Check MSSQL Database

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
hixavier
Posts: 12
Joined: Tue Jul 30, 2019 6:57 am

Check MSSQL Database

Post by hixavier »

Hello,

I'm having difficulties getting the check_mssql_database.py check to successfully connect to a database. I'm able to connect to the database using tsql, and just pymssql in a python interpreter. But when I try to connect using the Nagios check, I get the following error:

(20009, 'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (10.48.168.22:1443)\nNet-Lib error during Connection refused (111)\n')

Any adivse?

Thanks !
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Check MSSQL Database

Post by lmiltchev »

Try resolving your issue by following the steps, outlined in the KB article below:

https://support.nagios.com/kb/article/n ... d-735.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
hixavier
Posts: 12
Joined: Tue Jul 30, 2019 6:57 am

Re: Check MSSQL Database

Post by hixavier »

Thanks. I've tried troubleshooting steps, but still getting the error. Is the check_mssql_database.py my only option for connecting to a mssql database with nagios?
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Check MSSQL Database

Post by lmiltchev »

I've tried troubleshooting steps, but still getting the error.
What exactly have you tried? Can you explain?

Please show us the exact command that you are using, run from the command line, along with the output of it.
Is the check_mssql_database.py my only option for connecting to a mssql database with nagios?
There may be some 3rd party plugins on the Nagios Exchange. If you find one that looks promising, you can test it, add a new command and a service to Nagios XI, following the document below:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
hixavier
Posts: 12
Joined: Tue Jul 30, 2019 6:57 am

Re: Check MSSQL Database

Post by hixavier »

So far, I've tried the following:


First, I initially entered the check_mssql_database.py command which failed:

Code: Select all

$ ./check_mssql_database.py -H '******' -p 1443 -U 'nagios' -P '*****' -T '******''    
(20009, 'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (10.152.15.196)\nNet-Lib error during Connection refused (111)\nDB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (10.152.15.196)\nNet-Lib error during Connection refused (111)\n')

Then, I followed the suggestion in the article you replied with, by changing the tds protocol versin to 7.2:
After that, I tried running the ./check_mssql_database.py, which failed again.

Code: Select all

$ ./check_mssql_database.py -H '******' -p 1443 -U 'nagios' -P '*****' -T '******''    
(20009, 'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (10.152.15.196)\nNet-Lib error during Connection refused (111)\n')



I'm even able to access the database using tsql

Code: Select all

$ tsql -S testdb -U nagios -P ******
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Check MSSQL Database

Post by lmiltchev »

OK, it seems like the python versions check_mssql_database.py and check_mssql_server.py were combined and rewritten in PHP as check_mssql_server.php.

Can you try using the "check_mssql_server.php" plugin to see if it's going to work better for you?

Example:

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.php -H x.x.x.x  --checktype 'database' -U 'username' -P 'password' --instancename 'master' --perftype default -p 1433 --mode test --warning 10 --critical 20
activetrans passed!
datasize passed!
logbytesflushed passed!
logcachehit passed!
logfilessize passed!
logfilesused passed!
logfileusage passed!
logflushes passed!
logflushwaits passed!
loggrowths passed!
logshrinks passed!
logtruncs passed!
logwait passed!
transpsec passed!
0/14 tests failed.
Valid modes are (from the plugin's usage):
--mode Required: Must specify one and only one test, from the list, below...
(-h or --help for more information)

Available Tests

activetrans
datasize
logbytesflushed
logcachehit
logfilessize
logfilesused
logfileusage
logflushes
logflushwaits
loggrowths
logshrinks
logtruncs
logwait
transpsec
custom
time2connect
test
runall
Be sure to check out our Knowledgebase for helpful articles and solutions!
hixavier
Posts: 12
Joined: Tue Jul 30, 2019 6:57 am

Re: Check MSSQL Database

Post by hixavier »

I don't have the_mssql_server.php check. Do you know where I could download it?
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Check MSSQL Database

Post by lmiltchev »

What is the version of Nagios XI and MSSQL Database wizard that you are currently using?

The plugin is installed by the MSSQL Database wizard ver. 2.0.0. You may be able to update the wizard to the latest version by going to Admin > System Extensions > Manage Config Wizards > Check for Updates > Install Updates. If you Nagios XI version is too old, you may need to update XI in order to get the latest wizards.
Be sure to check out our Knowledgebase for helpful articles and solutions!
hixavier
Posts: 12
Joined: Tue Jul 30, 2019 6:57 am

Re: Check MSSQL Database

Post by hixavier »

I updated XI, and I now have the "check_mssql_server.php check, and it returns an OK when I use on an MSSQL server to check the database.

Now, when attempting to check for a specific instance, on the databse, it returns an OK even if I enter an invalid instance name.
Example:

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.php -H **** -U '****' -P '****' --perftype default -p 1433 --checktype 'database' -i 'blahblah' --mode time2connect --warning 10 --critical 20
OK: Time to connect was 0.006271s|time=0.006271s;10;20;;

Thanks for all your help with this, so far!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check MSSQL Database

Post by scottwilkerson »

Instance name is a capital I

Code: Select all

-I, --instance      Optional: MSSQL Instance. (Overrides port)
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked