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

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Mon Sep 1 16:04:23 CEST 2008


Revision: 2051
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2051&view=rev
Author:   dermoth
Date:     2008-09-01 14:04:22 +0000 (Mon, 01 Sep 2008)

Log Message:
-----------
check_ntp_peer/check_ntp_time used to show port in --help but ignored the argument - now implemented.

Modified Paths:
--------------
    nagiosplug/trunk/NEWS
    nagiosplug/trunk/plugins/check_ntp_peer.c
    nagiosplug/trunk/plugins/check_ntp_time.c

Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS	2008-09-01 14:04:04 UTC (rev 2050)
+++ nagiosplug/trunk/NEWS	2008-09-01 14:04:22 UTC (rev 2051)
@@ -11,6 +11,7 @@
 	check_icmp now supports packet size modification
 	check_http -e now accepts a comma-delimited list of expected status codes
 	libtap now included with this distribution for easier testing. Run ./configure with --enable-libtap
+	check_ntp_peer/check_ntp_time used to show port in --help but ignored the argument - now implemented.
 
 1.4.12 27th May 2008
 	Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren)

Modified: nagiosplug/trunk/plugins/check_ntp_peer.c
===================================================================
--- nagiosplug/trunk/plugins/check_ntp_peer.c	2008-09-01 14:04:04 UTC (rev 2050)
+++ nagiosplug/trunk/plugins/check_ntp_peer.c	2008-09-01 14:04:22 UTC (rev 2051)
@@ -48,6 +48,7 @@
 #include "utils.h"
 
 static char *server_address=NULL;
+static int port=123;
 static int verbose=0;
 static int quiet=0;
 static short do_offset=0;
@@ -283,7 +284,7 @@
 	 * 4) Extract the offset, jitter and stratum value from the data[]
 	 *    (it's ASCII)
 	 */
-	my_udp_connect(server_address, 123, &conn);
+	my_udp_connect(server_address, port, &conn);
 
 	/* keep sending requests until the server stops setting the
 	 * REM_MORE bit, though usually this is only 1 packet. */
@@ -469,6 +470,7 @@
 		{"jcrit", required_argument, 0, 'k'},
 		{"timeout", required_argument, 0, 't'},
 		{"hostname", required_argument, 0, 'H'},
+		{"port", required_argument, 0, 'p'},
 		{0, 0, 0, 0}
 	};
 
@@ -477,7 +479,7 @@
 		usage ("\n");
 
 	while (1) {
-		c = getopt_long (argc, argv, "Vhv46qw:c:W:C:j:k:t:H:", longopts, &option);
+		c = getopt_long (argc, argv, "Vhv46qw:c:W:C:j:k:t:H:p:", longopts, &option);
 		if (c == -1 || c == EOF || c == 1)
 			break;
 
@@ -525,6 +527,9 @@
 				usage2(_("Invalid hostname/address"), optarg);
 			server_address = strdup(optarg);
 			break;
+		case 'p':
+			port=atoi(optarg);
+			break;
 		case 't':
 			socket_timeout=atoi(optarg);
 			break;

Modified: nagiosplug/trunk/plugins/check_ntp_time.c
===================================================================
--- nagiosplug/trunk/plugins/check_ntp_time.c	2008-09-01 14:04:04 UTC (rev 2050)
+++ nagiosplug/trunk/plugins/check_ntp_time.c	2008-09-01 14:04:22 UTC (rev 2051)
@@ -47,6 +47,7 @@
 #include "utils.h"
 
 static char *server_address=NULL;
+static char *port="123";
 static int verbose=0;
 static int quiet=0;
 static char *owarn="60";
@@ -319,7 +320,7 @@
 	hints.ai_socktype = SOCK_DGRAM;
 
 	/* fill in ai with the list of hosts resolved by the host name */
-	ga_result = getaddrinfo(host, "123", &hints, &ai);
+	ga_result = getaddrinfo(host, port, &hints, &ai);
 	if(ga_result!=0){
 		die(STATE_UNKNOWN, "error getting address for %s: %s\n",
 		    host, gai_strerror(ga_result));
@@ -456,6 +457,7 @@
 		{"critical", required_argument, 0, 'c'},
 		{"timeout", required_argument, 0, 't'},
 		{"hostname", required_argument, 0, 'H'},
+		{"port", required_argument, 0, 'p'},
 		{0, 0, 0, 0}
 	};
 
@@ -464,7 +466,7 @@
 		usage ("\n");
 
 	while (1) {
-		c = getopt_long (argc, argv, "Vhv46qw:c:t:H:", longopts, &option);
+		c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:", longopts, &option);
 		if (c == -1 || c == EOF || c == 1)
 			break;
 
@@ -494,6 +496,9 @@
 				usage2(_("Invalid hostname/address"), optarg);
 			server_address = strdup(optarg);
 			break;
+		case 'p':
+			port = strdup(optarg);
+			break;
 		case 't':
 			socket_timeout=atoi(optarg);
 			break;


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