Hi,
Check this one, no warranty whatsoever :)
El 09/11/15 a las 13:36, Mario Loderer escribió:
Hello,
we have the problem that we have really a lot of servers and clusters
at customer. So we get some backup mails every day/week/some day's,
:) depending on backupmodel. So it is very confused to check the
backups. Sending only on error is not really an solution.
The idea is to have an nice nagioscheck for this service. I'm not a
programmer therefore, I can not even write himself. So do you think it
is possible to write an nagios plugin to check the Backupstatus? With
the API or something else?
Thanks and best Regards
Mario
_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
--
Zuzendari Teknikoa / Director Técnico
Binovo IT Human Project, S.L.
Telf. 943575997
943493611
Astigarraga bidea 2, planta 6 dcha., ofi. 3-2; 20180 Oiartzun (Gipuzkoa)
www.binovo.es
#!/bin/sh
# (C) Copyright 2013 Binovo IT Human Project SL
# License: 3-clause BSD license
http://directory.fsf.org/wiki/License:BSD_3Clause
# Authors:
# - 2013 Xabier Acosta, original script
# - 2013/12 Eneko Lacunza, add second argument for backup oldness
# - 2014/09/29 Eneko Lacunza, fix VM name extraction for snapshot support
if [ -f /etc/default/locale ]
then
. /etc/default/locale
export LANG
fi
#Directorio de log vzdump
LOG=/var/log/vzdump
#directorio .conf de las Maquinas virtuales
VM_CFG=/etc/pve/qemu-server
OLDNESS=0
USAGE="Usage: `basename $0` [-h] [-n ] [-o <oldness>] \n
-h [Muestra esta ayuda.]\n
-n [Nombre de la máquina precedido por vzdump_. Ej: vzdump_maquina]\n
-o [Oldness. Indica la antigüedad aceptable del backup, en segundos. Por
defecto 0, debe ser del mismo día]\n"
while getopts o:n:h OPT;
do
case "$OPT" in
h)
echo $USAGE
exit 1
;;
n)
PARAM_NOMBRE_MAQUINA=$OPTARG
;;
o)
OLDNESS=$OPTARG
;;
\?)
echo $USAGE >&2
exit 1
;;
esac
done
for CFG_FILE in $VM_CFG/[0-9]*.conf
do
if [ -f $CFG_FILE ] && [ -f $LOG/qemu-$(basename $CFG_FILE | cut -d'.'
-f 1).log ]
then
ID_MAQUINA=$(basename $CFG_FILE | cut -d'.' -f 1)
NOMBRE_MAQUINA=$(cat $CFG_FILE | grep "name:" | awk '{ print $2
}' | head -n 1)
if [ vzdump_$NOMBRE_MAQUINA = $PARAM_NOMBRE_MAQUINA ]
then
#Finished
#1 Si ha terminado correctamente
#0 Si error/No ha terminado
#2 o más: Unknown
if [ $OLDNESS -eq 0 ]
then
FINISHED=$(cat $LOG/qemu-$ID_MAQUINA.log | grep
"$(date +%b) $(date +%d)" | grep "INFO: Finished" | wc -l)
FINISHED_DATE=$(cat $LOG/qemu-$ID_MAQUINA.log |
grep "INFO: Finished" | cut -c 1-6)
else
FINISHED_DATE=$(cat $LOG/qemu-$ID_MAQUINA.log |
grep "INFO: Finished" | cut -c 1-6 | sed s/ene/jan/ | sed s/abr/apr/ | sed
s/ago/aug/ | sed s/dic/dec/)
FINISHED_TS=$(date --date="$FINISHED_DATE" +%s)
NOW=$(date +%s)
FINISHED_OLDNESS=$(expr $NOW - $FINISHED_TS)
if [ $FINISHED_OLDNESS -le $OLDNESS ]
then
FINISHED=$(cat
$LOG/qemu-$ID_MAQUINA.log | grep "INFO: Finished" | wc -l)
else
FINISHED=0
fi
fi
#Error
#1 Si hay error
#0 Si no hay error/No ha terminado)
#2 o más: Unknown
ERROR=$(cat $LOG/qemu-$ID_MAQUINA.log | grep "$(date
+%b) $(date +%d)" | grep "ERROR: Backup of VM $ID_MAQUINA failed" | wc -l)
if [ $FINISHED -eq 1 ] && [ $ERROR -eq 0 ]
then
STATUS=0
SIZE=$(cat $LOG/qemu-$ID_MAQUINA.log | grep
"archive file size" | awk '{ print $8 }')
TOTAL_TIME=$(cat $LOG/qemu-$ID_MAQUINA.log |
grep "INFO: Finished" | awk '{ print $10 }')
MESSAGE="OK: $TOTAL_TIME Size: $SIZE Date:
$FINISHED_DATE"
elif [ $FINISHED -eq 0 ] && [ $ERROR -eq 1 ]
then
STATUS=2
MESSAGE="CRITICAL: Backup failed"
else
STATUS=1
FINISHED=$(cat $LOG/qemu-$ID_MAQUINA.log | grep
"INFO: Finished")
ERROR=$(cat $LOG/qemu-$ID_MAQUINA.log | grep
"ERROR: Backup of VM $ID_MAQUINA failed")
MESSAGE="WARNING: Last log: $FINISHED $ERROR"
fi
if [ $HOST ]
then
echo $MESSAGE
exit $STATUS
else
echo $MESSAGE
exit $STATUS
fi
else
continue
fi
fi
done
echo "WARNING: Backup status unknown. No log/machine found."
exit 1
_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel