Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 69 lines (43 sloc) 2.372 kb
README to mysql_health_check.pl
-------------------------------------------
Requirements:
A recent version of perl5.
CPAN Modules:
Nagios::Plugin - if you're lucky, rpmforge repo is configured in yum and you
can issue 'yum install perl-Nagios-Plugin' to install everything you need.
(optional) Writable directory for meta data cache from mysql. Defaults to
'/tmp/pdb_nagios_cache'. Can also run in non-caching mode, see below or
--help for more info.
To install:
* copy plugin to nagios plugin directory.
* chmod 755.
* Make sure cache directory is writable by nagios user.
Usage examples:
To check for long running queries, warn at 40 seconds, critical at 60 seconds:
mysql_health_check.pl --hostname=localhost --user=root --mode=long-query \
--warning=900 --critical=1800
To checked for locked queries:
mysql_health_check.pl --hostname=localhost --user=root --mode=locked-query
To check mysql status and variables; for example max connections, alert at > 80% used:
mysql_health_check.pl --hostname=localhost --user=root --mode=varcomp \
--expression="Max_used_connections/max_connections * 100" --comparison_warning=">80" \
--comparison_critical=">100"
--shortname=max_connections
In varcomp, you can use any variable from 'SHOW GLOBAL STATUS' and
'SHOW GLOBAL VARIABLES'.
To compare status and variables from previous run's cache file, you can do something like:
mysql_health_check.pl --hostname=localhost --user=root --mode lastrun-varcomp \
--comparison_warning ">80" \
--comparison_critical ">100" \
--expression "(current{Queries} - lastrun{Queries}) / (current{Uptime} - lastrun{Uptime})"
current{keyword} and lastrun{keyword} will be replaced with the appropriate value from the cache.
WARNING: There isn't good sanity checking here yet, so please get the keywords right or else you'll see warnings.
To check if mySQL is read-only, you can do:
mysql_health_check.pl --hostname=localhost --user=root --mode simple --expression read_only
To check the default storage engine, you can do:
mysql_health_check.pl --hostname=localhost --user=root --mode simple --expression engine
General Notes:
--warning and --critical Thresholds are very flexible, please see:
http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT
for detailed info on how to use them.
Use --help to a full list of supported arguments.
Jump to Line
Something went wrong with that request. Please try again.