summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Mortier <opensides@users.sourceforge.net>2006-10-23 00:02:44 +0000
committerBenoit Mortier <opensides@users.sourceforge.net>2006-10-23 00:02:44 +0000
commit171ae1fb85f283da66d27c6a10ee8f0fbbf796b3 (patch)
tree3f7931c43b344403f1b808f37b6edabab01b68ce
parent1698772fa4a7708f79f14181dcbcc6abcd2bae04 (diff)
downloadmonitoring-plugins-171ae1fb85f283da66d27c6a10ee8f0fbbf796b3.tar.gz
first pass a making check icmp respecting nagiosplugins rules
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1519 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins-root/check_icmp.c78
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";
47const char *revision = "$Revision$";
48const char *copyright = "2005-2006";
49const 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 **/
99enum states {
100 STATE_OK = 0,
101 STATE_WARNING,
102 STATE_CRITICAL,
103 STATE_UNKNOWN,
104 STATE_DEPENDENT,
105 STATE_OOB
106};
107
108typedef unsigned short range_t; /* type for get_range() -- unimplemented */ 107typedef unsigned short range_t; /* type for get_range() -- unimplemented */
109 108
110typedef struct rta_host { 109typedef 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 **/
177static void usage(unsigned char, char *); 176void print_help (void);
177void print_usage (void);
178static u_int get_timevar(const char *); 178static u_int get_timevar(const char *);
179static u_int get_timevaldiff(struct timeval *, struct timeval *); 179static u_int get_timevaldiff(struct timeval *, struct timeval *);
180static int wait_for_reply(int, u_int); 180static 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) */
1180static void 1183void
1181usage(unsigned char arg, char *msg) 1184print_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
1241void
1242print_usage (void)
1243{
1244 printf (_("Usage:"));
1245 printf("Usage: %s [options] [-H] host1 host2 hostn\n\n", progname);
1228} 1246}