|
@@ -214,8 +214,12 @@ fi
|
|
|
|
|
|
|
|
diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
|
|
diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
|
|
|
|
|
|
|
|
-# Count the number of matching log entries we have
|
|
|
|
|
-count=$(egrep -c "$query" "$tempdiff")
|
|
|
|
|
|
|
+# Count the number of matching log entries we have and handle errors when grep fails
|
|
|
|
|
+count=$(grep -c "$query" "$tempdiff" 2>&1)
|
|
|
|
|
+if [[ $? -gt 1 ]];then
|
|
|
|
|
+ echo "Log check error: $count"
|
|
|
|
|
+ exit "$STATE_UNKNOWN"
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
# Get the last matching entry in the diff file
|
|
# Get the last matching entry in the diff file
|
|
|
lastentry=$(egrep "$query" "$tempdiff" | tail -1)
|
|
lastentry=$(egrep "$query" "$tempdiff" | tail -1)
|