#!/bin/bash
# This check can be used to test the name resolution of a given host
# address using the local resolver of the system this script is
# running on.

HOSTADDRESS=mathias-kettner.de

OUTPUT=$(nslookup $HOSTADDRESS 2>&1)
RC=$?
if [ $RC -ne 0 ]; then
    STATE=2
    OUTPUT="CRIT - $HOSTADDRESS could not be resolved"
else
    STATE=0
    ADDRESSES=$(echo "$OUTPUT" | tail -n+3 | grep Address: | cut -d" " -f2)
    OUTPUT="OK - $HOSTADDRESS resolved to ${ADDRESSES//$'\n'/, }"
fi

echo "<<<mrpe>>>"
echo "Resolve_$HOSTADDRESS $STATE $OUTPUT"
