Welcome to It-Slav.Net blog
Peter Andersson

I've already got a female to worry about. Her name is the Enterprise.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0

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


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:

 #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
 if [ $? != "0" ]
 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
 /opt/plugins/custom/send_nsca -H $NAGIOSHOST -c send_nscav2.cfg < passive_check_data_passed > /dev/null

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 success
Note: 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



One Response to “Monitor MySQL backup automysqlbackup with op5 Monitor or Nagios”

  1. Diigo’ the week (weekly) » The Bipeds’ Monitor Says:

    […] Monitor MySQL backup automysqlbackup with op5 Monitor or Nagios | An It-Slave in the digital saltmin… […]

Leave a Reply

five × = 30

Book reviews
FreePBX 2.5
Powerful Telephony Solutions

Asterisk 1.6
Build a feature rich telephony system with Asterisk

Learning NAGIOS 3.0

Cacti 0.8 Network Monitoring,
Monitor your network with ease!