Check_mssql - Could not connect to database

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
bsivavani
Posts: 339
Joined: Tue Oct 06, 2015 9:17 am

Check_mssql - Could not connect to database

Post 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 ?
Last edited by bsivavani on Thu Jan 31, 2019 12:53 pm, edited 1 time in total.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check_mssql - Could not connect to database

Post by mcapra »

Is this using Windows authentication or SQL Server authentication? I believe that plugin only supports SQL Server authentication.
Former Nagios employee
https://www.mcapra.com/
bsivavani
Posts: 339
Joined: Tue Oct 06, 2015 9:17 am

Re: Check_mssql - Could not connect to database

Post by bsivavani »

We are using SQL server authentication.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Check_mssql - Could not connect to database

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
bsivavani
Posts: 339
Joined: Tue Oct 06, 2015 9:17 am

Re: Check_mssql - Could not connect to database

Post by bsivavani »

We are able to connect to SQL server using telnet.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check_mssql - Could not connect to database

Post 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?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
bsivavani
Posts: 339
Joined: Tue Oct 06, 2015 9:17 am

Re: Check_mssql - Could not connect to database

Post 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.
Last edited by bsivavani on Fri Feb 01, 2019 10:21 am, edited 1 time in total.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check_mssql - Could not connect to database

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
bsivavani
Posts: 339
Joined: Tue Oct 06, 2015 9:17 am

Re: Check_mssql - Could not connect to database

Post 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 ~]$
kyang

Re: Check_mssql - Could not connect to database

Post 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?
Locked