X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=blobdiff_plain;f=automate-default.sh;h=d691c6651ad33b6a52ef76cb7e0693759851a99e;hp=a51144a2afbe719e57dbee5afca7c44814b768bd;hb=HEAD;hpb=19364119e73cf16f5e489703443bc3d8ce9dfd95 diff --git a/automate-default.sh b/automate-default.sh index a51144a..d691c66 100755 --- a/automate-default.sh +++ b/automate-default.sh @@ -11,12 +11,23 @@ set -e DATE=`date +%Y-%m-%d-%T` MONITOR_PID="${MONITOR_SCRIPT_ROOT}/SKIP" +function send_mail () +{ + subject=$1 + body=$2 + mail -s "$subject" $exception_email < /var/lib/monitor/comon/$DATE.comon.csv || : +#${MONITOR_SCRIPT_ROOT}/statistics/add-google-record.py --email email --password password --database MonitorStats --sheet NodeHistory `${MONITOR_SCRIPT_ROOT}/statistics/get-records.py nodes` +#${MONITOR_SCRIPT_ROOT}/statistics/add-google-record.py --email email --password password --database MonitorStats --sheet SiteHistory `${MONITOR_SCRIPT_ROOT}/statistics/get-records.py sites` + cp ${MONITOR_SCRIPT_ROOT}/monitor.log ${MONITOR_ARCHIVE_ROOT}/`date +%F-%H:%M`.monitor.log service plc restart monitor || : rm -f $MONITOR_PID + +D=`date +%F-%H:%M` + +# NOTE: check log for major sections. +wc=`grep -E "^(findbad|findbadpcu|nodebad|pcubad|sitebad|apply-policy)$" ${MONITOR_SCRIPT_ROOT}/monitor.log | wc -l` +if [[ $wc -ge 6 ]] ; then + send_mail "A:finished monitor run for $SD at $D" "Thank you..." +else + send_mail "ERROR finished monitor run for $SD at $D" "Missing some sections: + $(grep -E "findbad|findbadpcu|nodebad|pcubad|sitebad|apply-policy" ${MONITOR_SCRIPT_ROOT}/monitor.log)" +fi +