[Nagiosplug-checkins] nagiosplug/plugins check_dns.c,1.43,1.44

Matthew Kent mattkent at users.sourceforge.net
Thu Dec 9 21:58:01 CET 2004


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19915

Modified Files:
	check_dns.c 
Log Message:
Error catching improvements from Ollie Cook


Index: check_dns.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dns.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- check_dns.c	10 Dec 2004 00:20:23 -0000	1.43
+++ check_dns.c	10 Dec 2004 05:57:33 -0000	1.44
@@ -150,6 +150,10 @@
 
 	/* scan stderr */
 	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
+
+		if (verbose)
+			printf ("%s", input_buffer);
+
 		if (error_scan (input_buffer) != STATE_OK) {
 			result = max_state (result, error_scan (input_buffer));
 			output = strdup (1 + index (input_buffer, ':'));
@@ -163,7 +167,7 @@
 	/* close stdout */
 	if (spclose (child_process)) {
 		result = max_state (result, STATE_WARNING);
-		if (!strcmp (output, ""))
+		if (output == NULL || !strcmp (output, ""))
 			output = strdup (_("nslookup returned error status"));
 	}
 
@@ -240,6 +244,14 @@
 	          strstr (input_buffer, ": REFUSED")))
 		die (STATE_CRITICAL, _("Connection to DNS %s was refused\n"), dns_server);
 
+	/* Query refused (usually by an ACL in the namserver) */ 
+	else if (strstr (input_buffer, "Query refused"))
+		die (STATE_CRITICAL, _("Query was refused by DNS server at %s\n"), dns_server);
+
+	/* No information (e.g. nameserver IP has two PTR records) */
+	else if (strstr (input_buffer, "No information"))
+		die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server);
+
 	/* Host or domain name does not exist */
 	else if (strstr (input_buffer, "Non-existent") ||
 	         strstr (input_buffer, "** server can't find") ||





More information about the Commits mailing list