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=
|
NAGIOS_DETAILS=
|
||||||
|
|
||||||
for DNS_ZONE in $DNS_ZONES; do
|
for DNS_ZONE in $DNS_ZONES; do
|
||||||
read AUTH_NAMESERVER <<<$(host -t soa $DNS_ZONE ${DNS_SERVERS// .*/} | tail -1 | cut -d\ -f5 | sed "s/.$//")
|
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)
|
[ -n "$AUTH_NAMESERVER" ] && AUTH_SOA_SERIAL=$(host -t soa $DNS_ZONE $AUTH_NAMESERVER | tail -1 | cut -d\ -f7)
|
||||||
if [ -z "$AUTH_SOA_SERIAL" ]; then
|
if [ -z "$AUTH_SOA_SERIAL" ]; then
|
||||||
NAGIOS_STATE=CRITICAL
|
NAGIOS_STATE=CRITICAL
|
||||||
NAGIOS_RESULT=2
|
NAGIOS_RESULT=2
|
||||||
@@ -69,8 +69,9 @@ for DNS_ZONE in $DNS_ZONES; do
|
|||||||
NAMESERVER_EMPTY=
|
NAMESERVER_EMPTY=
|
||||||
NAMESERVERS=$DNS_SERVERS
|
NAMESERVERS=$DNS_SERVERS
|
||||||
if [ -z "$DNS_SERVERS" -o "$DNS_SERVER_LOOKUP" == '-n' -o "$DNS_SERVERS" == "$AUTH_NAMESERVER" ]; then
|
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/\.$//")"
|
NAMESERVERS="$NAMESERVERS $(host -t ns $DNS_ZONE $AUTH_NAMESERVER | fgrep -v : | sed "s/.* //;s/\.$//")"
|
||||||
fi
|
fi
|
||||||
|
NAMESERVERS=$(echo $NAMESERVERS | tr ' ' '\n' | sort -u)
|
||||||
for NAMESERVER in $NAMESERVERS; do
|
for NAMESERVER in $NAMESERVERS; do
|
||||||
if [ "$NAMESERVER" != "$AUTH_NAMESERVER" ]; then
|
if [ "$NAMESERVER" != "$AUTH_NAMESERVER" ]; then
|
||||||
SOA_SERIAL=$(host -t soa $DNS_ZONE $NAMESERVER | tail -1 | cut -d\ -f 7)
|
SOA_SERIAL=$(host -t soa $DNS_ZONE $NAMESERVER | tail -1 | cut -d\ -f 7)
|
||||||
|
|||||||
Reference in New Issue
Block a user