Commit bbad51d9ca931dafbead8e6c12f7946ebbb6615a
1 parent
dadb9bb1
2 optimizations:
- got rid of unnecessary read commands to set variables - de-duplicate the list of nameservers to check before checking
Showing
1 changed file
with
4 additions
and
3 deletions
plugins/check_dns_replication
... | ... | @@ -56,8 +56,8 @@ NAGIOS_RESULT=0 |
56 | 56 | NAGIOS_DETAILS= |
57 | 57 | |
58 | 58 | for DNS_ZONE in $DNS_ZONES; do |
59 | - read AUTH_NAMESERVER <<<$(host -t soa $DNS_ZONE ${DNS_SERVERS// .*/} | tail -1 | cut -d\ -f5 | sed "s/.$//") | |
60 | - [ -n "$AUTH_NAMESERVER" ] && read AUTH_SOA_SERIAL <<<$(host -t soa $DNS_ZONE $AUTH_NAMESERVER | tail -1 | cut -d\ -f7) | |
59 | + AUTH_NAMESERVER=$(host -t soa $DNS_ZONE ${DNS_SERVERS// .*/} | tail -1 | cut -d\ -f5 | sed "s/.$//") | |
60 | + [ -n "$AUTH_NAMESERVER" ] && AUTH_SOA_SERIAL=$(host -t soa $DNS_ZONE $AUTH_NAMESERVER | tail -1 | cut -d\ -f7) | |
61 | 61 | if [ -z "$AUTH_SOA_SERIAL" ]; then |
62 | 62 | NAGIOS_STATE=CRITICAL |
63 | 63 | NAGIOS_RESULT=2 |
... | ... | @@ -69,8 +69,9 @@ for DNS_ZONE in $DNS_ZONES; do |
69 | 69 | NAMESERVER_EMPTY= |
70 | 70 | NAMESERVERS=$DNS_SERVERS |
71 | 71 | if [ -z "$DNS_SERVERS" -o "$DNS_SERVER_LOOKUP" == '-n' -o "$DNS_SERVERS" == "$AUTH_NAMESERVER" ]; then |
72 | - NAMESERVERS="$NAMESERVERS $(host -t ns $DNS_ZONE $AUTH_NAMESERVER | fgrep -v : | sed "s/.* //;s/\.$//")" | |
72 | + NAMESERVERS="$NAMESERVERS $(host -t ns $DNS_ZONE $AUTH_NAMESERVER | fgrep -v : | sed "s/.* //;s/\.$//")" | |
73 | 73 | fi |
74 | + NAMESERVERS=$(echo $NAMESERVERS | tr ' ' '\n' | sort -u) | |
74 | 75 | for NAMESERVER in $NAMESERVERS; do |
75 | 76 | if [ "$NAMESERVER" != "$AUTH_NAMESERVER" ]; then |
76 | 77 | SOA_SERIAL=$(host -t soa $DNS_ZONE $NAMESERVER | tail -1 | cut -d\ -f 7) |
... | ... |