added reportsuccess and reportwarning config options.

This commit is contained in:
Elijah Saxon 2004-12-17 00:28:53 +00:00
parent 9f6af22a4c
commit 2738718518
2 changed files with 28 additions and 8 deletions

View File

@ -192,6 +192,8 @@ setfile $CONFFILE
# get global config options (second param is the default) # get global config options (second param is the default)
getconf configdirectory /etc/backup.d getconf configdirectory /etc/backup.d
getconf reportemail getconf reportemail
getconf reportsuccess yes
getconf reportwarning yes
getconf loglevel 3 getconf loglevel 3
getconf logfile /var/log/backupninja.log getconf logfile /var/log/backupninja.log
getconf SLAPCAT /usr/sbin/slapcat getconf SLAPCAT /usr/sbin/slapcat
@ -212,6 +214,8 @@ debug 1 "====== starting at "`date`" ======"
umask 077 umask 077
for file in $configdirectory/*; do for file in $configdirectory/*; do
[ -f $file ] || continue;
perms=`ls -ld $file` perms=`ls -ld $file`
perms=${perms:4:6} perms=${perms:4:6}
if [ "$perms" != "------" ]; then if [ "$perms" != "------" ]; then
@ -238,10 +242,10 @@ for file in $configdirectory/*; do
errors=`echo $ret | grep -e "^Error: \|^Fatal: " | wc -l` errors=`echo $ret | grep -e "^Error: \|^Fatal: " | wc -l`
if [ $errors != 0 ]; then if [ $errors != 0 ]; then
msg "*failed* -- $file" msg "*failed* -- $file"
error="$error\n== errors from $file ==\n\n$ret\n" errormsg="$error\n== errors from $file ==\n\n$ret\n"
elif [ $warnings != 0 ]; then elif [ $warnings != 0 ]; then
msg "*warning* -- $file" msg "*warning* -- $file"
error="$error\n== warnings from $file ==\n\n$ret\n" errormsg="$error\n== warnings from $file ==\n\n$ret\n"
elif [ $retcode == 0 ]; then elif [ $retcode == 0 ]; then
msg "success -- $file" msg "success -- $file"
else else
@ -256,13 +260,20 @@ done
## mail the messages to the report address ## mail the messages to the report address
if [ "$reportemail" != "" ]; then if [ "$reportemail" == "" ]; then doit=0
elif [ $errors != 0 ]; then doit=1
elif [ "$reportsuccess" == "yes" ]; then doit=1
elif [ "$reportwarning" == "yes" -a $warnings != 0 ]; then doit=1
else doit=0
fi
if [ $doit == 1 ]; then
hostname=`hostname` hostname=`hostname`
{ {
for ((i=0; i < ${#messages[@]} ; i++)); do for ((i=0; i < ${#messages[@]} ; i++)); do
echo ${messages[$i]} echo ${messages[$i]}
done done
echo -e "$error" echo -e "$errormsg"
} | mail $reportemail -s "backupninja: $hostname" } | mail $reportemail -s "backupninja: $hostname"
fi fi

View File

@ -6,15 +6,24 @@
# #
# how verbose to make the logs # how verbose to make the logs
# 5 -- Debugging messages (and below) # 5 -- Debugging messages (and below)
# 4 -- Informational messages (and below) # 4 -- Informational messages (and below)
# 3 -- Warnings (and below) # 3 -- Warnings (and below)
# 2 -- Errors (and below) # 2 -- Errors (and below)
# 1 -- Fatal errors (only) # 1 -- Fatal errors (only)
loglevel = 4 loglevel = 4
# send a summary of backup status to this email address # send a summary of the backup status to
# reportemail = root # this email address:
reportemail = root
# if set to 'yes', a report email will be generated
# even if all modules reported success. (default = yes)
reportsuccess = yes
# if set to 'yes', a report email will be generated
# even if there was no error. (default = yes)
reportwarning = yes
####################################################### #######################################################
# for most installations, the defaults below are good # # for most installations, the defaults below are good #