[Nagiosplug-checkins] nagiosplug/plugins-root check_icmp.c, 1.4, 1.5
Benoit Mortier
opensides at users.sourceforge.net
Mon Oct 23 02:02:46 CEST 2006
Update of /cvsroot/nagiosplug/nagiosplug/plugins-root
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17952/plugins-root
Modified Files:
check_icmp.c
Log Message:
first pass a making check icmp respecting nagiosplugins rules
Index: check_icmp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-root/check_icmp.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- check_icmp.c 22 Oct 2006 22:14:53 -0000 1.4
+++ check_icmp.c 23 Oct 2006 00:02:44 -0000 1.5
@@ -42,8 +42,16 @@
*
*****************************************************************************/
-
+/* progname may be check_ldaps */
+//char *progname = "check_ldap";
+const char *revision = "$Revision$";
+const char *copyright = "2005-2006";
+const char *email = "nagiosplug-devel at lists.sourceforge.net";
+/** nagios plugins basic includes */
+#include "common.h"
+#include "netutils.h"
+#include "utils.h"
#include <sys/time.h>
#include <sys/types.h>
@@ -64,6 +72,7 @@
#include <arpa/inet.h>
#include <signal.h>
+
/** sometimes undefined system macros (quite a few, actually) **/
#ifndef MAXTTL
# define MAXTTL 255
@@ -95,16 +104,6 @@
#endif
-/** typedefs and such **/
-enum states {
- STATE_OK = 0,
- STATE_WARNING,
- STATE_CRITICAL,
- STATE_UNKNOWN,
- STATE_DEPENDENT,
- STATE_OOB
-};
-
typedef unsigned short range_t; /* type for get_range() -- unimplemented */
typedef struct rta_host {
@@ -174,7 +173,8 @@
#define TSTATE_UNREACH 0x08
/** prototypes **/
-static void usage(unsigned char, char *);
+void print_help (void);
+void print_usage (void);
static u_int get_timevar(const char *);
static u_int get_timevaldiff(struct timeval *, struct timeval *);
static int wait_for_reply(int, u_int);
@@ -477,9 +477,12 @@
crit_down = (unsigned char)strtoul(ptr + 1, NULL, 0);
}
break;
- case 'h': case 'V': default:
- usage(arg, NULL);
- break;
+ case 'V': /* version */
+ //print_revision (progname, revision);
+ exit (STATE_OK);
+ case 'h': /* help */
+ print_help ();
+ exit (STATE_OK);
}
}
}
@@ -1177,20 +1180,21 @@
}
/* make core plugin developers happy (silly, really) */
-static void
-usage(unsigned char arg, char *msg)
+void
+print_help(void)
{
- if(msg) printf("%s: %s\n", progname, msg);
-
- if(arg == 'V') {
- printf("$Id$\n");
- exit(STATE_UNKNOWN);
- }
-
- printf("Usage: %s [options] [-H] host1 host2 hostn\n\n", progname);
-
- if(arg != 'h') exit(3);
+ //print_revision (progname, revision);
+
+ printf ("Copyright (c) 2005 Andreas Ericsson <ae at op5.se>\n");
+ printf (COPYRIGHT, copyright, email);
+
+ printf ("\n\n");
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
printf("Where options are any combination of:\n"
" * -H | --host specify a target\n"
" * -w | --warn warning threshold (currently %0.3fms,%u%%)\n"
@@ -1208,7 +1212,7 @@
(float)pkt_interval / 1000, (float)target_interval / 1000,
ttl, timeout);
- puts("\nThe -H switch is optional. Naming a host (or several) to check is not.\n\n"
+ printf("\nThe -H switch is optional. Naming a host (or several) to check is not.\n\n"
"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%\n"
"packet loss. The default values should work well for most users.\n"
"You can specify different RTA factors using the standardized abbreviations\n"
@@ -1220,9 +1224,23 @@
"Long options are currently unsupported.\n\n"
"Options marked with * require an argument\n");
- puts("The latest version of this plugin can be found at http://oss.op5.se/nagios\n"
+/* printf("The latest version of this plugin can be found at http://oss.op5.se/nagios\n"
"or https://devel.op5.se/oss until the day it is included in the official\n"
"plugin distribution.\n");
+*/
+
+ printf (_(UT_SUPPORT));
+
+ printf (_(UT_NOWARRANTY));
+
+// exit(3);
+}
- exit(3);
+
+
+void
+print_usage (void)
+{
+ printf (_("Usage:"));
+ printf("Usage: %s [options] [-H] host1 host2 hostn\n\n", progname);
}
More information about the Commits
mailing list