[Nagiosplug-devel] check_dns: DNS WARNING - nslookup returned error status

Emanuele Cisbani cisbani at perlafinanza.it
Thu Nov 24 09:44:05 CET 2005


Hi 				



I dont know why, but the following bash script work fine.

May be the problem is elsewere?



- Emanuele Cisbani (cisba)



#!/bin/bash



# Standard Nagios Status codes

STATE_OK=0

STATE_WARNING=1

STATE_CRITICAL=2

STATE_UNKNOWN=3



filename="/tmp/check_dns_$$.tmp"

result=''

stato='UNKNOWN'

code=3



dig @"$2" "$1" > $filename 2>&1

#head $filename

num_of_answer=$(cat $filename \

        | grep ANSWER: \

        | awk 'BEGIN{FS=","}{print $2}' \

        | awk 'BEGIN{FS=":"}{print $2}' )



if  grep 'ANSWER:' $filename >'/dev/null' ; then

        result=$num_of_answer

        if [ $result -gt 0 ] ; then

                stato="OK"

                code=0

        elif [ $result -eq 0 ]; then

                stato="WARNING: $(cat $filename)"

                code=1

        fi

elif  grep "connection timed out" >'/dev/null' $filename  ; then

        stato="CRITICAL: $(cat $filename)"

        code=2

elif  grep "Couldn't find server" >'/dev/null' $filename  ; then

        stato="CRITICAL: $(cat $filename)"

        code=2

fi



rm $filename

echo $stato

exit $code









-----------------------

This thread is located in the archive at this URL:

http://www.nagiosexchange.org/nagiosplug-devel.31.0.html?&tx_maillisttofa
q_pi1[showUid]=10253

					




More information about the Devel mailing list