Hi ,
I am trying to make a script which can count the errors in the log each time it scans. When ever it scans & counts the errors, it should do the comparison with the last count.
If the number is > than last time, you have errors.
If the number is < last time, ignore (new log file).
If the number is = last time, no change.
&
If errors <= 5 then WARN
If errors > 5 then ERROR
I have prepared the below given script ,,,but some how it is not working .
Kindly guide me , what is wrong with this script.
#!/bin/sh
tail -f sample_file.log > a.log
fCOUNT = grep ERROR a.log | wc -l
while (1)
do
iCOUNT= grep ERROR a.log | wc -l
COUNT=$(($fCOUNT -$iCOUNT))
if ($COUNT -eq 0) then
exit(1)
elif ($COUNT -le 5 ) then
echo "WARNING"
elif ($COUNT -gt 5) then
echo "ALERT"
fi
sleep 10
done
Regards