76 lines
1.2 KiB
Bash
Executable file
76 lines
1.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# Quick and dirty script around delv
|
|
|
|
# Stop on any uncaucht error
|
|
set -e
|
|
|
|
# Initialization
|
|
OUTPUT_EXIT_STATUS=0
|
|
OUTPUT_DETAIL_OK=""
|
|
OUTPUT_DETAIL_CRITICAL=""
|
|
LOGGER=""
|
|
|
|
#
|
|
# Help function
|
|
#
|
|
usage() {
|
|
cat <<EOF
|
|
Usage:
|
|
$0 -d example.net
|
|
$0 -h (this help output)
|
|
EOF
|
|
}
|
|
|
|
if ! which delv >/dev/null 2>&1; then
|
|
echo "UNKNOWN 'delv' not found."
|
|
exit 3
|
|
fi
|
|
|
|
if [ -z "$LOGGER" ] && which logger >/dev/null 2>&1; then
|
|
LOGGER="logger"
|
|
fi
|
|
|
|
#
|
|
# Gestion des paramètres
|
|
#
|
|
while getopts hd: f; do
|
|
case "$f" in
|
|
'h')
|
|
usage
|
|
exit
|
|
;;
|
|
|
|
'd')
|
|
OUTPUT="$( delv +vtrace "$OPTARG" soa 2>&1 )"
|
|
if ! echo "$OUTPUT" | grep "^; fully validated" >/dev/null 2>&1; then
|
|
[ -z "$LOGGER" ] || echo "$OUTPUT" | $LOGGER
|
|
OUTPUT_DETAIL_CRITICAL="$OUTPUT_DETAIL_CRITICAL $OPTARG"
|
|
OUTPUT_EXIT_STATUS=2
|
|
else
|
|
OUTPUT_DETAIL_OK="$OUTPUT_DETAIL_OK $OPTARG"
|
|
fi
|
|
;;
|
|
|
|
\?)
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
case "$OUTPUT_EXIT_STATUS" in
|
|
'0')
|
|
if [ -z "$OUTPUT_DETAIL_OK" ]; then
|
|
OUTPUT_DETAIL_OK=" (no domains tested)"
|
|
fi
|
|
printf "OK%s\n" "$OUTPUT_DETAIL_OK"
|
|
;;
|
|
|
|
'2')
|
|
printf "CRITICAL%s\n" "$OUTPUT_DETAIL_CRITICAL"
|
|
;;
|
|
esac
|
|
|
|
exit "$OUTPUT_EXIT_STATUS"
|