summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fb075e1)
raw | patch | inline | side by side (parent: fb075e1)
author | Florian Forster <octo@collectd.org> | |
Mon, 8 Jun 2015 10:36:04 +0000 (12:36 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 8 Jun 2015 10:36:04 +0000 (12:36 +0200) |
If set to false, close the connection after each interval. This lets
users chose this method if persistent connections pose a problem.
Fixes: #617
users chose this method if persistent connections pose a problem.
Fixes: #617
src/apcups.c | patch | blob | history | |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history |
diff --git a/src/apcups.c b/src/apcups.c
index 66fe45e119cda0c396da3bbb46e2012de1401687..dc533f1e48eb3b741c2f37eeb6978694ff01aa96 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
static char *conf_service = NULL;
/* Defaults to false for backwards compatibility. */
static _Bool conf_report_seconds = 0;
+static _Bool conf_persistent_conn = 1;
static int global_sockfd = -1;
static int count_retries = 0;
static int count_iterations = 0;
-static _Bool close_socket = 0;
static int net_shutdown (int *fd)
{
"first %i iterations. Will close the socket "
"in future iterations.",
count_retries, count_iterations);
- close_socket = 1;
+ conf_persistent_conn = 0;
}
while ((n = net_recv (&global_sockfd, recvline, sizeof (recvline) - 1)) > 0)
}
status = errno; /* save errno, net_shutdown() may re-set it. */
- if (close_socket)
+ if (!conf_persistent_conn)
net_shutdown (&global_sockfd);
if (n < 0)
cf_util_get_service (child, &conf_service);
else if (strcasecmp (child->key, "ReportSeconds") == 0)
cf_util_get_boolean (child, &conf_report_seconds);
+ else if (strcasecmp (child->key, "PersistentConnection") == 0)
+ cf_util_get_boolean (child, &conf_persistent_conn);
else
ERROR ("apcups plugin: Unknown config option \"%s\".", child->key);
}
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 99f879cc641999cf59e2631a557319c2d3c7b74d..5a4c46741349677692d0fc8ea53f7da80c054b6b 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Host "localhost"
# Port "3551"
# ReportSeconds true
+# PersistentConnection true
#</Plugin>
#<Plugin aquaero>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 1884914f4cb653faf4e9f4d1dde8e7a1a3c3732f..16315ade1ef8d5086a82fbdbb0ef6cf4d9ec9bac 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
TCP-Port to connect to. Defaults to B<3551>.
-=item B<ReportSeconds> B<true|false>
+=item B<ReportSeconds> B<true>|B<false>
If set to B<true>, the time reported in the C<timeleft> metric will be
converted to seconds. This is the recommended setting. If set to B<false>, the
default for backwards compatibility, the time will be reported in minutes.
+=item B<PersistentConnection> B<true>|B<false>
+
+By default, the plugin will try to keep the connection to UPS open between
+reads. Since this appears to be somewhat brittle (I<apcupsd> appears to close
+the connection due to inactivity quite quickly), the plugin will try to detect
+this problem and switch to an open-read-close mode in such cases.
+
+You can instruct the plugin to close the connection after each read by setting
+this option to B<false>.
+
=back
=head2 Plugin C<aquaero>