Page 2 of 4

Re: Check_mssql - Could not connect to database

Posted: Wed Oct 11, 2017 1:08 pm
by bsivavani
[root@XXXX ~]# curl -v telnet://SQLServer:1433
* About to connect() to SQLServer port 1433 (#0)
* Trying SQLServer... connected
* Connected to SQLServer (SQLServer) port 1433 (#0)
^C
[root@XXXX ~]#
[root@XXXX ~]# telnet SQLServer 1433
Trying SQLServer...
Connected to SQLServer.
Escape character is '^]'.
^]
telnet> ^logout
Connection closed by foreign host.
[root@XXXX ~]#
[root@XXXX ~]#


Kindly let me know what firewall rules that I can check on server ?

Re: Check_mssql - Could not connect to database

Posted: Wed Oct 11, 2017 4:39 pm
by npolovenko
@bsivavani, There were some major bug fixes in the latest version of this plugin(0.8.2). In particular, there were difficulties related to passwords with special characters(you can read more here: https://support.nagios.com/kb/article/n ... ailed.html).
To upgrade the plugin in your Nagios XI web interface go to Admin/Mange Config Wizards. Then click on #1 Check for Updates #2 Install Updates. After that please check your plugin version and make sure it's the latest one.
Let us know if that helps.
And just to throw in another thought, sometimes on MySQL Servers that were set up with the Active directory, the username would change depending on what computer in the network is trying to access it.

Re: Check_mssql - Could not connect to database

Posted: Thu Oct 12, 2017 4:38 am
by bsivavani
Hi,

We have upgraded the plugin to 1.6.2 and we are receiving below error. We don't have special characters in password.

[nagios@XXXX libexec]$ /usr/local/nagios/libexec/check_mssql -H SQLServer --username XXXX --password XXXX --port 1433 --database TESTDB
CRITICAL: Could not connect to dblib:host=SQLServer;dbname=TESTDB as testuser (Exception: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)).
[nagios@XXXX libexec]$

Re: Check_mssql - Could not connect to database

Posted: Thu Oct 12, 2017 10:04 am
by npolovenko
Hi, @bsivavani. Can you make sure that you have these two modules installed:

Code: Select all

 yum install php-pdo
yum install php-mssql
After that please modify your /etc/freetds.conf file. (see the screenshot)
Untitled.png
When that's done restart your mssql service

Code: Select all

systemctl restart mssql-server

Re: Check_mssql - Could not connect to database

Posted: Thu Oct 12, 2017 11:57 am
by bsivavani
Hi,

Below mentioned modules php-pdo and php-mssql installed already.

[root@XXXXX ~]# rpm -qa | grep "php-pdo"
php-pdo-5.3.3-47.el6.x86_64
[root@XXXXX ~]#
[root@XXXXX ~]# rpm -qa | grep "php-mssql"
php-mssql-5.3.3-4.el6.x86_64
[root@XXXXX ~]# 

Just want to confirm is it mssql-server or mysql service to restart?

Re: Check_mssql - Could not connect to database

Posted: Thu Oct 12, 2017 12:54 pm
by tacolover101
i believe the freetds module is for PHP to intract with mssql from my understanding. you shouldn't need to restart the mssql-server following that.

Re: Check_mssql - Could not connect to database

Posted: Thu Oct 12, 2017 3:46 pm
by npolovenko
Thank you for the correction, @tacolover101!
@bsivavani, can you post the whole freetds.conf file here as well?

Re: Check_mssql - Could not connect to database

Posted: Fri Oct 13, 2017 8:32 am
by bsivavani
Please find /etc/freetds.conf entries

[nagios@XXXXX etc]$ cat freetds.conf
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".

# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
; tds version = 4.2

# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff

# Command and connection timeouts
; timeout = 10
; connect timeout = 10

# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512

# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0

# A typical Microsoft server
[egServer70]
host = ntmachine.domain.com
port = 1433
tds version = 7.0
[nagios@XXXXX etc]$

Re: Check_mssql - Could not connect to database

Posted: Fri Oct 13, 2017 9:17 am
by npolovenko
@bsivavani, Go ahead and uncomment this line:

Code: Select all

; tds version = 4.2
and change it to:

Code: Select all

tds version = 7.0

Re: Check_mssql - Could not connect to database

Posted: Fri Oct 13, 2017 12:46 pm
by bsivavani
I made changes to tds version as 7.0 in freetds.conf, but still receiving the same error

[nagios@XXXX~]$ /usr/local/nagios/libexec/check_mssql -H MSSQLLISTENER --username XXXX --password YYYY--port 1433 --database TESTDB
CRITICAL: Could not connect to dblib:host=MSSQLLISTENER;dbname=TESTDB as XXXX (Exception: SQLSTATE[01002] Adaptive Server connection failed (severity 9)).
[nagios@XXXX~]$
[nagios@XXXX~]$ /usr/local/nagios/libexec/check_mssql -H MSSQLServer --username XXXX --password YYYY --port 2056 --database TESTDB
CRITICAL: Could not connect to dblib:host=MSSQLServer;dbname=TESTDB as XXXX (Exception: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)).
[nagios@XXXX ~]$