Last active
August 29, 2015 14:02
-
-
Save furu-nob/5d82339507cb0a3bc104 to your computer and use it in GitHub Desktop.
dns_check_existence.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Version 140624_1534 | |
NAGIOS_CHECK_DNS_COMMAND='/usr/local/nagios/libexec/check_dns' | |
HOSTNAME=$1 | |
EXITSTATUS='1' # Defaults | |
function usage { | |
cat <<-EOF | |
$(basename ${0}) is check HOSTMANE and IPAddress on DNS server. | |
Usage: $(basename ${0}) HOSTMANE | |
EOF | |
} | |
if [ $# -ne 1 ] | |
then | |
usage | |
exit 0 | |
else | |
RESULTS=$($NAGIOS_CHECK_DNS_COMMAND $HOSTNAME) | |
EXITSTATUS=$? | |
if [ $EXITSTATUS -ne 0 ] | |
then | |
#echo "$HOSTNAME|NoName" | |
echo "NoDNSName" | |
else | |
#echo -n "$HOSTNAME|" | |
#echo -n 'IPAddress:' | |
# $RESULTS ex : DNS OK: 0.017 seconds response time. www.example.jp returns 10.2.2.2|time=0.017038s;;;0.000000 | |
echo $RESULTS | cut -d"|" -f1 | sed -e "s/^.* //" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment