summaryrefslogtreecommitdiffstats
path: root/plugins/check_fping.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-10 06:53:22 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-10 06:53:22 (GMT)
commitf4f92be60c94fd4e0dd4b2b4b3101543eedb706a (patch)
tree28d25bd0ab624d82435823c940a186370947ad4d /plugins/check_fping.c
parentcbf702f51f839af5a8e9c66bdae7d6a3dc363ace (diff)
downloadmonitoring-plugins-f4f92be60c94fd4e0dd4b2b4b3101543eedb706a.tar.gz
the last round of pedantic compiler warnings
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@676 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_fping.c')
-rw-r--r--plugins/check_fping.c115
1 files changed, 64 insertions, 51 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index 7e4049c..bb17830 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -34,6 +34,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
34 34
35#include "common.h" 35#include "common.h"
36#include "popen.h" 36#include "popen.h"
37#include "netutils.h"
37#include "utils.h" 38#include "utils.h"
38 39
39#define PACKET_COUNT 1 40#define PACKET_COUNT 1
@@ -44,54 +45,11 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
44#define PL 0 45#define PL 0
45#define RTA 1 46#define RTA 1
46 47
47void
48print_usage (void)
49{
50 printf (_("Usage: %s <host_address>\n"), progname);
51}
52
53void
54print_help (void)
55{
56
57 print_revision (progname, "$Revision$");
58
59 printf (_("\
60Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)\n\n\
61This plugin will use the /bin/fping command (from saint) to ping the\n\
62specified host for a fast check if the host is alive. Note that it is\n\
63necessary to set the suid flag on fping.\n\n"));
64
65 print_usage ();
66
67 printf (_(UT_HELP_VRSN));
68
69 printf (_("\
70 -H, --hostname=HOST\n\
71 Name or IP Address of host to ping (IP Address bypasses name lookup,\n\
72 reducing system load)\n\
73 -w, --warning=THRESHOLD\n\
74 warning threshold pair\n\
75 -c, --critical=THRESHOLD\n\
76 critical threshold pair\n\
77 -b, --bytes=INTEGER\n\
78 Size of ICMP packet (default: %d)\n\
79 -n, --number=INTEGER\n\
80 Number of ICMP packets to send (default: %d)\n"),
81 PACKET_SIZE, PACKET_COUNT);
82
83 printf (_(UT_VERBOSE));
84
85 printf (_("\n\
86THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel\n\
87time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the\n\
88percentage of packet loss to trigger an alarm state.\n"));
89
90}
91
92int textscan (char *buf); 48int textscan (char *buf);
93int process_arguments (int, char **); 49int process_arguments (int, char **);
94int get_threshold (char *arg, char *rv[2]); 50int get_threshold (char *arg, char *rv[2]);
51void print_help (void);
52void print_usage (void);
95 53
96char *server_name = NULL; 54char *server_name = NULL;
97int cpl = UNKNOWN_PACKET_LOSS; 55int cpl = UNKNOWN_PACKET_LOSS;
@@ -200,11 +158,11 @@ textscan (char *buf)
200 rta = strtod (rtastr, NULL); 158 rta = strtod (rtastr, NULL);
201 if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl) 159 if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
202 status = STATE_CRITICAL; 160 status = STATE_CRITICAL;
203 else if (crta != UNKNOWN_TRIP_TIME && rta > crta) 161 else if (crta <= 0 && rta > crta)
204 status = STATE_CRITICAL; 162 status = STATE_CRITICAL;
205 else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl) 163 else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl)
206 status = STATE_WARNING; 164 status = STATE_WARNING;
207 else if (wrta != UNKNOWN_TRIP_TIME && rta > wrta) 165 else if (wrta >= 0 && rta > wrta)
208 status = STATE_WARNING; 166 status = STATE_WARNING;
209 else 167 else
210 status = STATE_OK; 168 status = STATE_OK;
@@ -218,7 +176,7 @@ textscan (char *buf)
218 losstr = 1 + strstr (losstr, "/"); 176 losstr = 1 + strstr (losstr, "/");
219 losstr = 1 + strstr (losstr, "/"); 177 losstr = 1 + strstr (losstr, "/");
220 loss = strtod (losstr, NULL); 178 loss = strtod (losstr, NULL);
221 if (loss == 100) 179 if (atoi(losstr) == 100)
222 status = STATE_CRITICAL; 180 status = STATE_CRITICAL;
223 else if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl) 181 else if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
224 status = STATE_CRITICAL; 182 status = STATE_CRITICAL;
@@ -248,8 +206,8 @@ process_arguments (int argc, char **argv)
248 int c; 206 int c;
249 char *rv[2]; 207 char *rv[2];
250 208
251 int option_index = 0; 209 int option = 0;
252 static struct option long_options[] = { 210 static struct option longopts[] = {
253 {"hostname", required_argument, 0, 'H'}, 211 {"hostname", required_argument, 0, 'H'},
254 {"critical", required_argument, 0, 'c'}, 212 {"critical", required_argument, 0, 'c'},
255 {"warning", required_argument, 0, 'w'}, 213 {"warning", required_argument, 0, 'w'},
@@ -275,7 +233,7 @@ process_arguments (int argc, char **argv)
275 } 233 }
276 234
277 while (1) { 235 while (1) {
278 c = getopt_long (argc, argv, "+hVvH:c:w:b:n:", long_options, &option_index); 236 c = getopt_long (argc, argv, "+hVvH:c:w:b:n:", longopts, &option);
279 237
280 if (c == -1 || c == EOF || c == 1) 238 if (c == -1 || c == EOF || c == 1)
281 break; 239 break;
@@ -389,3 +347,58 @@ get_threshold (char *arg, char *rv[2])
389 347
390 return OK; 348 return OK;
391} 349}
350
351
352
353
354
355
356void
357print_help (void)
358{
359
360 print_revision (progname, "$Revision$");
361
362 printf (_("\
363Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)\n\n\
364This plugin will use the /bin/fping command (from saint) to ping the\n\
365specified host for a fast check if the host is alive. Note that it is\n\
366necessary to set the suid flag on fping.\n\n"));
367
368 print_usage ();
369
370 printf (_(UT_HELP_VRSN));
371
372 printf (_("\
373 -H, --hostname=HOST\n\
374 Name or IP Address of host to ping (IP Address bypasses name lookup,\n\
375 reducing system load)\n\
376 -w, --warning=THRESHOLD\n\
377 warning threshold pair\n\
378 -c, --critical=THRESHOLD\n\
379 critical threshold pair\n\
380 -b, --bytes=INTEGER\n\
381 Size of ICMP packet (default: %d)\n\
382 -n, --number=INTEGER\n\
383 Number of ICMP packets to send (default: %d)\n"),
384 PACKET_SIZE, PACKET_COUNT);
385
386 printf (_(UT_VERBOSE));
387
388 printf (_("\n\
389THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel\n\
390time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the\n\
391percentage of packet loss to trigger an alarm state.\n"));
392
393 printf (_(UT_SUPPORT));
394}
395
396
397
398
399void
400print_usage (void)
401{
402 printf (_("Usage: %s <host_address>\n"), progname);
403 printf (_(UT_HLP_VRS), progname, progname);
404}