diff options
| -rw-r--r-- | plugins-root/check_icmp.c | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 2b1cc2cd..306113b5 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
| @@ -42,8 +42,16 @@ | |||
| 42 | * | 42 | * |
| 43 | *****************************************************************************/ | 43 | *****************************************************************************/ |
| 44 | 44 | ||
| 45 | 45 | /* progname may be check_ldaps */ | |
| 46 | //char *progname = "check_ldap"; | ||
| 47 | const char *revision = "$Revision$"; | ||
| 48 | const char *copyright = "2005-2006"; | ||
| 49 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | ||
| 46 | 50 | ||
| 51 | /** nagios plugins basic includes */ | ||
| 52 | #include "common.h" | ||
| 53 | #include "netutils.h" | ||
| 54 | #include "utils.h" | ||
| 47 | 55 | ||
| 48 | #include <sys/time.h> | 56 | #include <sys/time.h> |
| 49 | #include <sys/types.h> | 57 | #include <sys/types.h> |
| @@ -64,6 +72,7 @@ | |||
| 64 | #include <arpa/inet.h> | 72 | #include <arpa/inet.h> |
| 65 | #include <signal.h> | 73 | #include <signal.h> |
| 66 | 74 | ||
| 75 | |||
| 67 | /** sometimes undefined system macros (quite a few, actually) **/ | 76 | /** sometimes undefined system macros (quite a few, actually) **/ |
| 68 | #ifndef MAXTTL | 77 | #ifndef MAXTTL |
| 69 | # define MAXTTL 255 | 78 | # define MAXTTL 255 |
| @@ -95,16 +104,6 @@ | |||
| 95 | #endif | 104 | #endif |
| 96 | 105 | ||
| 97 | 106 | ||
| 98 | /** typedefs and such **/ | ||
| 99 | enum states { | ||
| 100 | STATE_OK = 0, | ||
| 101 | STATE_WARNING, | ||
| 102 | STATE_CRITICAL, | ||
| 103 | STATE_UNKNOWN, | ||
| 104 | STATE_DEPENDENT, | ||
| 105 | STATE_OOB | ||
| 106 | }; | ||
| 107 | |||
| 108 | typedef unsigned short range_t; /* type for get_range() -- unimplemented */ | 107 | typedef unsigned short range_t; /* type for get_range() -- unimplemented */ |
| 109 | 108 | ||
| 110 | typedef struct rta_host { | 109 | typedef struct rta_host { |
| @@ -174,7 +173,8 @@ typedef struct icmp_ping_data { | |||
| 174 | #define TSTATE_UNREACH 0x08 | 173 | #define TSTATE_UNREACH 0x08 |
| 175 | 174 | ||
| 176 | /** prototypes **/ | 175 | /** prototypes **/ |
| 177 | static void usage(unsigned char, char *); | 176 | void print_help (void); |
| 177 | void print_usage (void); | ||
| 178 | static u_int get_timevar(const char *); | 178 | static u_int get_timevar(const char *); |
| 179 | static u_int get_timevaldiff(struct timeval *, struct timeval *); | 179 | static u_int get_timevaldiff(struct timeval *, struct timeval *); |
| 180 | static int wait_for_reply(int, u_int); | 180 | static int wait_for_reply(int, u_int); |
| @@ -477,9 +477,12 @@ main(int argc, char **argv) | |||
| 477 | crit_down = (unsigned char)strtoul(ptr + 1, NULL, 0); | 477 | crit_down = (unsigned char)strtoul(ptr + 1, NULL, 0); |
| 478 | } | 478 | } |
| 479 | break; | 479 | break; |
| 480 | case 'h': case 'V': default: | 480 | case 'V': /* version */ |
| 481 | usage(arg, NULL); | 481 | //print_revision (progname, revision); |
| 482 | break; | 482 | exit (STATE_OK); |
| 483 | case 'h': /* help */ | ||
| 484 | print_help (); | ||
| 485 | exit (STATE_OK); | ||
| 483 | } | 486 | } |
| 484 | } | 487 | } |
| 485 | } | 488 | } |
| @@ -1177,20 +1180,21 @@ icmp_checksum(unsigned short *p, int n) | |||
| 1177 | } | 1180 | } |
| 1178 | 1181 | ||
| 1179 | /* make core plugin developers happy (silly, really) */ | 1182 | /* make core plugin developers happy (silly, really) */ |
| 1180 | static void | 1183 | void |
| 1181 | usage(unsigned char arg, char *msg) | 1184 | print_help(void) |
| 1182 | { | 1185 | { |
| 1183 | if(msg) printf("%s: %s\n", progname, msg); | ||
| 1184 | |||
| 1185 | if(arg == 'V') { | ||
| 1186 | printf("$Id$\n"); | ||
| 1187 | exit(STATE_UNKNOWN); | ||
| 1188 | } | ||
| 1189 | |||
| 1190 | printf("Usage: %s [options] [-H] host1 host2 hostn\n\n", progname); | ||
| 1191 | |||
| 1192 | if(arg != 'h') exit(3); | ||
| 1193 | 1186 | ||
| 1187 | //print_revision (progname, revision); | ||
| 1188 | |||
| 1189 | printf ("Copyright (c) 2005 Andreas Ericsson <ae@op5.se>\n"); | ||
| 1190 | printf (COPYRIGHT, copyright, email); | ||
| 1191 | |||
| 1192 | printf ("\n\n"); | ||
| 1193 | |||
| 1194 | print_usage (); | ||
| 1195 | |||
| 1196 | printf (_(UT_HELP_VRSN)); | ||
| 1197 | |||
| 1194 | printf("Where options are any combination of:\n" | 1198 | printf("Where options are any combination of:\n" |
| 1195 | " * -H | --host specify a target\n" | 1199 | " * -H | --host specify a target\n" |
| 1196 | " * -w | --warn warning threshold (currently %0.3fms,%u%%)\n" | 1200 | " * -w | --warn warning threshold (currently %0.3fms,%u%%)\n" |
| @@ -1208,7 +1212,7 @@ usage(unsigned char arg, char *msg) | |||
| 1208 | (float)pkt_interval / 1000, (float)target_interval / 1000, | 1212 | (float)pkt_interval / 1000, (float)target_interval / 1000, |
| 1209 | ttl, timeout); | 1213 | ttl, timeout); |
| 1210 | 1214 | ||
| 1211 | puts("\nThe -H switch is optional. Naming a host (or several) to check is not.\n\n" | 1215 | printf("\nThe -H switch is optional. Naming a host (or several) to check is not.\n\n" |
| 1212 | "Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%\n" | 1216 | "Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%\n" |
| 1213 | "packet loss. The default values should work well for most users.\n" | 1217 | "packet loss. The default values should work well for most users.\n" |
| 1214 | "You can specify different RTA factors using the standardized abbreviations\n" | 1218 | "You can specify different RTA factors using the standardized abbreviations\n" |
| @@ -1220,9 +1224,23 @@ usage(unsigned char arg, char *msg) | |||
| 1220 | "Long options are currently unsupported.\n\n" | 1224 | "Long options are currently unsupported.\n\n" |
| 1221 | "Options marked with * require an argument\n"); | 1225 | "Options marked with * require an argument\n"); |
| 1222 | 1226 | ||
| 1223 | puts("The latest version of this plugin can be found at http://oss.op5.se/nagios\n" | 1227 | /* printf("The latest version of this plugin can be found at http://oss.op5.se/nagios\n" |
| 1224 | "or https://devel.op5.se/oss until the day it is included in the official\n" | 1228 | "or https://devel.op5.se/oss until the day it is included in the official\n" |
| 1225 | "plugin distribution.\n"); | 1229 | "plugin distribution.\n"); |
| 1230 | */ | ||
| 1231 | |||
| 1232 | printf (_(UT_SUPPORT)); | ||
| 1233 | |||
| 1234 | printf (_(UT_NOWARRANTY)); | ||
| 1235 | |||
| 1236 | // exit(3); | ||
| 1237 | } | ||
| 1226 | 1238 | ||
| 1227 | exit(3); | 1239 | |
| 1240 | |||
| 1241 | void | ||
| 1242 | print_usage (void) | ||
| 1243 | { | ||
| 1244 | printf (_("Usage:")); | ||
| 1245 | printf("Usage: %s [options] [-H] host1 host2 hostn\n\n", progname); | ||
| 1228 | } | 1246 | } |
