From: octo Date: Sat, 1 Apr 2006 20:42:55 +0000 (+0000) Subject: Applied the TTL-patch for the ping plugin. X-Git-Tag: liboping-0.1.0~136 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=86d01078e065197bf9056077df34bd5beab33e8a;p=collectd.git Applied the TTL-patch for the ping plugin. --- diff --git a/ChangeLog b/ChangeLog index 2e086093..c980d16b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ * An option to compile collectd with different `step' and `hearbeat' settings has been added. The size of RRAs is no longer static but calculated based on the settings for `step' and `width'. + * The `ping' plugin can now be configured to use a certain TTL. 2006-03-14, Version 3.8.2 * `utils_mount.c' has been changed to not use the `MNTTAB' defined by diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 4920460e..64c66548 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -170,6 +170,10 @@ option for what this plugin does. Host to ping periodically. This option may be repeated several times to ping multiple hosts. +=item B I<0-255> + +Sets the Time-To-Live of generated ICMP packets. + =back =head1 SEE ALSO diff --git a/src/ping.c b/src/ping.c index f18ea8cc..69661708 100644 --- a/src/ping.c +++ b/src/ping.c @@ -45,9 +45,10 @@ static int ds_num = 1; static char *config_keys[] = { "Host", + "TTL", NULL }; -static int config_keys_num = 1; +static int config_keys_num = 2; static void ping_init (void) { @@ -56,23 +57,35 @@ static void ping_init (void) static int ping_config (char *key, char *value) { - if (strcasecmp (key, "host")) - { - return (-1); - } - if (pingobj == NULL) { if ((pingobj = ping_construct ()) == NULL) { syslog (LOG_ERR, "ping: `ping_construct' failed.\n"); - return (-1); + return (1); } } - if (ping_host_add (pingobj, value) < 0) + if (strcasecmp (key, "host") == 0) { - syslog (LOG_WARNING, "ping: `ping_host_add' failed.\n"); + if (ping_host_add (pingobj, value) < 0) + { + syslog (LOG_WARNING, "ping: `ping_host_add' failed."); + return (1); + } + } + else if (strcasecmp (key, "ttl") == 0) + { + int ttl = atoi (value); + if (ping_setopt (pingobj, PING_DEF_TIMEOUT, (void *) &ttl)) + { + syslog (LOG_WARNING, "ping: liboping did not accept the TTL value %i", ttl); + return (1); + } + } + else + { + return (-1); } return (0);