index 2b1cc2cde85837cb9db49684c2d10f92b76cb02e..62e3d574cbb924ab5f9b87a5afc6b6da210272e0 100644 (file)
*
*****************************************************************************/
-
-
+/* progname may change */
+/* char *progname = "check_icmp"; */
+char *progname;
+const char *revision = "$Revision$";
+const char *copyright = "2005-2006";
+const char *email = "nagiosplug-devel@lists.sourceforge.net";
+
+/** nagios plugins basic includes */
+#include "common.h"
+#include "netutils.h"
+#include "utils.h"
#include <sys/time.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <signal.h>
+
/** sometimes undefined system macros (quite a few, actually) **/
#ifndef MAXTTL
# define MAXTTL 255
#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 {
#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);
extern char **environ;
/** global variables **/
-static char *progname;
static struct rta_host **table, *cursor, *list;
static threshold crit = {80, 500000}, warn = {40, 200000};
static int mode, protocols, sockets, debug = 0, timeout = 10;
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);
}
}
}
return cksum;
}
-/* 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);
- }
+ //print_revision (progname, revision);
+
+ printf ("Copyright (c) 2005 Andreas Ericsson <ae@op5.se>\n");
+ printf (COPYRIGHT, copyright, email);
+
+ printf ("\n\n");
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (" %s\n", "-H");
+ printf (" %s\n", _("specify a target"));
+ printf (" %s\n", "-w");
+ printf (" %s", _("warning threshold (currently "));
+ printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000 , warn.pl / 1000);
+ printf (" %s\n", "-c");
+ printf (" %s", _("critical threshold (currently "));
+ printf ("%0.3fms,%u%%)\n", (float)crit.rta, crit.pl);
+ printf (" %s\n", "-n");
+ printf (" %s", _("number of packets to send (currently "));
+ printf ("%u)\n",packets);
+ printf (" %s\n", "-i");
+ printf (" %s", _("max packet interval (currently "));
+ printf ("%0.3fms)\n",(float)pkt_interval / 1000);
+ printf (" %s\n", "-I");
+ printf (" %s", _("max target interval (currently "));
+ printf ("%0.3fms)\n", (float)target_interval / 1000);
+ printf (" %s\n", "-l");
+ printf (" %s", _("TTL on outgoing packets (currently "));
+ printf ("%u)", ttl);
+ printf (" %s\n", "-t");
+ printf (" %s",_("timeout value (seconds, currently "));
+ printf ("%u)\n", timeout);
+ printf (" %s\n", "-b");
+ printf (" %s\n", _("icmp packet size (currenly ignored)"));
+ printf (" %s\n", "-v");
+ printf (" %s\n", _("verbose"));
+
+ printf ("\n");
+ printf ("%s\n\n", _("The -H switch is optional. Naming a host (or several) to check is not."));
+ printf ("%s\n", _("Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"));
+ printf ("%s\n", _("packet loss. The default values should work well for most users."));
+ printf ("%s\n", _("You can specify different RTA factors using the standardized abbreviations"));
+ printf ("%s\n\n", _("us (microseconds), ms (milliseconds, default) or just plain s for seconds."));
+ printf ("%s\n", _("Threshold format for -d is warn,crit. 12,14 means WARNING if >= 12 hops"));
+ printf ("%s\n", _("are spent and CRITICAL if >= 14 hops are spent."));
+ printf ("%s\n\n", _("NOTE: Some systems decrease TTL when forming ICMP_ECHOREPLY, others do not."));
+ printf ("%s\n\n", _("The -v switch can be specified several times for increased verbosity."));
+/* printf ("%s\n", _("Long options are currently unsupported."));
+ printf ("%s\n", _("Options marked with * require an argument"));
+*/
+ printf (_(UT_SUPPORT));
+
+ printf (_(UT_NOWARRANTY));
+}
- printf("Usage: %s [options] [-H] host1 host2 hostn\n\n", progname);
-
- if(arg != 'h') exit(3);
-
- printf("Where options are any combination of:\n"
- " * -H | --host specify a target\n"
- " * -w | --warn warning threshold (currently %0.3fms,%u%%)\n"
- " * -c | --crit critical threshold (currently %0.3fms,%u%%)\n"
- " * -n | --packets number of packets to send (currently %u)\n"
- " * -i | --interval max packet interval (currently %0.3fms)\n"
- " * -I | --hostint max target interval (currently %0.3fms)\n"
- " * -l | --ttl TTL on outgoing packets (currently %u)\n"
- " * -t | --timeout timeout value (seconds, currently %u)\n"
- " * -b | --bytes icmp packet size (currenly ignored)\n"
- " -v | --verbose verbosity++\n"
- " -h | --help this cruft\n",
- (float)warn.rta / 1000, warn.pl, (float)crit.rta / 1000, crit.pl,
- packets,
- (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"
- "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"
- "us (microseconds), ms (milliseconds, default) or just plain s for seconds.\n\n"
- "Threshold format for -d is warn,crit. 12,14 means WARNING if >= 12 hops\n"
- "are spent and CRITICAL if >= 14 hops are spent.\n"
- "NOTE: Some systems decrease TTL when forming ICMP_ECHOREPLY, others do not.\n\n"
- "The -v switch can be specified several times for increased verbosity.\n\n"
- "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"
- "or https://devel.op5.se/oss until the day it is included in the official\n"
- "plugin distribution.\n");
- exit(3);
+
+void
+print_usage (void)
+{
+ printf (_("Usage:"));
+ printf(" %s [options] [-H] host1 host2 hostn\n", progname);
}