Check_mssql_health - script from .sql file

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Wosiu
Posts: 2
Joined: Wed Mar 13, 2019 8:59 am

Check_mssql_health - script from .sql file

Post by Wosiu »

Hi all,
I have 2 short questions. Is it possible to use .sql file in check_mssql_health plugin? Is it possible in plugin check_mssql to use hosname than hostaddress? Why Im asking those questions? When the server is behind NAT, it is not possible to communicate with it by IP address.

BR,
Wosiu
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: Check_mssql_health - script from .sql file

Post by mbellerue »

Can you use a .sql file in the plugin? For check_mssql_health specifically, I don't think so. This is a 3rd party plugin, so I may be wrong, but it looks like it monitors specific aspects of SQL Server.

However, you can use the check_mssql plugin that does come with Nagios. There is a --query flag, and for that flag you can just specify the path to a .sql file and it will use the .sql file.

Can you use hostname rather than hostaddress? Yes, -H for Nagios plugins and most 3rd party plugins should just allow you to use the hostname or hostaddress interchangeably. However, be aware that there's really no difference between hostname and hostaddress when you get down to the networking. The host's name will need to be resolved to an address. So NAT or no, there needs to be a network path to the server you want to monitor. For servers behind a NAT, this is usually done with port address translation, which would work with the host's name or address.
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!
Wosiu
Posts: 2
Joined: Wed Mar 13, 2019 8:59 am

Re: Check_mssql_health - script from .sql file

Post by Wosiu »

Thank you for your response. I think we don't quite understand each other. I use check_mssql plugins. On several servers, it works correctly locally and remotely. The problem appeared with the servers behind NAT. For these servers, I have the error:
CRITICAL: Could not connect to dblib:host=Sserver.localMSSQLSERVER:dbname=master as monitoring_user (Exception: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (server.localMSSQLSERVER) (severity 9)).

Servers are available because I can log in using sqlcmd. I decided to try another plugin, check_mssql_health. This plugin works with servers behind the NAT fine but I don't know how to run sql queries from the .sql file using this script.
It is possible that the problem exists because the server behind NAT is the only one that has MSSQL 2016. I bet that there may be a problem in the tds version.
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: Check_mssql_health - script from .sql file

Post by mbellerue »

There really shouldn't be a reason that check_mssql does not work with SQL Server behind a NAT. Unfortunately we can't test every scenario with every plugin.

The other side of the coin is that check_mssql_health can connect through the NAT, but it can't use .sql files to run queries. At least, not that I've seen from their documentation. I may be missing something.

Your 3rd option would be to try to create a plugin, probably based on sqlcmd since you know it connects through the NAT. That way you know your plugin can traverse the NAT, and you can build it so it accepts the .sql file.
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