summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 309145f)
raw | patch | inline | side by side (parent: 309145f)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Sun, 8 May 2016 08:10:08 +0000 (14:10 +0600) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Sun, 8 May 2016 08:10:08 +0000 (14:10 +0600) |
src/apcups.c | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history |
diff --git a/src/apcups.c b/src/apcups.c
index 8006bd1edac61ad8c5f14a53c87102cdd6650d2f..591f6acd652b092db8a9332acb868d91d5e2f08a 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
static int apcups_config (oconfig_item_t *ci)
{
int i;
+ _Bool persistent_conn_set = 0;
for (i = 0; i < ci->children_num; i++)
{
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)
+ else if (strcasecmp (child->key, "PersistentConnection") == 0) {
cf_util_get_boolean (child, &conf_persistent_conn);
+ persistent_conn_set = 1;
+ }
else
ERROR ("apcups plugin: Unknown config option \"%s\".", child->key);
}
+ if (!persistent_conn_set) {
+ double interval = CDTIME_T_TO_DOUBLE(plugin_get_interval());
+ if (interval > 15.0) {
+ NOTICE ("apcups plugin: Plugin poll interval set to %.3f seconds. "
+ "Apcupsd NIS socket timeout is 15 seconds, "
+ "PersistentConnection disabled by default.",
+ interval);
+ conf_persistent_conn = 0;
+ }
+ }
+
return (0);
} /* int apcups_config */
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 43dfeaecd4e43cd1f3e14c3e62cdeecce4eec195..23af31ad1b60941511374bc466e3830a72844946 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=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.
+The plugin is designed to keep the connection to I<apcupsd> open between reads.
+If plugin poll interval is greater than 15 seconds (hardcoded socket close
+timeout in I<apcupsd> NIS), then this option is B<false> by default.
You can instruct the plugin to close the connection after each read by setting
-this option to B<false>.
+this option to B<false> or force keeping the connection by setting it to B<true>.
+
+If 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.
=back