I have installed Nagios 4.0 on my Ubuntu 14.0 and i want a plugin to alert me based on daily scheduled MySql queries ..

if the result of ( select count(*) from tableName > 10 ) raise a critical alert or < 10 warning alert this query run every day for example.

is it even possible ?! if so can you tell any suggested plugins , ideas or where to start ..


I do exactly that. The test is pretty trivial, inasmuch as it connects to a custom database called nagios and selects from a table that contains just a single numeric value, alerting if that value isn't 74581 - but I figure if mysql works well enough to retrieve that exact number from a table, it's probably fine. You could run more complex queries, though.

command[check_mysql]=/usr/lib64/nagios/plugins/check_mysql_query -H -d nagios -u user -p pass -q "select * from nagioscheck;" -c 74581:74581 -w 74581:74581

This is invoked by NRPE (hence the format of the above, which is from nrpe.cfg); the check_mysql_query plugin is a standard nagios plugin, at least in my distro (CentOS 6 with the nagios-plugins package from RPMForge). It can also be found here (with thanks to the OP for the link).


Needed to delete the character ; at the end of the query to get it to work. Didn't understand why, but "select * from nagioscheck;" returned an error and "select * from nagioscheck" works.

  • 1
    The semicolon (;) terminates the query interactively but it isn't part of the query itself. When sending SQL statements from code you should usually leave it off. – chicks May 2 '16 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.