[Nagiosplug-checkins] nagiosplug/plugins check_ntp.c,1.8,1.9

Ton Voon tonvoon at users.sourceforge.net
Fri Aug 11 10:26:36 CEST 2006


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

Modified Files:
	check_ntp.c 
Log Message:
Catch no responses from any server (1538341 - nmdias)


Index: check_ntp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ntp.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- check_ntp.c	17 Jun 2006 12:28:43 -0000	1.8
+++ check_ntp.c	11 Aug 2006 08:26:33 -0000	1.9
@@ -335,7 +335,7 @@
  *   we have to do it in a way that our lazy macros don't handle currently :( */
 double offset_request(const char *host, int *status){
 	int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
-	int servers_completed=0, one_written=0, servers_readable=0, best_index=-1;
+	int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
 	time_t now_time=0, start_ts=0;
 	ntp_message *req=NULL;
 	double avg_offset=0.;
@@ -437,12 +437,17 @@
 				servers[i].rtdelay=NTP32asDOUBLE(req[i].rtdelay);
 				servers[i].waiting=0;
 				servers_readable--;
+				one_read = 1;
 				if(servers[i].num_responses==AVG_NUM) servers_completed++;
 			}
 		}
 		/* lather, rinse, repeat. */
 	}
 
+	if (one_read == 0) {
+		die(STATE_CRITICAL, "NTP CRITICAL: No response from NTP server\n");
+	}
+
 	/* now, pick the best server from the list */
 	best_index=best_offset_server(servers, num_hosts);
 	if(best_index < 0){





More information about the Commits mailing list