Page 1 of 4
Check_mssql - Could not connect to database
Posted: Fri Oct 06, 2017 10:06 am
by bsivavani
Hi,
We are trying to run MS SQL query using check_mssql plugin, but we were not able to connect database using below command
[nagios@XXXXX ~]$ /usr/local/nagios/libexec/check_mssql -H XXXX --username 'XXXX' --password 'XXXX' --database TEST --port 1433 --query "SELECT COUNT(*) FROM test_view" --result 0
CRITICAL: Could not connect to XXXX:1433 as XXXX.
[nagios@XXXXX ~]$
[nagios@XXXX ~]$ /usr/local/nagios/libexec/check_mssql -V
0.7.8
[nagios@XXXX ~]$
Kindly advice on the issue ?
Re: Check_mssql - Could not connect to database
Posted: Fri Oct 06, 2017 10:26 am
by mcapra
Is this using Windows authentication or SQL Server authentication? I believe that plugin only supports SQL Server authentication.
Re: Check_mssql - Could not connect to database
Posted: Fri Oct 06, 2017 1:37 pm
by bsivavani
We are using SQL server authentication.
Re: Check_mssql - Could not connect to database
Posted: Fri Oct 06, 2017 2:15 pm
by cdienger
Can you verify that the server running the check can connect to the sql server on port 1433 ? Test this by running telnet SQL_SERVER_IP 1433.
Re: Check_mssql - Could not connect to database
Posted: Mon Oct 09, 2017 7:37 am
by bsivavani
We are able to connect to SQL server using telnet.
Re: Check_mssql - Could not connect to database
Posted: Mon Oct 09, 2017 10:34 am
by scottwilkerson
bsivavani wrote:We are able to connect to SQL server using telnet.
And authenticate with the username and password you provided to the check_mssql command?
Re: Check_mssql - Could not connect to database
Posted: Mon Oct 09, 2017 12:13 pm
by bsivavani
With the below command we were not able to execute.
[nagios@XXXXX ~]$ /usr/local/nagios/libexec/check_mssql -H XXXX --username 'XXXX' --password 'XXXX' --database TEST --port 1433 --query "SELECT COUNT(*) FROM test_view" --result 0
CRITICAL: Could not connect to XXXX:1433 as XXXX.
[nagios@XXXXX ~]$
We were able to connect to database from SQL server end.
We are using MS SQL Server 2012.
Re: Check_mssql - Could not connect to database
Posted: Mon Oct 09, 2017 12:33 pm
by scottwilkerson
I guess my question was related to connecting with the same port, username and password, and doing do from the nagios server.
The server you test from matters because there could be firewalls that block IP's or ports
Re: Check_mssql - Could not connect to database
Posted: Wed Oct 11, 2017 9:20 am
by bsivavani
I am able to connect to SQL Server (Version 2016).. Please find below output
[nagios@XXXX ~]$ curl -v telnet://SQLServer:2056
* About to connect() to SQLServer port 2056 (#0)
* Trying SQLServer... connected
* Connected to SQLServer (SQLServer) port 2056 (#0)
^]
^C
[nagios@XXXX ~]$
Re: Check_mssql - Could not connect to database
Posted: Wed Oct 11, 2017 12:44 pm
by kyang
Can you connect using port 1433 and post the results. Instead of connecting to port 2056?
telnet SQL_SERVER_IP 1433
curl -v telnet://SQLServer:1433
I guess my question was related to connecting with the same port, username and password, and doing do from the nagios server.
The server you test from matters because there could be firewalls that block IP's or ports
Did you do as
@scottwilkerson suggested?