2 optimizations:
- got rid of unnecessary read commands to set variables - de-duplicate the list of nameservers to check before checking
This commit is contained in:
@@ -56,8 +56,8 @@ NAGIOS_RESULT=0
|
||||
NAGIOS_DETAILS=
|
||||
|
||||
for DNS_ZONE in $DNS_ZONES; do
|
||||
read AUTH_NAMESERVER <<<$(host -t soa $DNS_ZONE ${DNS_SERVERS// .*/} | tail -1 | cut -d\ -f5 | sed "s/.$//")
|
||||
[ -n "$AUTH_NAMESERVER" ] && read AUTH_SOA_SERIAL <<<$(host -t soa $DNS_ZONE $AUTH_NAMESERVER | tail -1 | cut -d\ -f7)
|
||||
AUTH_NAMESERVER=$(host -t soa $DNS_ZONE ${DNS_SERVERS// .*/} | tail -1 | cut -d\ -f5 | sed "s/.$//")
|
||||
[ -n "$AUTH_NAMESERVER" ] && AUTH_SOA_SERIAL=$(host -t soa $DNS_ZONE $AUTH_NAMESERVER | tail -1 | cut -d\ -f7)
|
||||
if [ -z "$AUTH_SOA_SERIAL" ]; then
|
||||
NAGIOS_STATE=CRITICAL
|
||||
NAGIOS_RESULT=2
|
||||
@@ -71,6 +71,7 @@ for DNS_ZONE in $DNS_ZONES; do
|
||||
if [ -z "$DNS_SERVERS" -o "$DNS_SERVER_LOOKUP" == '-n' -o "$DNS_SERVERS" == "$AUTH_NAMESERVER" ]; then
|
||||
NAMESERVERS="$NAMESERVERS $(host -t ns $DNS_ZONE $AUTH_NAMESERVER | fgrep -v : | sed "s/.* //;s/\.$//")"
|
||||
fi
|
||||
NAMESERVERS=$(echo $NAMESERVERS | tr ' ' '\n' | sort -u)
|
||||
for NAMESERVER in $NAMESERVERS; do
|
||||
if [ "$NAMESERVER" != "$AUTH_NAMESERVER" ]; then
|
||||
SOA_SERIAL=$(host -t soa $DNS_ZONE $NAMESERVER | tail -1 | cut -d\ -f 7)
|
||||
|
||||
Reference in New Issue
Block a user