Treewide: Don't set value_list_t.host to hostname_g.
authorFlorian Forster <octo@collectd.org>
Wed, 30 Aug 2017 11:32:54 +0000 (13:32 +0200)
committerFlorian Forster <octo@collectd.org>
Wed, 30 Aug 2017 11:32:54 +0000 (13:32 +0200)
plugin_dispatch_values() will automatically fill that value in.

src/curl.c
src/dpdkevents.c
src/dpdkstat.c
src/mic.c
src/nut.c
src/perl.c
src/utils_curl_stats.c
src/utils_tail_match.c

index cc48c77..288c974 100644 (file)
@@ -623,7 +623,7 @@ static int cc_read_page(web_page_t *wp) /* {{{ */
   if (wp->response_time)
     cc_submit_response_time(wp, CDTIME_T_TO_DOUBLE(cdtime() - start));
   if (wp->stats != NULL)
-    curl_stats_dispatch(wp->stats, wp->curl, hostname_g, "curl", wp->instance);
+    curl_stats_dispatch(wp->stats, wp->curl, NULL, "curl", wp->instance);
 
   if (wp->response_code) {
     long response_code = 0;
index efb7694..32d3d6a 100644 (file)
@@ -488,7 +488,6 @@ static void dpdk_events_gauge_submit(const char *plugin_instance,
                      .plugin = DPDK_EVENTS_PLUGIN,
                      .type = "gauge",
                      .meta = NULL};
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
   sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
   plugin_dispatch_values(&vl);
index d36cb8f..c95ba0c 100644 (file)
@@ -373,7 +373,6 @@ static void dpdk_stats_counter_submit(const char *plugin_instance,
   vl.values = &(value_t){.derive = value};
   vl.values_len = 1;
   vl.time = port_read_time;
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, DPDK_STATS_PLUGIN, sizeof(vl.plugin));
   sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
   dpdk_stats_resolve_cnt_type(vl.type, sizeof(vl.type), cnt_name);
index a7ee433..3f9521d 100644 (file)
--- a/src/mic.c
+++ b/src/mic.c
@@ -163,7 +163,6 @@ static void mic_submit_temp(int micnumber, const char *type, gauge_t value) {
   vl.values = &(value_t){.gauge = value};
   vl.values_len = 1;
 
-  strncpy(vl.host, hostname_g, sizeof(vl.host));
   strncpy(vl.plugin, "mic", sizeof(vl.plugin));
   snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%i", micnumber);
   strncpy(vl.type, "temperature", sizeof(vl.type));
@@ -205,7 +204,6 @@ static void mic_submit_cpu(int micnumber, const char *type_instance, int core,
   vl.values = &(value_t){.derive = value};
   vl.values_len = 1;
 
-  strncpy(vl.host, hostname_g, sizeof(vl.host));
   strncpy(vl.plugin, "mic", sizeof(vl.plugin));
   if (core < 0) /* global aggregation */
     snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%i", micnumber);
@@ -259,7 +257,6 @@ static void mic_submit_power(int micnumber, const char *type,
   vl.values = &(value_t){.gauge = value};
   vl.values_len = 1;
 
-  strncpy(vl.host, hostname_g, sizeof(vl.host));
   strncpy(vl.plugin, "mic", sizeof(vl.plugin));
   snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%i", micnumber);
   strncpy(vl.type, type, sizeof(vl.type));
index 2bd4019..58c7d79 100644 (file)
--- 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);
 
@@ -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
index 971fabe..a1ac8d7 100644 (file)
@@ -424,8 +424,6 @@ static int hv2value_list(pTHX_ HV *hash, value_list_t *vl) {
 
   if (NULL != (tmp = hv_fetch(hash, "host", 4, 0)))
     sstrncpy(vl->host, SvPV_nolen(*tmp), sizeof(vl->host));
-  else
-    sstrncpy(vl->host, hostname_g, sizeof(vl->host));
 
   if (NULL != (tmp = hv_fetch(hash, "plugin", 6, 0)))
     sstrncpy(vl->plugin, SvPV_nolen(*tmp), sizeof(vl->plugin));
@@ -2351,25 +2349,14 @@ static int g_interval_set(pTHX_ SV *var, MAGIC *mg) {
   return 0;
 } /* static int g_interval_set (pTHX_ SV *, MAGIC *) */
 
-static MGVTBL g_pv_vtbl = {g_pv_get,
-                           g_pv_set,
-                           NULL,
-                           NULL,
-                           NULL,
-                           NULL,
-                           NULL
+static MGVTBL g_pv_vtbl = {g_pv_get, g_pv_set, NULL, NULL, NULL, NULL, NULL
 #if HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL
                            ,
                            NULL
 #endif
 };
-static MGVTBL g_interval_vtbl = {g_interval_get,
-                                 g_interval_set,
-                                 NULL,
-                                 NULL,
-                                 NULL,
-                                 NULL,
-                                 NULL
+static MGVTBL g_interval_vtbl = {g_interval_get, g_interval_set, NULL, NULL,
+                                 NULL, NULL, NULL
 #if HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL
                                  ,
                                  NULL
index 2a42664..2a1d9de 100644 (file)
@@ -218,15 +218,15 @@ int curl_stats_dispatch(curl_stats_t *s, CURL *curl, const char *hostname,
 
   if (s == NULL)
     return 0;
-  if ((curl == NULL) || (hostname == NULL) || (plugin == NULL)) {
+  if ((curl == NULL) || (plugin == NULL)) {
     ERROR("curl stats: dispatch() called with missing arguments "
-          "(curl=%p; hostname=%s; plugin=%s)",
-          curl, hostname == NULL ? "<NULL>" : hostname,
-          plugin == NULL ? "<NULL>" : plugin);
+          "(curl=%p; plugin=%s)",
+          curl, plugin == NULL ? "<NULL>" : plugin);
     return -1;
   }
 
-  sstrncpy(vl.host, hostname, sizeof(vl.host));
+  if (hostname != NULL)
+    sstrncpy(vl.host, hostname, sizeof(vl.host));
   sstrncpy(vl.plugin, plugin, sizeof(vl.plugin));
   if (plugin_instance != NULL)
     sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
index af8bbe7..242cc38 100644 (file)
@@ -108,7 +108,6 @@ static int latency_submit_match(cu_match_t *match, void *user_data) {
   if (match_value == NULL)
     return -1;
 
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, data->plugin, sizeof(vl.plugin));
   sstrncpy(vl.plugin_instance, data->plugin_instance,
            sizeof(vl.plugin_instance));