source: trunk/DataCheck/Monitoring/CheckLogs.sh@ 18766

Last change on this file since 18766 was 18702, checked in by Daniela Dorner, 8 years ago
check for errors and warnings only once per day but for connection problems or full disk every hour
  • Property svn:executable set to *
File size: 1.8 KB
Line 
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
7source `dirname $0`/../Sourcefile.sh
8printprocesslog "INFO starting $0 $1"
9
10if ! [ "$1" = "day" ] && ! [ "$1" = "hour" ]
11then
12 #echo "wrong option "$1" (only min and nights valid)."
13 echo "wrong option "$1" (only day and hour valid)."
14 finish
15fi
16
17# check for connection problems or full disks every hour
18if [ "$1" = "hour" ]
19then
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
34fi
35
36# check for errors and warnings once a day
37if [ "$1" = "day" ]
38then
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
53fi
54
55printprocesslog "INFO finished $0 $1"
56
Note: See TracBrowser for help on using the repository browser.