Nagios XI - MSSQL Wizards - Adaptive Server connection failed


Problem Description

After running the MSSQL wizards your new service has a CRITICAL or UNKNOWN state with the following error:

CRITICAL: Could not connect to dblib:host=mssql01.box293.local:1433;dbname=Sample as BOX293nagios
(Exception: SQLSTATE[01002] Adaptive Server connection failed (mssql01.box293.local:1433) (severity 9)).

OR

CRITICAL: Could not connect to dblib:host=mssql01.box293.local:1433;dbname=Sample as BOX293\nagios
(Exception: SQLSTATE[01002] Adaptive Server connection failed (severity 9)).

OR

DB-Lib error message 20002, severity 9:
Adaptive Server connection failed

 

In the first two errors above the first line is almost identical except for the username in the output, this is the key to identifying the problem as there are two separate solutions to this problem. The last two errors have the same solution.

A similar error is generated for a separate issue:

PHP Notice: Undefined variable: db_connstr in /usr/local/nagios/libexec/check_mssql on line 416
CRITICAL: Could not connect to as nagios (Exception: SQLSTATE[01002] Adaptive Server connection failed (severity 9)).

Please refer to the Custom Port solution in this KB article to resolve this issue.

 

 

Username Not Enclosed In Quotes

This addresses the following error:

CRITICAL: Could not connect to dblib:host=mssql01.box293.local:1433;dbname=Sample as BOX293nagios
(Exception: SQLSTATE[01002] Adaptive Server connection failed (mssql01.box293.local:1433) (severity 9)).

 

The service in Nagios XI has the username in the domain\user format however it is NOT enclosed in quotes. This screenshot of the service in Core Configuration Manager shows without the quotes:

 

 

This screenshot shows the service after quotes have been added (this is required to fix the problem):

 

 

After making this change save the service and Apply Configuration. Then go and force an immediate check of the service to test that it is working correctly.

 

 

 

System Configuration File Change

This addresses the following error:

CRITICAL: Could not connect to dblib:host=mssql01.box293.local:1433;dbname=Sample as BOX293\nagios
(Exception: SQLSTATE[01002] Adaptive Server connection failed (severity 9)).

OR

DB-Lib error message 20002, severity 9:
Adaptive Server connection failed

 

The plugins require a change to the /etc/freetds.conf configuration file to allow them to work with Windows Authentication.

 

Execute the following command to open the /etc/freetds.conf file in vi:

vi /etc/freetds.conf

When using the vi editor, to make changes press i on the keyboard first to enter insert mode. Press Esc to exit insert mode.

 

Under the [global] section find the following:

[global]
        # TDS protocol version
;       tds version = 4.2

 

Remove the semi-colon (;) at the beginning of the tds version line and change the value to 7.2as follows:

[global]
        # TDS protocol version
       tds version = 7.2

 

When you have finished, save the changes in vi by typing:

:wq

and press Enter.

 

After making these changes go back into the XI web interface and force an immediate check of the service to test that it is working correctly.

 

 

 

Custom Port

This addresses the following error:

PHP Notice: Undefined variable: db_connstr in /usr/local/nagios/libexec/check_mssql on line 416
CRITICAL: Could not connect to as nagios (Exception: SQLSTATE[01002] Adaptive Server connection failed (severity 9)).

 

Notice this:

Could not connect to as nagios

 

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.

 

 

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/



Article ID: 735
Created On: Thu, Aug 3, 2017 at 1:05 AM
Last Updated On: Thu, Oct 24, 2019 at 4:33 PM
Authored by: tlea

Online URL: https://support.nagios.com/kb/article/nagios-xi-mssql-wizards-adaptive-server-connection-failed-735.html