[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1831] nagiosplug/branches/dermoth_ntp_rework/ plugins

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Fri Nov 23 22:38:53 CET 2007


Revision: 1831
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1831&view=rev
Author:   dermoth
Date:     2007-11-23 13:38:53 -0800 (Fri, 23 Nov 2007)

Log Message:
-----------
[1/2] Rename (plus some minor modifications)

Modified Paths:
--------------
    nagiosplug/branches/dermoth_ntp_rework/plugins/check_ntpd.c
    nagiosplug/branches/dermoth_ntp_rework/plugins/check_time_ntp.c

Modified: nagiosplug/branches/dermoth_ntp_rework/plugins/check_ntpd.c
===================================================================
--- nagiosplug/branches/dermoth_ntp_rework/plugins/check_ntpd.c	2007-11-23 04:21:09 UTC (rev 1830)
+++ nagiosplug/branches/dermoth_ntp_rework/plugins/check_ntpd.c	2007-11-23 21:38:53 UTC (rev 1831)
@@ -1,6 +1,6 @@
 /******************************************************************************
 *
-* Nagios check_ntpd plugin
+* Nagios check_ntp_peer plugin
 *
 * License: GPL
 * Copyright (c) 2006 sean finney <seanius at seanius.net>
@@ -10,7 +10,7 @@
 *
 * Description:
 *
-* This file contains the check_ntpd plugin
+* This file contains the check_ntp_peer plugin
 *
 *  This plugin to check ntp servers independant of any commandline
 *  programs or external libraries.
@@ -36,7 +36,7 @@
  
 *****************************************************************************/
 
-const char *progname = "check_ntpd";
+const char *progname = "check_ntp_peer";
 const char *revision = "$Revision$";
 const char *copyright = "2007";
 const char *email = "nagiosplug-devel at lists.sourceforge.net";
@@ -211,6 +211,7 @@
 	char *value=NULL, *nptr=NULL;
 	void *tmp;
 
+	status = STATE_OK;
 	*offset_result = STATE_UNKNOWN;
 	*jitter = *stratum = -1;
 
@@ -315,28 +316,33 @@
 				printf("parsing offset from peer %.2x: ", ntohs(peers[i].assoc));
 
 			value = extract_value(req.data, "offset");
+			/* Convert the value if we have one */
 			if(value != NULL)
 				*offset = strtod(value, &nptr) / 1000;
-			if(value == NULL || value==nptr){
+			/* If value is null or no conversion was performed */
+			if(value == NULL || value==nptr) {
 				printf("warning: unable to read server offset response.\n");
-				status = max_state(status, STATE_CRITICAL);
+				status = max_state_alt(status, STATE_CRITICAL);
 			} else {
 				*offset_result = STATE_OK;
 				if(verbose) printf("%g\n", *offset);
 			}
 
 			if(do_jitter) {
+				/* first reset the pointers */
 				value = NULL, nptr=NULL;
 				/* get the jitter */
 				if(verbose) {
 					printf("parsing jitter from peer %.2x: ", ntohs(peers[i].assoc));
 				}
 				value = extract_value(req.data, strstr(getvar, "dispersion") != NULL ? "dispersion" : "jitter");
+				/* Convert the value if we have one */
 				if(value != NULL)
 					*jitter = strtod(value, &nptr);
+				/* If value is null or no conversion was performed */
 				if(value == NULL || value==nptr){
 					printf("warning: unable to read server jitter response.\n");
-					status = max_state(status, STATE_UNKNOWN);
+					status = max_state_alt(status, STATE_UNKNOWN);
 				} else {
 					if(verbose) printf("%g\n", *jitter);
 				}
@@ -351,7 +357,7 @@
 				value = extract_value(req.data, "stratum");
 				if(value == NULL){
 					printf("warning: unable to read server stratum response.\n");
-					status = max_state(status, STATE_UNKNOWN);
+					status = max_state_alt(status, STATE_UNKNOWN);
 				} else {
 					*stratum = atoi(value);
 					if(verbose) printf("%i\n", *stratum);
@@ -508,13 +514,13 @@
 	alarm (socket_timeout);
 
 	result = ntp_request(server_address, &offset, &offset_result, &jitter, &stratum);
-	result = get_status(fabs(offset), offset_thresholds);
+	result = max_state_alt(result, get_status(fabs(offset), offset_thresholds));
 
 	if(do_stratum)
-		result = max_state(result, get_status(stratum, stratum_thresholds));
+		result = max_state_alt(result, get_status(stratum, stratum_thresholds));
 
 	if(do_jitter)
-		result = max_state(result, get_status(jitter, jitter_thresholds));
+		result = max_state_alt(result, get_status(jitter, jitter_thresholds));
 
 	switch (result) {
 		case STATE_CRITICAL :
@@ -593,12 +599,12 @@
 	printf("\n");
 	printf("%s\n", _("Examples:"));
 	printf(" %s\n", _("Normal offset check:"));
-	printf("  %s\n", ("./check_ntpd -H ntpserv -w 0.5 -c 1"));
+	printf("  %s\n", ("./check_ntp_peer -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_ntpd -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200"));
+	printf("  %s\n", ("./check_ntp_peer -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200"));
 	printf(" %s\n", _("Check only stratum:"));
-	printf("  %s\n", ("./check_ntpd -H ntpserv -W 4 -C 6"));
+	printf("  %s\n", ("./check_ntp_peer -H ntpserv -W 4 -C 6"));
 
 	printf (_(UT_SUPPORT));
 }

Modified: nagiosplug/branches/dermoth_ntp_rework/plugins/check_time_ntp.c
===================================================================
--- nagiosplug/branches/dermoth_ntp_rework/plugins/check_time_ntp.c	2007-11-23 04:21:09 UTC (rev 1830)
+++ nagiosplug/branches/dermoth_ntp_rework/plugins/check_time_ntp.c	2007-11-23 21:38:53 UTC (rev 1831)
@@ -1,6 +1,6 @@
 /******************************************************************************
 *
-* Nagios check_time_ntp plugin
+* Nagios check_ntp_time plugin
 *
 * License: GPL
 * Copyright (c) 2006 sean finney <seanius at seanius.net>
@@ -10,7 +10,7 @@
 *
 * Description:
 *
-* This file contains the check_time_ntp plugin
+* This file contains the check_ntp_time plugin
 *
 *  This plugin checks the clock offset with an NTP server. It is
 *  independant of any commandline programs or external libraries.
@@ -36,7 +36,7 @@
  
 *****************************************************************************/
 
-const char *progname = "check_time_ntp";
+const char *progname = "check_ntp_time";
 const char *revision = "$Revision$";
 const char *copyright = "2007";
 const char *email = "nagiosplug-devel at lists.sourceforge.net";
@@ -600,7 +600,7 @@
 
 	printf("\n");
 	printf("%s\n", _("Examples:"));
-	printf("  %s\n", ("./check_time_ntp -H ntpserv -w 0.5 -c 1"));
+	printf("  %s\n", ("./check_ntp_time -H ntpserv -w 0.5 -c 1"));
 
 	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