getting error while connecting to DB

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
vinayvemula
Posts: 18
Joined: Mon Jun 03, 2019 2:09 am

getting error while connecting to DB

Post by vinayvemula »

Hi Team,

We are trying to monitor DB availability on our onprem sql servers and getting below error when connecting from our onprem Nagios server:

/usr/local/nagios/libexec/check_mssql -H sqlhost --username NagiosSQL --password ****** --port 2058 --database SQLDB
CRITICAL: Could not connect to dblib:host=sqlhost:2058;dbname=SQLDBas NagiosSQL (Exception: SQLSTATE[01002] Adaptive Server connection failed (sqlhost) (severity 9)).

----------------------------------------------------------------
php plugins are installed:

rpm -qa | grep "php-pdo"
php-pdo-5.4.16-46.1.el7_7.x86_64

rpm -qa | grep "php-mssql"
php-mssql-5.4.16-9.el7.x86_64

----------------------------------------------------------------------
tds file contents are below:
vi /etc/freetds.conf
[global]
# TDS protocol version
tds version = auto

# 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

# To reduce data sent from server for BLOBs (like TEXT or
# IMAGE) try setting 'text size' to a reasonable limit
; text size = 64512

# If you experience TLS handshake errors and are using openssl,
# try adjusting the cipher list (don't surround in double or single quotes)
# openssl ciphers = HIGH:!SSLv2:!aNULL:-DH

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

# A typical Microsoft server
[egServer73]
host = ntmachine.domain.com
port = 1433
tds version = 7.3
---------------------------------------------------------------------------------------------------------

We have same setup in cloud Nagios server and we are able to connect to cloud remote server DB availability. No issues in cloud

We tried also to connect from cloud Nagios server to our onprem remote sql serverr DB availability still there also we are getting error for onprem sql server DB connection.


Could you please help us in resolving the issue why we are getting the error.
User avatar
jbrunkow
Posts: 441
Joined: Fri Mar 13, 2020 10:45 am

Re: getting error while connecting to DB

Post by jbrunkow »

Is there a special character in your password?

You could also try putting the username in quotes. Please take a look at the following document for more information on what can cause this error.
Adaptive Server Connection Failed
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
vinayvemula
Posts: 18
Joined: Mon Jun 03, 2019 2:09 am

Re: getting error while connecting to DB

Post by vinayvemula »

Password we are using is a simple one no special characters in it.
We tried using single quotes to username still had no luck to it.

But We are having custom ports to monitor DBs

Could you please help us how to resolve the issue.
User avatar
jbrunkow
Posts: 441
Joined: Fri Mar 13, 2020 10:45 am

Re: getting error while connecting to DB

Post by jbrunkow »

What version of the plugin are you using?
See how the server name is not shown. The problem here is that the check_mssql plugin has a bug, it is not using the custom TCP port you defined when running the wizard (instead of the default 1433). This problem has been resolved in version 1.6.1 of the MSSQL Query wizard. To update to the latest version of the wizard navigate to Admin > System Extensions > Manage Config Wizards. On this page you can check for updates and install the latest available version.
Apparently there was a bug in a previous version of this plugin that would cause it to use the default port, even when the option was specifying otherwise. If you are using a version 1.6.1 or lower, you may want to update.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
vinayvemula
Posts: 18
Joined: Mon Jun 03, 2019 2:09 am

Re: getting error while connecting to DB

Post by vinayvemula »

Hi Team,

Plugin we are using is
check_mssql
and version is
Version 0.8.5 - 2019/010/18 # - Changed the output message depending on the querywarning and querycritical thresholds.

source: https://exchange.nagios.org/directory/P ... ql/details

Please provide us any alternate plugin if this plugin is of no use.
User avatar
jbrunkow
Posts: 441
Joined: Fri Mar 13, 2020 10:45 am

Re: getting error while connecting to DB

Post by jbrunkow »

Yes, so in that case you should update. Navigate to the Admin section of XI using the top bar > click Manage Config Wizards under System Extensions on the left > and click Check for Updates then Install Updates.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
vinayvemula
Posts: 18
Joined: Mon Jun 03, 2019 2:09 am

Re: getting error while connecting to DB

Post by vinayvemula »

Hi team,

Wizard version we are using is 1.6.7 Please find attached image.
Still getting the same error mentioned. Could you please help us how to resolve this error further.
You do not have the required permissions to view the files attached to this post.
User avatar
jbrunkow
Posts: 441
Joined: Fri Mar 13, 2020 10:45 am

Re: getting error while connecting to DB

Post by jbrunkow »

Dang! I thought that was it. :?

What result do you get if you scan the MsSQL server with nmap from the XI machine?

Code: Select all

nmap -p 2058 <host IP>
You can usually use the -h option to see the help page associated with the plugin. Please take a look at this to double check that all necessary options are present, and the correct values are being passed to them.

Code: Select all

/usr/local/nagios/libexec/check_mssql -h
It never hurts to send ( PM ) us a profile either! We can find lots of information about your system in there. You can download the profile by navigating to System Profile under System Config on the left pane > and clicking the Download Profile button on that page
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
vinayvemula
Posts: 18
Joined: Mon Jun 03, 2019 2:09 am

Re: getting error while connecting to DB

Post by vinayvemula »

Below is the output when ran nmap from nagios xi machine:

nmap -p 2058 sqlserver

Starting Nmap 6.47 ( http://nmap.org ) at 2020-08-19 19:14 CEST
Nmap scan report for sqlserver
Host is up (0.0010s latency).
rDNS record for sqlserveripaddress: sqlserver
PORT STATE SERVICE
2058/tcp open unknown

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
User avatar
jbrunkow
Posts: 441
Joined: Fri Mar 13, 2020 10:45 am

Re: getting error while connecting to DB

Post by jbrunkow »

Adaptive Server connection failed
(severity 9)
After doing some more digging on what that error message is telling us, I found several sources saying that the problem could be related to the TDS version and/or configuration.

The configuration file for TDS is likely in the following location. Uncomment out the line specifying the version.

Code: Select all

/etc/freetds/freetds.conf
I believe the config should designate your custom port for that service as well.

Code: Select all

Port = 2058
The output from the nmap command tells me that the host is reachable via that port, but we should verify that the service is assigned to it on the target machine as well.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked