Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions plugins/check_nagios_latency
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ function print_help() {
}

function test_integer() {
LABEL=$1
LABEL=$1
VALUE=$2

if ! echo $VALUE | grep -qE '^[0-9]+(\.[0-9]+)?$' ; then
OUTPUT="$LABEL has no integer value ($VALUE)! Please correct this parameter"
EXITCODE=3
fi

}

#defaults
EXITCODE=0
WARNING=120 # Warning at 2 minutes
CRITICAL=180 # Critical at 3 minutes

if [ ! -x $NAGIOSTATS ]; then
OUTPUT="Please correct path to nagiostats ($NAGIOSTATS)"
if [ ! -x $NAGIOSSTATS ]; then
OUTPUT="Please correct path to nagiostats ($NAGIOSSTATS)"
EXITCODE=3
fi

Expand All @@ -60,7 +60,7 @@ test_integer "-c" $CRITICAL
test_integer "-w" $WARNING

if [ $EXITCODE -eq 0 ]; then
LATENCY=`$NAGIOSTATS | awk '/Active Service Latency/ {print $8}' `
LATENCY=`$NAGIOSSTATS | awk '/Active Service Latency/ {print $8}' `
LATENCY_INT=`echo $LATENCY | cut -f1 -d"." `
if [ $LATENCY_INT -ge $CRITICAL ]; then
OUTPUT="CRITICAL: Latency at $LATENCY seconds! | latency=$LATENCY;$WARNING;$CRITICAL"
Expand All @@ -70,9 +70,8 @@ if [ $EXITCODE -eq 0 ]; then
EXITCODE=1
else
OUTPUT="OK: Latency at $LATENCY seconds. | latency=$LATENCY;$WARNING;$CRITICAL"
fi fi
fi fi
fi

echo $OUTPUT
exit $EXITCODE