Logoj0ke.net Open Build Service > Projects > internetx > nagios-plugins-automysqlbackup > check_multimysqlbackup
Sign Up | Log In

File check_multimysqlbackup of Package nagios-plugins-automysqlbackup

 
1
#!/bin/bash
2
3
CONFPATH="/etc/multimysqlbackup.conf"
4
5
STAT=0
6
if [ -s "${CONFPATH}" ] ; then
7
    # read each active host from multimysql backup config
8
    for LINE in `cat ${CONFPATH} | grep -v ^# | grep -v ^$ | sed -e s@" "@"%20%"@g` ; do
9
10
        # get the hostname
11
        export DBHOST=`echo ${LINE} | awk -F\; '{print $1}' | awk -F: '{print $1}'`
12
        unset BACKUPDIR
13
        # include default configuration to construct dynamic backup path (BACKUPDIR)
14
        [ -f /etc/automysqlbackup/automysqlbackup.conf ] && . /etc/automysqlbackup/automysqlbackup.conf
15
16
        count=$( find ${BACKUPDIR}/. -type f -name '*.bz2' -o -name '*.gz' -o -name '*.sql' -mtime 0 | wc -l )
17
 
18
        if [ $count -gt 0 ] ; then
19
            echo "OK: found $count table backup files for host - $DBHOST"
20
            STAT=$(expr $STAT + 0)
21
        else
22
            echo "ERROR: Latest MySQL backup for $DBHOST is older than 24 hours, please check!"
23
            STAT=$(expr $STAT + 2)
24
        fi
25
    done | sort
26
fi
27
28
if [ ${STAT} > 2 ] ; then
29
    exit 2
30
else
31
    exit 0
32
fi
33