X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fping.c;h=084e45683b116f28b15ebeddc11c52f218631160;hb=9b626288aff81c68fe19210a58b4a32eeefde9d3;hp=3c700668ddef5e11be1c05aff34faa88a1633737;hpb=e1b0c447f57338706d45a485b40da7325faa4f34;p=collectd.git diff --git a/src/ping.c b/src/ping.c index 3c700668..084e4568 100644 --- a/src/ping.c +++ b/src/ping.c @@ -1,6 +1,6 @@ /** * collectd - src/ping.c - * Copyright (C) 2005,2006 Florian octo Forster + * Copyright (C) 2005-2007 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -106,15 +106,18 @@ static void add_hosts (void) hl_this = hl_this->next; } } -} +} /* void add_hosts */ static int ping_init (void) { + if (pingobj == NULL) + return (-1); + if (hosts != NULL) add_hosts (); return (0); -} +} /* int ping_init */ static int ping_config (const char *key, const char *value) { @@ -159,7 +162,7 @@ static int ping_config (const char *key, const char *value) else if (strcasecmp (key, "ttl") == 0) { int ttl = atoi (value); - if (ping_setopt (pingobj, PING_DEF_TIMEOUT, (void *) &ttl)) + if (ping_setopt (pingobj, PING_OPT_TTL, (void *) &ttl)) { WARNING ("ping: liboping did not accept the TTL value %i", ttl); return (1); @@ -182,13 +185,13 @@ static void ping_submit (char *host, double latency) vl.values = values; vl.values_len = 1; - vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "ping"); - strcpy (vl.plugin_instance, ""); - strncpy (vl.type_instance, host, sizeof (vl.type_instance)); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "ping", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); + sstrncpy (vl.type_instance, host, sizeof (vl.type_instance)); + sstrncpy (vl.type, "ping", sizeof (vl.type)); - plugin_dispatch_values ("ping", &vl); + plugin_dispatch_values (&vl); } static int ping_read (void) @@ -241,7 +244,7 @@ static int ping_read (void) number_of_hosts++; } - if ((number_of_hosts == 0) && (getuid != 0)) + if ((number_of_hosts == 0) && (getuid () != 0)) { ERROR ("ping plugin: All hosts failed. Try starting collectd as root."); }