Page 1 of 4

MSSQL - Adaptive Server connection failed

Posted: Thu Nov 22, 2018 8:21 am
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

Re: MSSQL - Adaptive Server connection failed

Posted: Mon Nov 26, 2018 3:18 pm
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

Re: MSSQL - Adaptive Server connection failed

Posted: Tue Nov 27, 2018 11:21 am
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

Re: MSSQL - Adaptive Server connection failed

Posted: Tue Nov 27, 2018 11:23 am
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

Re: MSSQL - Adaptive Server connection failed

Posted: Tue Nov 27, 2018 12:12 pm
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

Re: MSSQL - Adaptive Server connection failed

Posted: Tue Nov 27, 2018 12:39 pm
by eliassal
Ok thanks for the details, in any way, I tried both but still getting the same error.

Re: MSSQL - Adaptive Server connection failed

Posted: Tue Nov 27, 2018 1:03 pm
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?

Re: MSSQL - Adaptive Server connection failed

Posted: Tue Nov 27, 2018 2:12 pm
by eliassal
Where should I run the command, in the VM or in the service test ui page?

Re: MSSQL - Adaptive Server connection failed

Posted: Tue Nov 27, 2018 2:16 pm
by eliassal
I ran the command in the vM, getting the exact same error
Net-Lib error during connection refused error 111 - Connection refused

Re: MSSQL - Adaptive Server connection failed

Posted: Tue Nov 27, 2018 2:18 pm
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.