diff options
author | Jan Wagner <waja@cyconet.org> | 2013-09-29 02:23:11 +0200 |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2014-07-30 13:16:37 +0200 |
commit | d0da78ced184197b29af9fe910aaf56a9e7fe762 (patch) | |
tree | 2db08436512d4c8c2b46f1b7854ded83a5fbd55a | |
parent | d8c20cc487f4dc361af553c57b8b4f8a4ab1dd29 (diff) | |
download | monitoring-plugins-d0da78ced184197b29af9fe910aaf56a9e7fe762.tar.gz |
check_dns: returns incorrect state when specifying server
This patch verifies if the response is returned by the dns server we
are trying to check
---
Closes #981
Closes #982
Closes #1164
-rw-r--r-- | plugins/check_dns.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 31a953d7..da90da75 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -136,6 +136,28 @@ main (int argc, char **argv) } } + /* bug ID: 2946553 - Older versions of bind will use all available dns + servers, we have to match the one specified */ + if (strstr (chld_out.line[i], "Server:") && strlen(dns_server) > 0) { + temp_buffer = index (chld_out.line[i], ':'); + temp_buffer++; + + /* Strip leading tabs */ + for (; *temp_buffer != '\0' && *temp_buffer == '\t'; temp_buffer++) + /* NOOP */; + + strip(temp_buffer); + if (temp_buffer==NULL || strlen(temp_buffer)==0) { + die (STATE_CRITICAL, + _("DNS CRITICAL - '%s' returned empty server string\n"), + NSLOOKUP_COMMAND); + } + + if (strcmp(temp_buffer, dns_server) != 0) { + die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server); + } + } + /* the server is responding, we just got the host name... */ if (strstr (chld_out.line[i], "Name:")) parse_address = TRUE; |