summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: feca599)
raw | patch | inline | side by side (parent: feca599)
author | Stefan Völkel <bd@bc-bd.org> | |
Tue, 15 Dec 2009 10:25:58 +0000 (10:25 +0000) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 15 Dec 2009 12:11:42 +0000 (13:11 +0100) |
Any host not replying to consecutive MaxMissed PING packets will get
it's name re-resolved via DNS.
This enables the use of dynamic DNS services (like dyndns.org) with the
ping plugin. Prior to this patch, hostnames were resolved once on daemon
start.
The default is -1 (disabled).
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
it's name re-resolved via DNS.
This enables the use of dynamic DNS services (like dyndns.org) with the
ping plugin. Prior to this patch, hostnames were resolved once on daemon
start.
The default is -1 (disabled).
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/collectd.conf.pod | patch | blob | history | |
src/ping.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 41597edd18ac0ca151670cc7dc88d8d6abf8a788..e2cb799ee1238f2707f5dcf35f7689824681341b 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
interface name (e.E<nbsp>g. C<eth0>). This might not be supported by all
operating systems.
+=item B<MaxMissed> I<Packets>
+
+Trigger a DNS resolv after the host has not replied to I<Packets> packets. This
+enables the use of dynamic DNS services (like dyndns.org) with the ping plugin.
+
+Default: B<-1> (disabled)
+
=back
=head2 Plugin C<postgresql>
diff --git a/src/ping.c b/src/ping.c
index e1540c37d94ca9321a4088c841f9b5c1673e56c7..5366b98fbcc1d309be5b4161c82f5dd9ca23ff85 100644 (file)
--- a/src/ping.c
+++ b/src/ping.c
uint32_t pkg_sent;
uint32_t pkg_recv;
+ uint32_t pkg_missed;
double latency_total;
double latency_squared;
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 int ping_thread_loop = 0;
static int ping_thread_error = 0;
#endif
"TTL",
"Interval",
- "Timeout"
+ "Timeout",
+ "MaxMissed"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
hl->pkg_recv++;
hl->latency_total += latency;
hl->latency_squared += (latency * latency);
- }
+
+ /* reset missed packages counter */
+ hl->pkg_missed = 0;
+ } else
+ hl->pkg_missed++;
+
+ /* if the host did not answer our last N packages, trigger a resolv. */
+ if (ping_max_missed >= 0 && hl->pkg_missed >= ping_max_missed)
+ { /* {{{ */
+ /* we reset the missed package counter here, since we only want to
+ * trigger a resolv every N packages and not every package _AFTER_ N
+ * missed packages */
+ hl->pkg_missed = 0;
+
+ WARNING ("ping plugin: host %s has not answered %d PING requests,"
+ " triggering resolve", hl->host, ping_max_missed);
+
+ /* we trigger the resolv simply be removeing and adding the host to our
+ * ping object */
+ status = ping_host_remove (pingobj, hl->host);
+ if (status != 0)
+ {
+ WARNING ("ping plugin: ping_host_remove (%s) failed.", hl->host);
+ }
+ else
+ {
+ status = ping_host_add (pingobj, hl->host);
+ if (status != 0)
+ WARNING ("ping plugin: ping_host_add (%s) failed.", hl->host);
+ }
+ } /* }}} ping_max_missed */
} /* }}} for (iter) */
if (gettimeofday (&tv_end, NULL) < 0)
hl->host = host;
hl->pkg_sent = 0;
hl->pkg_recv = 0;
+ hl->pkg_missed = 0;
hl->latency_total = 0.0;
hl->latency_squared = 0.0;
hl->next = hostlist_head;
WARNING ("ping plugin: Ignoring invalid timeout %g (%s)",
tmp, value);
}
+ else if (strcasecmp (key, "MaxMissed") == 0)
+ {
+ ping_max_missed = atoi (value);
+ if (ping_max_missed < 0)
+ INFO ("ping plugin: MaxMissed < 0, disabled re-resolving of hosts");
+ }
else
{
return (-1);