MS SQL Monitoring

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

MS SQL Monitoring

Post by raamardhani7 »

Hi Team,

I am trying to set up MS SQL monitoring and I am facing the below issue.

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H server -U 'nagios' -P 'password' -I 'server' --time2connect --warning 1 --critical 5
Connection to the database failed for an unknown reason.
Could you please help me here, thanks.

Regards,
Ram.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: MS SQL Monitoring

Post by lmiltchev »

/usr/local/nagios/libexec/check_mssql_server.py -H server -U 'nagios' -P 'password' -I 'server' --time2connect --warning 1 --critical 5
Connection to the database failed for an unknown reason.
You should run:
/usr/local/nagios/libexec/check_mssql_server.py -H server -U 'nagios' -P 'password' -I 'Instance' --time2connect --warning 1 --critical 5
Connection to the database failed for an unknown reason.
To find out what are the instances installed on the server type "regedit" in the search bar, and hit "Enter". Then go to:

HKEY_LOCAL_MACHINE -> SOFTWARE -> MICROSOFT -> MICROSOFT SQL SERVER -> INSTALLEDINSTANCES

double-click on "InstalledInstances" on the right-hand side to view them.

Instead of using an instance, you can try using a port number ("-p"). Use one or the other - can't use both. Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Re: MS SQL Monitoring

Post by raamardhani7 »

lmiltchev wrote:
/usr/local/nagios/libexec/check_mssql_server.py -H server -U 'nagios' -P 'password' -I 'server' --time2connect --warning 1 --critical 5
Connection to the database failed for an unknown reason.
You should run:
/usr/local/nagios/libexec/check_mssql_server.py -H server -U 'nagios' -P 'password' -I 'Instance' --time2connect --warning 1 --critical 5
Connection to the database failed for an unknown reason.
To find out what are the instances installed on the server type "regedit" in the search bar, and hit "Enter". Then go to:

HKEY_LOCAL_MACHINE -> SOFTWARE -> MICROSOFT -> MICROSOFT SQL SERVER -> INSTALLEDINSTANCES

double-click on "InstalledInstances" on the right-hand side to view them.

Instead of using an instance, you can try using a port number ("-p"). Use one or the other - can't use both. Hope this helps.
Hi Team,

I have tried with the port.

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H server -U 'nagios' -P 'password' -p 1433 --time2connect --warning 1 --critical 5
SQL Server message 18456, severity 14, state 1, line 1:
Login failed for user 'nagios'.
DB-Lib error message 18456, severity 14:
General SQL Server error: Check messages from the SQL Server
DB-Lib error message 20002, severity 9:
Adaptive Server connection failed

User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: MS SQL Monitoring

Post by lmiltchev »

This Wizard/Plugin requires SQL authentication and will not work with Windows Auth. What kind of user is "nagios"? Does it have sufficient MSSQL privileges? Do you have any special characters in the password?
Be sure to check out our Knowledgebase for helpful articles and solutions!
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Re: MS SQL Monitoring

Post by raamardhani7 »

lmiltchev wrote:This Wizard/Plugin requires SQL authentication and will not work with Windows Auth. What kind of user is "nagios"? Does it have sufficient MSSQL privileges? Do you have any special characters in the password?
Password had @ in it, but earlier I tired without that too. Even then I had the same issue.

COuld you please tell me what privileges that we can grant for the user nagios, so that I can get it done ad give a try. thanks.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: MS SQL Monitoring

Post by lmiltchev »

The user has to have at least database level permissions of "Connect" and role - "db_owner".
Be sure to check out our Knowledgebase for helpful articles and solutions!
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Re: MS SQL Monitoring

Post by raamardhani7 »

lmiltchev wrote:The user has to have at least database level permissions of "Connect" and role - "db_owner".
Hi Lmiltchev,

db_owner permissions are given to the user id.

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H USRCSQLQ05 -U 'domain\user' -P 'passwd' -p 1433 --time2connect --warning 10
DB-Lib error message 20002, severity 9:
Adaptive Server connection failed
Could you please advice me here. thanks.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: MS SQL Monitoring

Post by tgriep »

The check_mssql_server.py plugin will NOT work with Windows Authentication and requires local SQL authentication.
You will have to setup a local account on the MSSQL server, set the user rights to DBO and give that user connect rights to the master database and the check should work for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Re: MS SQL Monitoring

Post by raamardhani7 »

tgriep wrote:The check_mssql_server.py plugin will NOT work with Windows Authentication and requires local SQL authentication.
You will have to setup a local account on the MSSQL server, set the user rights to DBO and give that user connect rights to the master database and the check should work for you.
Hi Tom,

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H USRCSQLQ05 -U 'userid' -P 'password@123' -p 1433 --time2connect --warning 10         
OK: Time to connect was 0.0247271060944s|time=0.0247271060944s;10;;;

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H USRCSQLQ05 -U 'userid' -P 'password@123' -p 1433 --averagewait --warning 20 --critical 30
SQL Server message 297, severity 16, state 1, line 1:
The user does not have permission to perform this action.
DB-Lib error message 297, severity 16:
General SQL Server error: Check messages from the SQL Server
But SQL team claims that they gave the highest privileges and whatever command we run using the user ID should work. i am going wrong somewhere with the command?

And they said when tried with the user ID and password that is shared, they are able to get the output for everything. could you please advise. thanks.
jomann
Development Lead
Posts: 611
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: MS SQL Monitoring

Post by jomann »

Does the user only have permissions for a specified table? There are some commands that read from the internal MS SQL tables that may require special permissions.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked