From: Pavel Rochnyack Date: Sun, 8 May 2016 08:10:08 +0000 (+0600) Subject: apcups plugin: Change "PersistentConnection" option default value depending on poll... X-Git-Tag: collectd-5.6.0~303^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f1538c3b02b7c3caa080f8a5d4d572cd3f662dd0;p=collectd.git apcups plugin: Change "PersistentConnection" option default value depending on poll Interval. --- diff --git a/src/apcups.c b/src/apcups.c index 8006bd1e..591f6acd 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -378,6 +378,7 @@ static int apc_query_server (char const *node, char const *service, static int apcups_config (oconfig_item_t *ci) { int i; + _Bool persistent_conn_set = 0; for (i = 0; i < ci->children_num; i++) { @@ -389,12 +390,25 @@ static int apcups_config (oconfig_item_t *ci) 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 43dfeaec..23af31ad 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -834,13 +834,15 @@ default for backwards compatibility, the time will be reported in minutes. =item B B|B -By default, the plugin will try to keep the connection to UPS open between -reads. Since this appears to be somewhat brittle (I 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 open between reads. +If plugin poll interval is greater than 15 seconds (hardcoded socket close +timeout in I NIS), then this option is B by default. You can instruct the plugin to close the connection after each read by setting -this option to B. +this option to B or force keeping the connection by setting it to B. + +If I 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