| 1 | #!/bin/bash
|
|---|
| 2 | #
|
|---|
| 3 | # This script checks, if there are WARNs or ERRORs in the processlog of
|
|---|
| 4 | # the last night and sends them to the emailadresse(s) in $erradr
|
|---|
| 5 | #
|
|---|
| 6 |
|
|---|
| 7 | source `dirname $0`/../Sourcefile.sh
|
|---|
| 8 | printprocesslog "INFO starting $0 $1"
|
|---|
| 9 |
|
|---|
| 10 | if ! [ "$1" = "day" ] && ! [ "$1" = "hour" ]
|
|---|
| 11 | then
|
|---|
| 12 | #echo "wrong option "$1" (only min and nights valid)."
|
|---|
| 13 | echo "wrong option "$1" (only day and hour valid)."
|
|---|
| 14 | finish
|
|---|
| 15 | fi
|
|---|
| 16 |
|
|---|
| 17 | # check for connection problems or full disks every hour
|
|---|
| 18 | if [ "$1" = "hour" ]
|
|---|
| 19 | then
|
|---|
| 20 | lastdate=`date +'%F %H' --date="-1hour"`
|
|---|
| 21 | processlogfile=$processlogpath/process`date +%F --date="-1hour"`.log
|
|---|
| 22 |
|
|---|
| 23 | if grep -E "^$lastdate.*DISK" $processlogfile >/dev/null
|
|---|
| 24 | then
|
|---|
| 25 | grep -E "^$lastdate.*DISK" $processlogfile | mail -s 'disk full ('$processlogfile')' $deladrs
|
|---|
| 26 | printprocesslog "INFO sent full-disk info to "$deladrs
|
|---|
| 27 | fi
|
|---|
| 28 |
|
|---|
| 29 | if grep -E "^$lastdate.*CONNECTION" $processlogfile >/dev/null
|
|---|
| 30 | then
|
|---|
| 31 | grep -E "^$lastdate.*CONNECTION" $processlogfile | mail -s 'found connection problems found ('$processlogfile')' $erradrs
|
|---|
| 32 | printprocesslog "INFO sent connection-problem info to "$erradrs
|
|---|
| 33 | fi
|
|---|
| 34 | fi
|
|---|
| 35 |
|
|---|
| 36 | # check for errors and warnings once a day
|
|---|
| 37 | if [ "$1" = "day" ]
|
|---|
| 38 | then
|
|---|
| 39 | lastdate=`date +'%F ' --date="-1hour"`
|
|---|
| 40 | processlogfile=$processlogpath/process`date +%F --date="-1hour"`.log
|
|---|
| 41 |
|
|---|
| 42 | if grep -E "^$lastdate.*WARN" $processlogfile >/dev/null
|
|---|
| 43 | then
|
|---|
| 44 | grep -E "^$lastdate.*WARN" $processlogfile | mail -s 'found warnings in '$processlogfile $erradrs
|
|---|
| 45 | printprocesslog "INFO sent warnings to "$erradrs
|
|---|
| 46 | fi
|
|---|
| 47 |
|
|---|
| 48 | if grep -E "^$lastdate.*ERROR" $processlogfile >/dev/null
|
|---|
| 49 | then
|
|---|
| 50 | grep -E "^$lastdate.*ERROR" $processlogfile | mail -s 'found errors in '$processlogfile $erradrs
|
|---|
| 51 | printprocesslog "INFO sent errors to "$erradrs
|
|---|
| 52 | fi
|
|---|
| 53 | fi
|
|---|
| 54 |
|
|---|
| 55 | printprocesslog "INFO finished $0 $1"
|
|---|
| 56 |
|
|---|