X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fnut.c;h=1d1e94b521cc9fdd02a19e58e828ba2c182d3795;hp=2bd4019bb5efdb9b5e126cf01ef890fed63cc8e9;hb=ec51ddee94fa2ba1e01fe0e336ccc9c190a198ff;hpb=88bd89f106abd5c0a9f9a80246e31a16c36a3c6d diff --git a/src/nut.c b/src/nut.c index 2bd4019b..1d1e94b5 100644 --- a/src/nut.c +++ b/src/nut.c @@ -53,11 +53,11 @@ struct nut_ups_s { static const char *config_keys[] = {"UPS", "FORCESSL", "VERIFYPEER", "CAPATH", "CONNECTTIMEOUT"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static int force_ssl = 0; // Initialized to default of 0 (false) -static int verify_peer = 0; // Initialized to default of 0 (false) +static int force_ssl; // Initialized to default of 0 (false) +static int verify_peer; // Initialized to default of 0 (false) static int ssl_flags = UPSCLI_CONN_TRYSSL; static int connect_timeout = -1; -static char *ca_path = NULL; +static char *ca_path; static int nut_read(user_data_t *user_data); @@ -96,13 +96,13 @@ static int nut_add_ups(const char *name) { cb_name = ssnprintf_alloc("nut/%s", name); status = plugin_register_complex_read( - /* group = */ "nut", - /* name = */ cb_name, - /* callback = */ nut_read, - /* interval = */ 0, - /* user_data = */ &(user_data_t){ - .data = ups, .free_func = free_nut_ups_t, - }); + /* group = */ "nut", + /* name = */ cb_name, + /* callback = */ nut_read, + /* interval = */ 0, + /* user_data = */ &(user_data_t){ + .data = ups, .free_func = free_nut_ups_t, + }); sfree(cb_name); @@ -191,10 +191,8 @@ static void nut_submit(nut_ups_t *ups, const char *type, vl.values = &(value_t){.gauge = value}; vl.values_len = 1; - sstrncpy(vl.host, - (strcasecmp(ups->hostname, "localhost") == 0) ? hostname_g - : ups->hostname, - sizeof(vl.host)); + if (strcasecmp(ups->hostname, "localhost") != 0) + sstrncpy(vl.host, ups->hostname, sizeof(vl.host)); sstrncpy(vl.plugin, "nut", sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, ups->upsname, sizeof(vl.plugin_instance)); sstrncpy(vl.type, type, sizeof(vl.type)); @@ -211,8 +209,8 @@ static int nut_connect(nut_ups_t *ups) { tv.tv_sec = connect_timeout / 1000; tv.tv_usec = connect_timeout % 1000; - status = upscli_tryconnect(ups->conn, ups->hostname, ups->port, ssl_flags, - &tv); + status = + upscli_tryconnect(ups->conn, ups->hostname, ups->port, ssl_flags, &tv); #else /* #if HAVE_UPSCLI_TRYCONNECT */ status = upscli_connect(ups->conn, ups->hostname, ups->port, ssl_flags); #endif