You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.1 KiB
Bash
35 lines
1.1 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Wrapper around the NRPE script "check_prtdiag" to interpret correct status
|
|
#
|
|
|
|
plugins=/usr/local/monitoring/nagios/libexec
|
|
port=9666
|
|
timeout=90
|
|
|
|
if [[ "$#" -ne "1" ]]; then echo "Usage: check_nrpe_prtdiag_wrapper <hostname>"; exit 3; fi
|
|
|
|
host=$1
|
|
|
|
output=`${plugins}/check_nrpe -p $port -t $timeout -H $host -c check_prtdiag 2>&1`
|
|
|
|
if echo $output | grep -q "^OK"; then # OK/recovery alert
|
|
stat=0; text_stat=OK
|
|
elif echo $output | grep -q "status is '\(failed\|faulty\)'"; then # failed/faulty = CRITICAL
|
|
stat=2; text_stat=CRITICAL
|
|
elif echo $output | grep -q "status is"; then # "status is" which is not CRITICAL is a WARNING
|
|
stat=1; text_stat=WARNING
|
|
else # Everything else is UNKNOWN
|
|
stat=3; text_stat=UNKNOWN
|
|
fi
|
|
|
|
# Final output w/o the original text status
|
|
text_out=`echo $output | sed -n 's/^[^\-]\+\(.*\)/'$text_stat' \1/p'`
|
|
|
|
# Just a precaution... if the original text status didn't have "^\(OK\|WARNING\|CRITICAL\|UNKNOWN\) -", then simply use the original
|
|
if [[ -z "$text_out" ]]; then text_out="$output"; fi
|
|
|
|
echo $text_out
|
|
|
|
exit $stat
|