[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1811] nagiosplug/trunk

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Thu Oct 25 23:06:08 CEST 2007


Revision: 1811
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1811&view=rev
Author:   dermoth
Date:     2007-10-25 14:06:08 -0700 (Thu, 25 Oct 2007)

Log Message:
-----------
check_ntp now return UNKNOWN instead of WARNING if jitter is
unavailable. If no offset threshold is specified and
the offset is unavailable, will return UNKNOWN as well.

Modified Paths:
--------------
    nagiosplug/trunk/NEWS
    nagiosplug/trunk/plugins/check_ntp.c

Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS	2007-10-25 20:43:04 UTC (rev 1810)
+++ nagiosplug/trunk/NEWS	2007-10-25 21:06:08 UTC (rev 1811)
@@ -4,6 +4,11 @@
 	Fix check_http regression in 1.4.10 where following redirects to
 	  relative URLs on virtual hosts failed if both "-H" and "-I" were used
 	Add stratum thresholds support to check_ntp (feature request #1703823)
+	check_ntp now return UNKNOWN instead of WARNING if jitter is unavailable (jitter=-1.000000)
+	  as long as the thresholds range inculde -1. If no offset threshold is specified
+	  and the offset is unavailable, will return UNKNOWN as well.
+	  NOTE: If jitter thresholds are specified integers it will return CRITICAL if jitter
+	  is "-1" as the default range starts at 0. See Examples in --help output.
 
 1.4.10 28th September 2007
 	Fix check_http buffer overflow vulnerability when following HTTP redirects

Modified: nagiosplug/trunk/plugins/check_ntp.c
===================================================================
--- nagiosplug/trunk/plugins/check_ntp.c	2007-10-25 20:43:04 UTC (rev 1810)
+++ nagiosplug/trunk/plugins/check_ntp.c	2007-10-25 21:06:08 UTC (rev 1811)
@@ -47,6 +47,7 @@
 
 static char *server_address=NULL;
 static int verbose=0;
+static short do_offset=0;
 static char *owarn="60";
 static char *ocrit="120";
 static short do_stratum=0;
@@ -479,7 +480,7 @@
 	/* now, pick the best server from the list */
 	best_index=best_offset_server(servers, num_hosts);
 	if(best_index < 0){
-		*status=STATE_CRITICAL;
+		*status=STATE_UNKNOWN;
 	} else {
 		/* finally, calculate the average offset */
 		for(i=0; i<servers[best_index].num_responses;i++){
@@ -582,7 +583,7 @@
 	if(verbose) printf("%d candiate peers available\n", num_candidates);
 	if(verbose && syncsource_found) printf("synchronization source found\n");
 	if(! syncsource_found){
-		*status = STATE_WARNING;
+		*status = STATE_UNKNOWN;
 		if(verbose) printf("warning: no synchronization source found\n");
 	}
 
@@ -632,7 +633,7 @@
 				}
 				if(startofvalue == NULL || startofvalue==nptr){
 					printf("warning: unable to read server jitter response.\n");
-					*status = STATE_WARNING;
+					*status = STATE_UNKNOWN;
 				} else {
 					if(verbose) printf("%g\n", jitter);
 					num_valid++;
@@ -695,9 +696,11 @@
 			verbose++;
 			break;
 		case 'w':
+			do_offset=1;
 			owarn = optarg;
 			break;
 		case 'c':
+			do_offset=1;
 			ocrit = optarg;
 			break;
 		case 'W':
@@ -777,7 +780,7 @@
 	double offset=0, jitter=0;
 	char *result_line, *perfdata_line;
 
-	result = offset_result = jitter_result= STATE_UNKNOWN;
+	result = offset_result = jitter_result = STATE_OK;
 
 	if (process_arguments (argc, argv) == ERROR)
 		usage4 (_("Could not parse arguments"));
@@ -793,7 +796,11 @@
 	alarm (socket_timeout);
 
 	offset = offset_request(server_address, &stratum, &offset_result);
-	result = get_status(fabs(offset), offset_thresholds);
+	if (do_offset && offset_result == STATE_UNKNOWN) {
+		result = STATE_CRITICAL;
+	} else {
+		result = get_status(fabs(offset), offset_thresholds);
+	}
 	result = max_state(result, offset_result);
 	if(do_stratum)
 		result = max_state(result, get_status(stratum, stratum_thresholds));
@@ -827,13 +834,15 @@
 			asprintf(&result_line, "NTP UNKNOWN:");
 			break;
 	}
-	if(offset_result==STATE_CRITICAL){
+	if(offset_result == STATE_UNKNOWN){
 		asprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
 		asprintf(&perfdata_line, "");
 	} else {
+#if 0		/* 2007-10-25 This can't happen. Leftovers or uninplemented? */
 		if(offset_result==STATE_WARNING){
 			asprintf(&result_line, "%s %s", result_line, _("Unable to fully sample sync server"));
 		}
+#endif
 		asprintf(&result_line, "%s Offset %.10g secs", result_line, offset);
 		asprintf(&perfdata_line, "%s", perfd_offset(offset));
 	}
@@ -887,6 +896,16 @@
 	printf(" %s\n", ("http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT"));
 	printf(" %s\n", _("for THRESHOLD format and examples."));
 
+	printf("\n");
+	printf("%s\n", _("Examples:"));
+	printf(" %s\n", _("Normal offset check:"));
+	printf("  %s\n", ("./check_ntp -H ntpserv -w 0.5 -c 1"));
+	printf(" %s\n", _("Check jitter too, avoiding critical notifications if jitter isn't available"));
+	printf(" %s\n", _("(See Notes above for more details on thresholds formats):"));
+	printf("  %s\n", ("./check_ntp -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200"));
+	printf(" %s\n", _("Check only stratum:"));
+	printf("  %s\n", ("./check_ntp -H ntpserv -W 4 -C 6"));
+
 	printf (_(UT_SUPPORT));
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list