|
|
|
|
@ -16,6 +16,7 @@ host=""
|
|
|
|
|
service=""
|
|
|
|
|
state=""
|
|
|
|
|
severity=""
|
|
|
|
|
raw=""
|
|
|
|
|
num=""
|
|
|
|
|
# These two need to be regexp wildcards to match everything when nothing is specified
|
|
|
|
|
aSource="(HOST|SERVICE)"
|
|
|
|
|
@ -49,6 +50,7 @@ Usage:
|
|
|
|
|
--notime don't convert timestamp to human time
|
|
|
|
|
-c|--constant) the equivalent of a tail -f on the Nagios log file
|
|
|
|
|
--file <file[s]>) scan <file[s]> instead of $files; use "..." if wildcards
|
|
|
|
|
--raw Just print the raw file but convert time stamps to human readable form
|
|
|
|
|
-v turn on verbose/debug mode
|
|
|
|
|
|
|
|
|
|
All input is evaluated as a case-insensitive regexp surrounded by wildcards.
|
|
|
|
|
@ -80,6 +82,7 @@ while [ -n "$1" ]; do
|
|
|
|
|
--crit|--critical) state="CRITICAL"; shift 1;;
|
|
|
|
|
--hard) severity="HARD"; shift 1;;
|
|
|
|
|
--soft) severity="SOFT"; shift 1;;
|
|
|
|
|
--raw) raw="true"; shift 1;;
|
|
|
|
|
--sev|--severity) severity="$2"; shift 2;;
|
|
|
|
|
-Q) severity="HARD"; state="CRITICAL"; shift 1;;
|
|
|
|
|
-n|--num) num="$2"; shift 2;;
|
|
|
|
|
@ -116,9 +119,11 @@ fi
|
|
|
|
|
timeSub=""
|
|
|
|
|
[ -z "$noTime" ] && timeSub="&& sub (/^\[[0-9]{10}]/, strftime (\"%Y-%m-%d %H:%M:%S\", substr (\$1, 2, 10)), \$1)"
|
|
|
|
|
|
|
|
|
|
awkString="/^\[[0-9]{10}] (GLOBAL |CURRENT )?$aSource (DOWNTIME |FLAPPING )?$aType: .*$host.*$service/"
|
|
|
|
|
[ -n "$raw" ] && awkString="/./"
|
|
|
|
|
do_debug "host=$host"
|
|
|
|
|
do_debug "service=$service"
|
|
|
|
|
do_debug "awk=^\[[0-9]{10}] (GLOBAL |CURRENT )?$aSource (DOWNTIME |FLAPPING )?$aType: .*$host.*$service"
|
|
|
|
|
do_debug "awk=$awkString"
|
|
|
|
|
do_debug "state=$state"
|
|
|
|
|
do_debug "severity=$severity"
|
|
|
|
|
do_debug "num=$num"
|
|
|
|
|
@ -128,9 +133,18 @@ do_debug "num=$num"
|
|
|
|
|
# $(NF-2) = HARD/SOFT
|
|
|
|
|
# $(NF-3) = UP/DOWN/UNREACHABLE/OK/WARNING/CRITICAL/etc
|
|
|
|
|
|
|
|
|
|
if [ -n "$raw" ]; then
|
|
|
|
|
tail -n +1 $tailMode $files | gawk -F\; "\
|
|
|
|
|
$awkString \
|
|
|
|
|
$timeSel \
|
|
|
|
|
$timeSub \
|
|
|
|
|
{
|
|
|
|
|
print
|
|
|
|
|
}"
|
|
|
|
|
else
|
|
|
|
|
tail -n +1 $tailMode $files | gawk -F\; "\
|
|
|
|
|
BEGIN {IGNORECASE=1} \
|
|
|
|
|
/^\[[0-9]{10}] (GLOBAL |CURRENT )?$aSource (DOWNTIME |FLAPPING )?$aType: .*$host.*$service/ \
|
|
|
|
|
$awkString \
|
|
|
|
|
&& \$(NF-3)~/$state/ \
|
|
|
|
|
&& \$(NF-2)~/$severity/ \
|
|
|
|
|
&& \$(NF-1)~/$num/ \
|
|
|
|
|
@ -147,3 +161,4 @@ tail -n +1 $tailMode $files | gawk -F\; "\
|
|
|
|
|
sub(/SOFT/, \"\x1b[36mSOFT\x1b[0m\", \$(NF-2))
|
|
|
|
|
printf \"%s: %s;%s;%s;%s;%s\n\", \$1, \$2, \$3, \$4, \$5, \$6
|
|
|
|
|
}"
|
|
|
|
|
fi
|
|
|
|
|
|