summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 867ad62)
raw | patch | inline | side by side (parent: 867ad62)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Fri, 7 Jul 2017 17:56:23 +0000 (00:56 +0700) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Fri, 7 Jul 2017 17:56:23 +0000 (00:56 +0700) |
Previously the apcups plugin could not be used without defining
an explicit configuration.
While the apcups plugin did provide a localhost fallback, it
did not however provide a 3551 port fallback in practice,
eventhough a constant for that purpose was already present.
Thanks to Pascal de Bruijn for report.
Closes: #2347
an explicit configuration.
While the apcups plugin did provide a localhost fallback, it
did not however provide a 3551 port fallback in practice,
eventhough a constant for that purpose was already present.
Thanks to Pascal de Bruijn for report.
Closes: #2347
src/apcups.c | patch | blob | history |
diff --git a/src/apcups.c b/src/apcups.c
index 7c6a47c1b97c5bf1b19ac53206de890d515897a0..406c164a2b7e96781093c85b30524e3937d481e2 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
.linefreq = NAN,
};
- int status =
- apc_query_server(conf_node == NULL ? APCUPS_DEFAULT_NODE : conf_node,
- conf_service, &apcups_detail);
+ int status = apc_query_server(conf_node, conf_service, &apcups_detail);
+
if (status != 0) {
DEBUG("apcups plugin: apc_query_server (\"%s\", \"%s\") = %d",
- conf_node == NULL ? APCUPS_DEFAULT_NODE : conf_node, conf_service,
- status);
+ conf_node, conf_service, status);
return status;
}
return 0;
} /* apcups_read */
+static int apcups_init(void) {
+ if (conf_node == NULL)
+ conf_node = APCUPS_DEFAULT_NODE;
+
+ if (conf_service == NULL)
+ conf_service = APCUPS_DEFAULT_SERVICE;
+
+ return 0;
+} /* apcups_init */
+
void module_register(void) {
plugin_register_complex_config("apcups", apcups_config);
+ plugin_register_init("apcups", apcups_init);
plugin_register_read("apcups", apcups_read);
plugin_register_shutdown("apcups", apcups_shutdown);
} /* void module_register */