Monitoring SQL Database - inside.

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.
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Monitoring SQL Database - inside.

Post by Melanie123 »

Hello again,

I come with another question from my side.
Specifically, I mean the SQL database.

I have a database on a separate server to which data goes over the TCP/IP port.
I would like (if it is possible) to get inside the sql database from the server Nagios also on the TCP/IP port.
In the database from time to time appear "errors" from my application (defined by me). Can I call a plugin to let Nagios detect this and inform me about it when the line with the keyword "1" appears in the "error" column?
What agent to install?
How can you possibly approach this topic?

I will be grateful for every tips, because I have no idea how to counter it and if it is possible.

Regards!
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Monitoring SQL Database - inside.

Post by npolovenko »

Hello, @Melanie123. I would recommend using one of MySQL query plugins, to query the data table and get the check in a critical state based on specified thresholds. For example, this one:
https://www.monitoring-plugins.org/doc/ ... query.html
cd /usr/local/nagios/libexec/
[root@centos7x64 libexec]# ./check_mysql_query
Must specify a SQL query to run
Usage:
check_mysql_query -q SQL_query [-w warn] [-c crit] [-H host] [-P port] [-s socket]
[-d database] [-u user] [-p password] [-f optfile] [-g group]
It's a standard plugin, so you should already have it in the /usr/local/nagios/libexec/ directory.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Re: Monitoring SQL Database - inside.

Post by Melanie123 »

Yes, that's it!

But... How can this plugin also support the MS SQL database?

I found "check_mssql" (https://exchange.nagios.org/directory/P ... ql/details), i think this is what i search.
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Re: Monitoring SQL Database - inside.

Post by Melanie123 »

I configured everything - I think.

And when I tried plugin:

Code: Select all

./check_mssql -H x.x.x.x -U Administrator -P 'xxx' -p 1433 -d test -q "SELECT COUNT(*) FROM test"
I have this:

Code: Select all

CRITICAL: Could not connect to dblib:host=x.x.x.x;dbname=test as Administrator (Exception: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)).
And I have no idea what else to change.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Monitoring SQL Database - inside.

Post by npolovenko »

@Melanie123, Please check out this troubleshooting guide that we have:
https://support.nagios.com/kb/article/n ... d-735.html
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Re: Monitoring SQL Database - inside.

Post by Melanie123 »

npolovenko, I tried everything, but nothing changed. Do you have any idea yet?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Monitoring SQL Database - inside.

Post by mcapra »

You might try some of the various Python based plugins for SQL Server:
https://github.com/NagiosEnterprises/ch ... ollection/

This will help identify if it's a SQL Server connection issue, or an issue with the check_mssql plugin you used previously.
Former Nagios employee
https://www.mcapra.com/
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Monitoring SQL Database - inside.

Post by tmcdonald »

Thanks for the assist, @mcapra!

@Melanie123, let us know if you have further (related) questions.
Former Nagios employee
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Re: Monitoring SQL Database - inside.

Post by Melanie123 »

Are these plugins compatible with MS SQL 2014?
I found the information in all that they support to the 2008/2012 server version.

Now I have problems with connecting to the SQL server and I'm looking for the source of the problem.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Monitoring SQL Database - inside.

Post by mcapra »

Melanie123 wrote:Are these plugins compatible with MS SQL 2014?
I haven't encountered any issues with using these plugins against SQL Server 2014. Admittedly, I haven't tested every possible use of the plugins.
Melanie123 wrote:Now I have problems with connecting to the SQL server and I'm looking for the source of the problem.
Can you share the error message that the plugins are producing? It may give us useful insights for troubleshooting.
Former Nagios employee
https://www.mcapra.com/
Locked