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 */
=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