X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fapcups.c;h=406c164a2b7e96781093c85b30524e3937d481e2;hp=7c6a47c1b97c5bf1b19ac53206de890d515897a0;hb=7111bb6df7628edce3a8e538b386fbe27633a191;hpb=9655d4a6d9fa2c4f02032759b831e93933d68bd9 diff --git a/src/apcups.c b/src/apcups.c index 7c6a47c1..406c164a 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -421,13 +421,11 @@ static int apcups_read(void) { .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; } @@ -436,8 +434,19 @@ static int apcups_read(void) { 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 */