nagios/glue_records: standalone + warn if no IP
This commit is contained in:
parent
90a94aa61a
commit
8e37cb2478
1 changed files with 24 additions and 12 deletions
|
@ -8,22 +8,29 @@
|
|||
# Stop at the first non-catched error
|
||||
set -e
|
||||
|
||||
# Output
|
||||
OUTPUT_EXIT_STATUS=0
|
||||
OUTPUT_DETAIL_OK=""
|
||||
OUTPUT_DETAIL_WARNING=""
|
||||
OUTPUT_DETAIL_CRITICAL=""
|
||||
#OUTPUT_PERFDATA=""
|
||||
|
||||
# Defaults
|
||||
CHECK_SOA=1
|
||||
|
||||
# For monitoring plugins
|
||||
PROGPATH=$( echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,' )
|
||||
REVISION="0.1"
|
||||
|
||||
# Include check_range()
|
||||
. $PROGPATH/utils.sh
|
||||
#. $PROGPATH/utils.sh
|
||||
# No need for check_range() at the moment, we just copy
|
||||
# the states to be standalone (easier to use that way)
|
||||
STATE_OK=0
|
||||
STATE_WARNING=1
|
||||
STATE_CRITICAL=2
|
||||
STATE_UNKNOWN=3
|
||||
STATE_DEPENDENT=4
|
||||
|
||||
# Defaults
|
||||
CHECK_SOA=1
|
||||
|
||||
# Output
|
||||
OUTPUT_EXIT_STATUS=$STATE_OK
|
||||
OUTPUT_DETAIL_OK=""
|
||||
OUTPUT_DETAIL_WARNING=""
|
||||
OUTPUT_DETAIL_CRITICAL=""
|
||||
#OUTPUT_PERFDATA=""
|
||||
|
||||
#
|
||||
# Help function
|
||||
|
@ -88,6 +95,11 @@ while [ "$#" -gt 0 ]; do
|
|||
# Query this TLD server on our domain and loop on each IP address "additionally"
|
||||
# given, aka. the glue records
|
||||
LIST_IP_NS_SERVERS="$( dig +norec +nocomments +noquestion +nostats +nocmd @"$NS_TLD" "$DOMAIN" NS | sed -n 's/.*IN[[:space:]]\+\(A\|AAAA\)[[:space:]]\+\(.*\)$/\2/p' )"
|
||||
if [ -z "$LIST_IP_NS_SERVERS" ] && [ "$OUTPUT_EXIT_STATUS" -ne "$STATE_CRITICAL" ]; then
|
||||
OUTPUT_EXIT_STATUS=$STATE_WARNING
|
||||
OUTPUT_DETAIL_WARNING="$OUTPUT_DETAIL_WARNING No glue records for domain $DOMAIN ?"
|
||||
continue
|
||||
fi
|
||||
for IPADDR in $LIST_IP_NS_SERVERS; do
|
||||
# Query our server
|
||||
OUTPUT=$( dig @"$IPADDR" $DOMAIN SOA +short 2>&1 )
|
||||
|
@ -107,7 +119,7 @@ while [ "$#" -gt 0 ]; do
|
|||
# Check that SOA records are all the same
|
||||
if [ "$CHECK_SOA" -ne 0 ] && [ "$OUTPUT_EXIT_STATUS" -ne "$STATE_CRITICAL" ] && [ "$( echo "$LIST_SOA" | uniq | wc -l )" -ne 1 ]; then
|
||||
OUTPUT_EXIT_STATUS=$STATE_WARNING
|
||||
OUTPUT_DETAIL_WARNING="SOA records discrepancies for domain $DOMAIN : $LIST_SOA"
|
||||
OUTPUT_DETAIL_WARNING="$OUTPUT_DETAIL_WARNING SOA records discrepancies for domain $DOMAIN : $LIST_SOA"
|
||||
fi
|
||||
|
||||
# Clean up after each domain
|
||||
|
|
Loading…
Reference in a new issue