X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnut.c;h=58c7d797c4d4d8b93083c97e1223064eb246d892;hb=849f5394cce97a76da080f6cd9e5194b7f4ee0f0;hp=e3820951258f27569e4d8c9da710a3b3b2c2b051;hpb=d83bdb92ce4dbda05dcb7112c4e9fea1a17a3e22;p=collectd.git diff --git a/src/nut.c b/src/nut.c index e3820951..58c7d797 100644 --- a/src/nut.c +++ b/src/nut.c @@ -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); @@ -160,7 +160,7 @@ static int nut_set_connect_timeout(const char *value) { ret = strtol(value, /* endptr = */ NULL, /* base = */ 10); if (errno == 0) connect_timeout = ret; - else + else WARNING("nut plugin: The ConnectTimeout option requires numeric argument. " "Setting ignored."); #else /* #if HAVE_UPSCLI_TRYCONNECT */ @@ -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