[monitoring-plugins] detect unreachable dns service in nslookup output ...

ghciv6 git at monitoring-plugins.org
Wed May 20 23:40:11 CEST 2020


 Module: monitoring-plugins
 Branch: master
 Commit: 905b09c38b6b8b08f0fe4a43b9b118366817bf0f
 Author: ghciv6 <ghciv6 at localhost>
   Date: Wed May 20 23:02:42 2020 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=905b09c

detect unreachable dns service in nslookup output (from bind-utils-9.8.2)
prevent core if error_scan detects an error in a line without ':'

---

 plugins/check_dns.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index d4d0b88..b90f50e 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -202,7 +202,10 @@ main (int argc, char **argv)
     if (error_scan (chld_err.line[i]) != STATE_OK) {
       result = max_state (result, error_scan (chld_err.line[i]));
       msg = strchr(input_buffer, ':');
-      if(msg) msg++;
+      if(msg)
+         msg++;
+      else
+         msg = input_buffer;
     }
   }
 
@@ -348,6 +351,8 @@ error_scan (char *input_buffer)
   /* DNS server is not running... */
   else if (strstr (input_buffer, "No response from server"))
     die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
+  else if (strstr (input_buffer, "no servers could be reached"))
+    die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
 
   /* Host name is valid, but server doesn't have records... */
   else if (strstr (input_buffer, "No records"))



More information about the Commits mailing list