Revision: 2026
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2026&view=rev
Author: psychotrahe
Date: 2008-07-17 07:06:33 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Add support for packet size modification (-b)
Modified Paths:
--------------
nagiosplug/trunk/NEWS
nagiosplug/trunk/plugins-root/check_icmp.c
Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS 2008-07-10 10:03:55 UTC (rev 2025)
+++ nagiosplug/trunk/NEWS 2008-07-17 07:06:33 UTC (rev 2026)
@@ -8,6 +8,7 @@
check_dig now returns CRITICAL instead of WARNING when no answer section is found
check_procs now captures stderr in external command and adds to plugin output
check_snmp now only prints perfdata for non numeric values (#1867716)
+ check_icmp now supports packet size modification
1.4.12 27th May 2008
Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren)
Modified: nagiosplug/trunk/plugins-root/check_icmp.c
===================================================================
--- nagiosplug/trunk/plugins-root/check_icmp.c 2008-07-10 10:03:55 UTC (rev 2025)
+++ nagiosplug/trunk/plugins-root/check_icmp.c 2008-07-17 07:06:33 UTC (rev 2026)
@@ -203,7 +203,9 @@
static struct rta_host **table, *cursor, *list;
static threshold crit = {80, 500000}, warn = {40, 200000};
static int mode, protocols, sockets, debug = 0, timeout = 10;
-static unsigned short icmp_pkt_size, icmp_data_size = DEFAULT_PING_DATA_SIZE;
+static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE;
+static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN;
+
static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0;
#define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost))
static unsigned short targets_down = 0, targets = 0, packets = 0;
@@ -453,12 +455,22 @@
/* parse the arguments */
for(i = 1; i < argc; i++) {
while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) {
+ long size;
switch(arg) {
case 'v':
debug++;
break;
case 'b':
- /* silently ignored for now */
+ size = strtol(optarg,NULL,0);
+ if (size >= (sizeof(struct icmp) + sizeof(struct icmp_ping_data)) &&
+ size <= MAX_PING_DATA + ICMP_MINLEN) {
+ icmp_pkt_size = size;
+ icmp_data_size = icmp_pkt_size - ICMP_MINLEN;
+ } else
+ usage_va("ICMP packet size must be between: %d and %d",
+ sizeof(struct icmp) + sizeof(struct icmp_ping_data),
+ MAX_PING_DATA + ICMP_MINLEN);
+
break;
case 'i':
pkt_interval = get_timevar(optarg);
@@ -587,13 +599,6 @@
}
}
- icmp_pkt_size = icmp_data_size + ICMP_MINLEN;
- if(debug > 2) printf("icmp_pkt_size = %u\n", icmp_pkt_size);
- if(icmp_pkt_size < sizeof(struct icmp) + sizeof(struct icmp_ping_data)) {
- icmp_pkt_size = sizeof(struct icmp) + sizeof(struct icmp_ping_data);
- }
- if(debug > 2) printf("icmp_pkt_size = %u\n", icmp_pkt_size);
-
if(debug) {
printf("crit = {%u, %u%%}, warn = {%u, %u%%}\n",
crit.rta, crit.pl, warn.rta, warn.pl);
@@ -1296,7 +1301,8 @@
printf (" %s",_("timeout value (seconds, currently "));
printf ("%u)\n", timeout);
printf (" %s\n", "-b");
- printf (" %s\n", _("icmp packet size (currenly ignored)"));
+ printf (" %s", _("icmp packet size (bytes, currently "));
+ printf ("%u)\n", icmp_pkt_size);
printf (" %s\n", "-v");
printf (" %s\n", _("verbose"));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.