summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-xplugins-scripts/check_log.sh34
1 files changed, 32 insertions, 2 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
index 8a79704..6e9fbca 100755
--- a/plugins-scripts/check_log.sh
+++ b/plugins-scripts/check_log.sh
@@ -145,6 +145,22 @@ while test -n "$1"; do
145 exitstatus=$2 145 exitstatus=$2
146 shift 146 shift
147 ;; 147 ;;
148 --extended-regex)
149 ERE=1
150 shift
151 ;;
152 -e)
153 ERE=1
154 shift
155 ;;
156 --perl-regex)
157 PRE=1
158 shift
159 ;;
160 -p)
161 PRE=1
162 shift
163 ;;
148 *) 164 *)
149 echo "Unknown argument: $1" 165 echo "Unknown argument: $1"
150 print_usage 166 print_usage
@@ -154,6 +170,20 @@ while test -n "$1"; do
154 shift 170 shift
155done 171done
156 172
173# Parameter sanity check
174if [ $ERE ] && [ $PRE ] ; then
175 echo "Can not use extended and perl regex at the same time"
176 exit "$STATE_UNKNOWN"
177fi
178
179if [ $ERE ]; then
180 GREP="grep -E"
181fi
182
183if [ $PRE ]; then
184 GREP="grep -P"
185fi
186
157# If the source log file doesn't exist, exit 187# If the source log file doesn't exist, exit
158 188
159if [ ! -e "$logfile" ]; then 189if [ ! -e "$logfile" ]; then
@@ -190,10 +220,10 @@ fi
190diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff" 220diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
191 221
192# Count the number of matching log entries we have 222# Count the number of matching log entries we have
193count=$(grep -c "$query" "$tempdiff") 223count=$($GREP -c "$query" "$tempdiff")
194 224
195# Get the last matching entry in the diff file 225# Get the last matching entry in the diff file
196lastentry=$(grep "$query" "$tempdiff" | tail -1) 226lastentry=$($GREP "$query" "$tempdiff" | tail -1)
197 227
198rm -f "$tempdiff" 228rm -f "$tempdiff"
199cat "$logfile" > "$oldlog" 229cat "$logfile" > "$oldlog"