[collectd] [PATCH] Add a Data option to the ping plugin to specify arbitrary payloads for differing ping packet sizes.
Andrew O'Brien
andrewo at oriel.com.au
Thu Jan 2 02:05:30 CET 2014
For example:
<Plugin ping>
Host "host.baz.qux"
Interval 1.0
Timeout 0.9
#TTL 255
#SourceAddress "1.2.3.4"
#Device "eth0"
#MaxMissed -1
Data "Some arbitrary text here - By default a 56 byte long string is used so that the packet size of an ICMPv4 packet is exactly 64 bytes."
</Plugin
Signed-off-by: Andrew OBrien <andrewo at foic.net>
---
src/ping.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/ping.c b/src/ping.c
index 8bbb807..ff6cd8a 100644
--- a/src/ping.c
+++ b/src/ping.c
@@ -72,6 +72,7 @@ static int ping_ttl = PING_DEF_TTL;
static double ping_interval = 1.0;
static double ping_timeout = 0.9;
static int ping_max_missed = -1;
+static char *ping_data = NULL;
static int ping_thread_loop = 0;
static int ping_thread_error = 0;
@@ -89,7 +90,8 @@ static const char *config_keys[] =
"TTL",
"Interval",
"Timeout",
- "MaxMissed"
+ "MaxMissed",
+ "Data",
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
@@ -273,6 +275,7 @@ static void *ping_thread (void *arg) /* {{{ */
ping_setopt (pingobj, PING_OPT_TIMEOUT, (void *) &ping_timeout);
ping_setopt (pingobj, PING_OPT_TTL, (void *) &ping_ttl);
+ ping_setopt (pingobj, PING_OPT_DATA, (void *) ping_data);
/* Add all the hosts to the ping object. */
count = 0;
@@ -548,6 +551,12 @@ static int ping_config (const char *key, const char *value) /* {{{ */
if (ping_max_missed < 0)
INFO ("ping plugin: MaxMissed < 0, disabled re-resolving of hosts");
}
+ else if (strcasecmp (key, "Data") == 0)
+ {
+ int status = config_set_string (key, &ping_data, value);
+ if (status != 0)
+ return (status);
+ }
else
{
return (-1);
--
1.7.10.4
More information about the collectd
mailing list