Activities

October 2011
M T W T F S S
« Sep   Nov »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Nagios : Monitoring MySQL runtime variables

Here I have a requirement of monitoring say “Skip_Counter” which represent no. of sql queries that containing errors while executing binary logs at the slave side.

This MySQL slave uses slave-skip-errors=all options in my.cnf file. Enabling this option cause data inconsistency unless you are aware about what you are dealing with. I did this because I’m getting certain unwanted duplicate key errors in slave server and caused replication stops working.

You may get my script download from here
You may need to update the certain variables declare in that file as shown below,

warn : This warns you when threshold limit reached.
crit: This will send you critical alert when your threashold reaches at this value
user : mysql user
pass: mysql password

The core of this script is a single line which grep the output of “SHOW SLAVE STATUS”

Eg: seconds=`$mysqlpath/mysql -u $user -p$pass -e ‘show slave status\G’ | /bin/grep Skip_Counter | /bin/cut -f2 -d:`

You can modify this line to get any variables value you are looking for to monitor. Also can use the same for monitoring mysql runtime variable in mysql server as you like.

Also pls note that you can customize the notification messages content by editing this script

In nagios client I added the following lines

 #vi /usr/local/nagios/etc/nrpe.cfg

command[check_skip_error]=/bin/bash /home/installation/scripts/slave_check_skip-cntr.sh
[root@db03 scripts]# service xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]

And in Nagios monitoring host, add new service for monitoring this

[root@nagios ~]# vi /usr/local/nagios/etc/objects/db03.cfg
define service{
 use generic-service
 host_name  Db03
 service_description Skipped SQL errors
 check_command check_nrpe!check_skip_error
 contact_groups   svr-dba
 }

[root@nagios ~]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

This script would be a multipurpose one definitely as I was modified this script given from Nagios Exchange plugins repository :-).

#### I’m good to tweak others scripts 🙂 ###

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>