MSSQL - Adaptive Server connection failed

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
eliassal
Posts: 28
Joined: Sun Nov 18, 2018 2:17 pm

MSSQL - Adaptive Server connection failed

Post by eliassal »

I configured Nagios to monitor SQL server, user is sysadmin and has all privileges . Nagios in not able to read any value, all values appear as "Unknown"

I went to Service Management, I did a "Test Check Command", getting the following error:
COMMAND: /usr/local/nagios/libexec/check_mssql_server.py -H 192.168.1.69 -U 'salam\\mylogin' -P 'my\*passord' -p 1433 --time2connect --warning 10 --critical 20
OUTPUT: DB-Lib error message 20002, severity 9:
Adaptive Server connection failed
Thanks for your help
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: MSSQL - Adaptive Server connection failed

Post by lmiltchev »

Have you tried all of the troubleshooting steps, outlined in our KB article on the topic?

https://support.nagios.com/kb/article/n ... d-735.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
eliassal
Posts: 28
Joined: Sun Nov 18, 2018 2:17 pm

Re: MSSQL - Adaptive Server connection failed

Post by eliassal »

HI, thanks. I followed the instructions in the KB to the letter, retried, getting same error

Testing check from command line...
COMMAND: /usr/local/nagios/libexec/check_mssql_server.py -H 192.168.1.69 -U 'mydomain\\salam' -P my\*password' -p 1433 --time2connect --warning 10 --critical 20
OUTPUT: DB-Lib error message 20009, severity 9:
Unable to connect: Adaptive Server is unavailable or does not exist
Net-Lib error during Connection refused Error 111 - Connection refused
eliassal
Posts: 28
Joined: Sun Nov 18, 2018 2:17 pm

Re: MSSQL - Adaptive Server connection failed

Post by eliassal »

Also I think that the KB article is not up-to-date as it shows in the arg field
--username .....--password
whereas in the Nagios it is

-U user -P password
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: MSSQL - Adaptive Server connection failed

Post by lmiltchev »

I see a couple of issues with your command:
/usr/local/nagios/libexec/check_mssql_server.py -H 192.168.1.69 -U 'mydomain\\salam' -P my\*password' -p 1433 --time2connect --warning 10 --critical 20
1. You are escaping the backslash after the domain name, but the whole expression is wrapped in single quotes (which will take it literally)
2. You are missing a single quote before "my". If you are wrapping the password in single quotes, you won't need to escape the "*" with "\".

Try running the command as such:

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H 192.168.1.69 -U 'mydomain\salam' -P 'my*password' -p 1433 --time2connect --warning 10 --critical 20
Did this help.
Also I think that the KB article is not up-to-date as it shows in the arg field
--username .....--password
whereas in the Nagios it is

-U user -P password
There are a few mssql plugins that are used with our wizards. The options vary a bit, but in most cases, you could use either one - the "long" or the "short" version. This particular one:
[root@main-nagios-xi libexec]# ./check_mssql -h
check_mssql, 0.8.4

This plugin checks various aspect of an MSSQL server. It will also
execute queries or stored procedures and return results based on
query execution times and expected query results.

Options:
-h, --help Print detailed help screen.
-V, --version Print version information.
-H, --hostname Hostname of the MSSQL server.
-U, --username Username to use when logging into the MSSQL server.
-P, --password Password to use when logging into the MSSQL server.
-F, --cfgfile Read parameters from a php file, e. g.
-I, --instance Optional MSSQL Instance. (Overrides port)
-p, --port Optional MSSQL server port. (Default is 1433)
-d, --database Optional DB name to connect to.
-q, --query Optional query or SQL file to execute on MSSQL server.
-l, --longquery Optional query or SQL file to execute on MSSQL server.
The query is used for multiple line output only.
By default Nagios will only read the first 4 KB.
(MAX_PLUGIN_OUTPUT_LENGTH)
--decode Reads the query -q in urlencoded format. Useful if
special characters are in your query.
--decodeonly Decode the query -q
Prints the decoded query string and exits.
--encode Encodes the query -q
Prints urlencoded query and exits.
-s, --storedproc Optional stored procedure to execute on MSSQL server.
--parameters Optional parameters to pass to the stored procedure.
Assumes a comma-delimited list. Ignored if -s isn't set.
-r, --result Expected result from the specified query, requires -q.
The query pulls only the first row for comparison,
so you should limit yourself to small, simple queries.
-w, --warning Warning threshold in seconds on duration of check
-c, --critical Critical threshold in seconds on duration of check
-W, --querywarning Query warning threshold
-C, --querycritical Query critical threshold
The check_mssql_server.py uses the following options:
[root@main-nagios-xi libexec]# ./check_mssql_server.py -h
Usage: check_mssql_server.py -H hostname -U user -P password -T table --mode

Options:
-h, --help show this help message and exit

Required Options:
-H HOSTNAME, --hostname=HOSTNAME
Specify MSSQL Server Address
-U USER, --user=USER
Specify MSSQL User Name
-P PASSWORD, --password=PASSWORD
Specify MSSQL Password
Be sure to check out our Knowledgebase for helpful articles and solutions!
eliassal
Posts: 28
Joined: Sun Nov 18, 2018 2:17 pm

Re: MSSQL - Adaptive Server connection failed

Post by eliassal »

Ok thanks for the details, in any way, I tried both but still getting the same error.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: MSSQL - Adaptive Server connection failed

Post by lmiltchev »

Do you have any special characters in the usersname and/or password other than the "*"? Can you run the following commands and show the output?

Code: Select all

/usr/local/nagios/libexec/check_mssql_server.py -H 192.168.1.69 -U 'mydomain\salam' -P 'my*password'
nmap 192.168.1.69 -p 1433
Can you temporarily change the password to something simple without special characters for troubleshooting purposes, and try your check again?
Be sure to check out our Knowledgebase for helpful articles and solutions!
eliassal
Posts: 28
Joined: Sun Nov 18, 2018 2:17 pm

Re: MSSQL - Adaptive Server connection failed

Post by eliassal »

Where should I run the command, in the VM or in the service test ui page?
eliassal
Posts: 28
Joined: Sun Nov 18, 2018 2:17 pm

Re: MSSQL - Adaptive Server connection failed

Post by eliassal »

I ran the command in the vM, getting the exact same error
Net-Lib error during connection refused error 111 - Connection refused
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: MSSQL - Adaptive Server connection failed

Post by lmiltchev »

Open a ssh (putty) session to your Nagios XI server, and ran the two commands from the command line in the putty terminal.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked