[ SEA-GHOST MINI SHELL]
#!/bin/bash
# /usr/lib/check_mk_agent/local/mysql_backup
#
file="/etc/bareos/check_mk/mysql-last-backup"
if [ ! -f "$file" ]
then
echo "ERROR: mysql-last-backup stats file not found"
exit 0
fi
if [ ! -s "$file" ]
then
echo "ERROR: size of mysql-last-backup stats file = 0 bytes"
exit 0
fi
vars=$(sudo cat $file)
db_backup=$(echo $vars | awk '{print $1}')
db_total=$(echo $vars | awk '{print $2}')
warn=$(($db_total - 9))
crit=$(expr $db_total \* 9 / 10)
if [[ $db_backup -lt $crit ]]
then
echo "ERROR: Only $db_backup db backed up from $db_total db."
elif [[ $db_backup -lt $warn ]]
then
echo "WARNING: Only $db_backup db backed up from $db_total db."
elif [[ $db_backup -lt $db_total ]]
then
echo "WARNING: Only $db_backup db backed up from $db_total db."
elif [[ $db_backup -eq $db_total ]]
then
echo "OK: All $db_backup db backed up."
else
echo "INFO: Something goes wrong. db_backup=$db_backup; db_total=$db_total"
fi
SEA-GHOST - SHELL CODING BY SEA-GHOST