I have hinted about automysqlbackup in an earlier blog. Of course an important script like this should be monitored by Nagios or op5 Monitor. In my opinion the correct way of doing this is using a passive check that sends in the result of the backup into Nagios or op5 Monitor. The backup script is supposed to run every 24 hour. If no result from the script has been reported to Nagios or op5 Monitor within the last 26 hours it will be set to WARNING status.
The Nagios or op5 Monitor configuration:
# service 'MySQL backup'
define service{
use default-service
host_name dull
service_description MySQL backup
check_command check_dummy!1 "No Data from MySQL backup"
max_check_attempts 1
active_checks_enabled 0
check_freshness 1
freshness_threshold 93600
flap_detection_options n
contact_groups it-slav_mail,call_it-slav,it-slav_msn
stalking_options n
}
Explanation:
The freshness_threshold 93600 makes Nagios or op5 Monitor to run the check_command if no result has been sent in the last 26 hours i.e. set status to WARNING and the Status Information to “No Data from MySQL Backup”.
I’ve modified the automysqlbackup.sh.2.5 so if there are any errors the message will be sent to a temporary file:
cat "$LOGERR" cat "$LOGERR" > /tmp/automysqlbackuperror.log #this is added by peter@it-slav.net
A wrapper that starts automysqlbackup is created:
#!/bin/sh #This script is a wrapper for automysqlbackup #It runs automysqlbackup and sends the status of the automysqlbackup #to Nagios or op5 Monitor with nsca #By Peter Andersson #peter@it-slav.net #GPLv2
BASEDIR=/root/scripts/automysqlbackup/ NAGIOSHOST=op5
cd $BASEDIR
./automysqlbackup.sh.2.5 if [ $? != "0" ] then echo -n "dull MySQL backup 2 CRITICAL:" >passive_check_data_failed cat /tmp/automysqlbackuperror.log >> passive_check_data_failed /opt/plugins/custom/send_nsca -H $NAGIOSHOST -c send_nscav2.cfg < passive_check_data_failed else /opt/plugins/custom/send_nsca -H $NAGIOSHOST -c send_nscav2.cfg < passive_check_data_passed > /dev/null fi
If the backup is successful the content of passive_check_data_passed will be sent to Nagios or op5 Monitor. passive_check_data_passed looks like this:
dull MySQL backup 0 OK: MySQL backup successNote: Tabs is used as separators.
If the backup script fails it will send the content in passive_check_data_failed via nsca to Nagios or op5 Monitor. An example of passive_check_data_failed:
dull MySQL backup 2 CRITICAL:ERROR 1045 (28000): Access denied for user 'kalle'@'localhost' (using password: NO)Note: Tabs is used as separators.
Create a cron job that starts the wrapper:
0 23 * * * /root/scripts/automysqlbackup/automysqlwrapper.sh
Links:
One Response to “Monitor MySQL backup automysqlbackup with op5 Monitor or Nagios”
Leave a Reply
You must be logged in to post a comment.
May 31st, 2009 at 2:10 am
[…] Monitor MySQL backup automysqlbackup with op5 Monitor or Nagios | An It-Slave in the digital saltmin… […]