Pages

Tuesday, August 23, 2016

Nagios Plugin Mysql DB - "check_mysql_health"

1. DESCRIPTION

- Plugin Name :-  check_mysql_health
- Plugin Purpose :- To check MySQL Database Server for various parameters on performance and health level

2. PRE-REQUISITS

- MySQL Client packages i.e. “mysql”
- Database level access username and password

3. PLUGIN DETAILS

- Plugin simply checks for MySQL server information on the basis of available options for monitoring.
- Based on configured threshold for various available options alert is thrown

4. INPUT

--hostname
IP address of MySQL Database Server or Hostname of MySQL Database Server (Note:- Hostname is getting resolved from Nagios Server)
--port
Port number (default: 3306) for MySQL Database Server
--username
Username to connect to MySQL Database Server
--password
Password to connect to MySQL Database Server
--database
Database name to be checked for in MySQL Database Server
--warning
WARNING status if Value is more than INTEGER value for specified parameter/mode of plugin output for MySQL Database Server
--critical
CRITICAL status if Value is more than INTEGER value for specified parameter/mode of plugin output for MySQL Database Server
--mode
connection-time - Time to connect to MySQL Database server
uptime - Time MySQL Database server is running
threads-connected - Number of currently open connections on MySQL Database Server
threadcache-hitrate - Hit rate of the thread-cache on MySQL Database Server
threads-created - Number of threads created per sec on MySQL Database Server
threads-running - Number of currently running threads on MySQL Database Server
threads-cached - Number of currently cached threads on MySQL Database Server
connects-aborted - Number of aborted connections per sec on MySQL Database Server
clients-aborted - Number of aborted connections (because the client died) per sec on MySQL Database Server
slave-lag - MySQL Database Server is X seconds behind master
slave-io-running - Slave io running on MySQL Database Server: Yes
slave-sql-running - Slave sql running on MySQL Database Server: Yes
qcache-hitrate - Query cache hitrate on MySQL Database Server
keycache-hitrate - MyISAM key cache hitrate on MySQL Database Server
bufferpool-hitrate - InnoDB buffer pool hitrate MySQL Database Server
bufferpool-wait-free - InnoDB buffer pool waits for clean page available on MySQL Database Server
log-waits - InnoDB log waits because of a too small log buffer on MySQL Database Server
tablecache-hitrate - Table cache hitrate on MySQL Database Server
table-lock-contention - Table lock contention on MySQL Database Server
index-usage - Usage of indices on MySQL Database Server
tmp-disk-tables - Percent of temp tables created on disk on MySQL Database Server
table-fragmentation - Show tables which should be optimized on MySQL Database Server
open-files - Percent of opened files on MySQL Database Server
slow-queries - Slow queries running on MySQL Database Server
long-running-procs- long running processes on MySQL Database Server
sql - any sql command to be executed on MySQL Database Server
--name
The name of something that needs to be further specified, currently only used for sql statements
--name2
if name is a sql statement, this statement would appear in the output and the performance data. This can be ugly, so name2 can be used to appear instead.

5. OUTPUT

Possible outputs are as below,
- “table CHARACTER_SETS is 0.00% fragmented, table COLLATIONS is 0.00% fragmented, table COLLATION_CHARACTER_SET_APPLICABILITY is 0.00% fragmented, table COLUMNS is 0.00% fragmented, table COLUMN_PRIVILEGES is 0.00% fragmented, table KEY_COLU”
Fragmentation related health check output.

- “index_usage=0.01%;60;80 index_usage_now=0.00%”
Index usage on MySQL Database Server

- “pct_open_files=0.299%;40.000;50.000 open_files=299;40000;50000”
Open files in use on MySQL Database Server

- “qps=0;50;100”
Query Per Seconds running on MySQL Database Server

- “slave_lag=0;1;2”
Slave LAG for an MySQL Database Server

- “slow_queries_rate=0.00%;5;10”
Number of slow running queries on MySQL Database Server

- “connection_time=0.0157s;0;0”
Connection time to MySQL Database Server

6. EXAMPLE

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode connection-time

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode uptime

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode threads-connected

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode threadcache-hitrate

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode threads-created

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode threads-running

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode threads-cached

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode connects-aborted

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode clients-aborted

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode slave-lag

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode slave-io-running

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode slave-sql-running

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode qcache-hitrate

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode bufferpool-hitrate

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode keycache-hitrate

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode log-waits

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode tablecache-hitrate

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode table-lock-contention

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode index-usage

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode tmp-disk-tables

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode table-fragmentation

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode open-files

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode slow-queries

/usr/lib64/nagios/plugins/check_mysql_health --hostname [ HOSTADDRESS ] --port [ PORT ]  --username [ DBUser ] --password [ DBPass ] --database [ Database ] --warning [ Warning ] --critical [ Critical ] --mode [ SQL QUERY ] --name [ **** ] --name2 [ **** ]

7. Plugin can be downloaded from Link

No comments:

Post a Comment