diff options
author | Matthias Eble <psychotrahe@users.sourceforge.net> | 2008-07-17 07:06:33 (GMT) |
---|---|---|
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | 2008-07-17 07:06:33 (GMT) |
commit | c64070fd3f924b02a517117bba2dfe702d020a9b (patch) | |
tree | d72261eb17921f71d6070cfcdd1be2cb1dd4d291 | |
parent | b336798e4c1c2fab5e4396e45af6f07ddae647f1 (diff) | |
download | monitoring-plugins-c64070fd3f924b02a517117bba2dfe702d020a9b.tar.gz |
Add support for packet size modification (-b)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2026 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | plugins-root/check_icmp.c | 26 |
2 files changed, 17 insertions, 10 deletions
@@ -8,6 +8,7 @@ This file documents the major additions and syntax changes between releases. | |||
8 | check_dig now returns CRITICAL instead of WARNING when no answer section is found | 8 | check_dig now returns CRITICAL instead of WARNING when no answer section is found |
9 | check_procs now captures stderr in external command and adds to plugin output | 9 | check_procs now captures stderr in external command and adds to plugin output |
10 | check_snmp now only prints perfdata for non numeric values (#1867716) | 10 | check_snmp now only prints perfdata for non numeric values (#1867716) |
11 | check_icmp now supports packet size modification | ||
11 | 12 | ||
12 | 1.4.12 27th May 2008 | 13 | 1.4.12 27th May 2008 |
13 | Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren) | 14 | Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren) |
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index f3e5f0d..5fb9c36 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
@@ -203,7 +203,9 @@ extern char **environ; | |||
203 | static struct rta_host **table, *cursor, *list; | 203 | static struct rta_host **table, *cursor, *list; |
204 | static threshold crit = {80, 500000}, warn = {40, 200000}; | 204 | static threshold crit = {80, 500000}, warn = {40, 200000}; |
205 | static int mode, protocols, sockets, debug = 0, timeout = 10; | 205 | static int mode, protocols, sockets, debug = 0, timeout = 10; |
206 | static unsigned short icmp_pkt_size, icmp_data_size = DEFAULT_PING_DATA_SIZE; | 206 | static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE; |
207 | static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN; | ||
208 | |||
207 | static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0; | 209 | static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0; |
208 | #define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost)) | 210 | #define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost)) |
209 | static unsigned short targets_down = 0, targets = 0, packets = 0; | 211 | static unsigned short targets_down = 0, targets = 0, packets = 0; |
@@ -453,12 +455,22 @@ main(int argc, char **argv) | |||
453 | /* parse the arguments */ | 455 | /* parse the arguments */ |
454 | for(i = 1; i < argc; i++) { | 456 | for(i = 1; i < argc; i++) { |
455 | while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) { | 457 | while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) { |
458 | long size; | ||
456 | switch(arg) { | 459 | switch(arg) { |
457 | case 'v': | 460 | case 'v': |
458 | debug++; | 461 | debug++; |
459 | break; | 462 | break; |
460 | case 'b': | 463 | case 'b': |
461 | /* silently ignored for now */ | 464 | size = strtol(optarg,NULL,0); |
465 | if (size >= (sizeof(struct icmp) + sizeof(struct icmp_ping_data)) && | ||
466 | size <= MAX_PING_DATA + ICMP_MINLEN) { | ||
467 | icmp_pkt_size = size; | ||
468 | icmp_data_size = icmp_pkt_size - ICMP_MINLEN; | ||
469 | } else | ||
470 | usage_va("ICMP packet size must be between: %d and %d", | ||
471 | sizeof(struct icmp) + sizeof(struct icmp_ping_data), | ||
472 | MAX_PING_DATA + ICMP_MINLEN); | ||
473 | |||
462 | break; | 474 | break; |
463 | case 'i': | 475 | case 'i': |
464 | pkt_interval = get_timevar(optarg); | 476 | pkt_interval = get_timevar(optarg); |
@@ -587,13 +599,6 @@ main(int argc, char **argv) | |||
587 | } | 599 | } |
588 | } | 600 | } |
589 | 601 | ||
590 | icmp_pkt_size = icmp_data_size + ICMP_MINLEN; | ||
591 | if(debug > 2) printf("icmp_pkt_size = %u\n", icmp_pkt_size); | ||
592 | if(icmp_pkt_size < sizeof(struct icmp) + sizeof(struct icmp_ping_data)) { | ||
593 | icmp_pkt_size = sizeof(struct icmp) + sizeof(struct icmp_ping_data); | ||
594 | } | ||
595 | if(debug > 2) printf("icmp_pkt_size = %u\n", icmp_pkt_size); | ||
596 | |||
597 | if(debug) { | 602 | if(debug) { |
598 | printf("crit = {%u, %u%%}, warn = {%u, %u%%}\n", | 603 | printf("crit = {%u, %u%%}, warn = {%u, %u%%}\n", |
599 | crit.rta, crit.pl, warn.rta, warn.pl); | 604 | crit.rta, crit.pl, warn.rta, warn.pl); |
@@ -1296,7 +1301,8 @@ print_help(void) | |||
1296 | printf (" %s",_("timeout value (seconds, currently ")); | 1301 | printf (" %s",_("timeout value (seconds, currently ")); |
1297 | printf ("%u)\n", timeout); | 1302 | printf ("%u)\n", timeout); |
1298 | printf (" %s\n", "-b"); | 1303 | printf (" %s\n", "-b"); |
1299 | printf (" %s\n", _("icmp packet size (currenly ignored)")); | 1304 | printf (" %s", _("icmp packet size (bytes, currently ")); |
1305 | printf ("%u)\n", icmp_pkt_size); | ||
1300 | printf (" %s\n", "-v"); | 1306 | printf (" %s\n", "-v"); |
1301 | printf (" %s\n", _("verbose")); | 1307 | printf (" %s\n", _("verbose")); |
1302 | 1308 | ||