]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Various: s/metric_t/metric_single_t/g
authorFlorian Forster <octo@google.com>
Fri, 17 Jul 2020 11:08:51 +0000 (13:08 +0200)
committerFlorian Forster <octo@google.com>
Wed, 29 Jul 2020 11:40:03 +0000 (13:40 +0200)
13 files changed:
src/aggregation.c
src/amqp.c
src/amqp1.c
src/check_uptime.c
src/grpc.cc
src/perl.c
src/pyvalues.c
src/snmp_agent.c
src/threshold.c
src/write_graphite.c
src/write_http.c
src/write_kafka.c
src/write_redis.c

index 23d259caabaeda11777f8a78e386652aa9057477..c3e9c5299b6b2e93a317961b8237585b22e8b1c0 100644 (file)
@@ -715,12 +715,12 @@ static int agg_read(void) /* {{{ */
   return (success > 0) ? 0 : -1;
 } /* }}} int agg_read */
 
-static int agg_write(metric_t const *metric_p, /* {{{ */
+static int agg_write(metric_single_t const *m, /* {{{ */
                      __attribute__((unused)) user_data_t *user_data) {
   bool created_by_aggregation = false;
   /* Ignore values that were created by the aggregation plugin to avoid weird
    * effects. */
-  (void)meta_data_get_boolean(metric_p->meta->meta, "aggregation:created",
+  (void)meta_data_get_boolean(m->meta->meta, "aggregation:created",
                               &created_by_aggregation);
   if (created_by_aggregation)
     return 0;
@@ -730,7 +730,7 @@ static int agg_write(metric_t const *metric_p, /* {{{ */
   if (lookup == NULL)
     status = ENOENT;
   else {
-    status = lookup_search(lookup, metric_p);
+    status = lookup_search(lookup, m);
     if (status > 0)
       status = 0;
   }
index 8405bc02763cec994c0d6d42f2bca0cee8453b21..91c11ffa7abfc012b2879b21468a48f9b73db1d9 100644 (file)
@@ -29,9 +29,9 @@
 #include "collectd.h"
 
 #include "plugin.h"
+#include "utils/avltree/avltree.h"
 #include "utils/cmds/putval.h"
 #include "utils/common/common.h"
-#include "utils/avltree/avltree.h"
 #include "utils/format_graphite/format_graphite.h"
 #include "utils/format_json/format_json.h"
 #include "utils_random.h"
@@ -788,7 +788,7 @@ static int camqp_write_locked(camqp_config_t *conf, /* {{{ */
   return status;
 } /* }}} int camqp_write_locked */
 
-static int camqp_write(const metric_t *metric_p, /* {{{ */
+static int camqp_write(metric_single_t const *m, /* {{{ */
                        user_data_t *user_data) {
   camqp_config_t *conf = user_data->data;
   char routing_key[6 * DATA_MAX_NAME_LEN];
@@ -796,7 +796,7 @@ static int camqp_write(const metric_t *metric_p, /* {{{ */
   int status;
   char *index_p = (char *)&buffer[0];
 
-  if ((metric_p == NULL) || (metric_p->ds == NULL) || (conf == NULL))
+  if ((m == NULL) || (metric_p->ds == NULL) || (conf == NULL))
     return EINVAL;
 
   if (conf->routing_key != NULL) {
@@ -804,15 +804,15 @@ static int camqp_write(const metric_t *metric_p, /* {{{ */
   } else {
     int buffer_size = sizeof(routing_key);
     int tmp_str_len = 0;
-    tmp_str_len = strlen(metric_p->identity->name);
+    tmp_str_len = strlen(m->identity->name);
     if (tmp_str_len < buffer_size) {
-      snprintf(index_p, tmp_str_len + 1, "%s", metric_p->identity->name);
+      snprintf(index_p, tmp_str_len + 1, "%s", m->identity->name);
       index_p += tmp_str_len; /* This is the location of the trailing nul */
       buffer_size -= tmp_str_len;
     }
 
-    if (metric_p->identity->root_p != NULL) {
-      c_avl_iterator_t *iter_p = c_avl_get_iterator(metric_p->identity->root_p);
+    if (m->identity->root_p != NULL) {
+      c_avl_iterator_t *iter_p = c_avl_get_iterator(m->identity->root_p);
       if (iter_p != NULL) {
         char *key_p = NULL;
         char *value_p = NULL;
@@ -826,8 +826,8 @@ static int camqp_write(const metric_t *metric_p, /* {{{ */
               buffer_size -= tmp_str_len;
             } else {
               snprintf(index_p, buffer_size, ";%s", value_p);
-             buffer_size = 0;
-             break;
+              buffer_size = 0;
+              break;
             }
           }
         }
@@ -846,7 +846,7 @@ static int camqp_write(const metric_t *metric_p, /* {{{ */
   }
 
   if (conf->format == CAMQP_FORMAT_COMMAND) {
-    status = cmd_create_putval(buffer, sizeof(buffer), metric_p);
+    status = cmd_create_putval(buffer, sizeof(buffer), m);
     if (status != 0) {
       ERROR("amqp plugin: cmd_create_putval failed with status %i.", status);
       return status;
@@ -856,12 +856,12 @@ static int camqp_write(const metric_t *metric_p, /* {{{ */
     size_t bfill = 0;
 
     format_json_initialize(buffer, &bfill, &bfree);
-    format_json_metric(buffer, &bfill, &bfree, metric_p, conf->store_rates);
+    format_json_metric(buffer, &bfill, &bfree, m, conf->store_rates);
     format_json_finalize(buffer, &bfill, &bfree);
   } else if (conf->format == CAMQP_FORMAT_GRAPHITE) {
     status =
-        format_graphite(buffer, sizeof(buffer), metric_p, conf->prefix,
-                        conf->postfix, conf->escape_char, conf->graphite_flags);
+        format_graphite(buffer, sizeof(buffer), m, conf->prefix, conf->postfix,
+                        conf->escape_char, conf->graphite_flags);
     if (status != 0) {
       ERROR("amqp plugin: format_graphite failed with status %i.", status);
       return status;
index 20e7cc543bb7a1b9d06d1d3ed7d2d6ec5920b6cf..67ac5fca9a6c556fbe3cc93727c225a157bf1224 100644 (file)
@@ -430,7 +430,7 @@ static int amqp1_notify(notification_t const *n,
 
 } /* }}} int amqp1_notify */
 
-static int amqp1_write(const metric_t *metric_p, /* {{{ */
+static int amqp1_write(metric_single_t const *m, /* {{{ */
                        user_data_t *user_data) {
   int status = 0;
   size_t bfree = BUFSIZE;
@@ -479,8 +479,8 @@ static int amqp1_write(const metric_t *metric_p, /* {{{ */
     break;
   case AMQP1_FORMAT_JSON:
     format_json_initialize((char *)cdm->mbuf.start, &bfill, &bfree);
-    format_json_metric((char *)cdm->mbuf.start, &bfill, &bfree, metric_p,
-                           instance->store_rates);
+    format_json_metric((char *)cdm->mbuf.start, &bfill, &bfree, m,
+                       instance->store_rates);
     status = format_json_finalize((char *)cdm->mbuf.start, &bfill, &bfree);
     if (status != 0) {
       ERROR("amqp1 plugin: format_json_finalize failed with status %i.",
index e877505bcc4b7a90b3d9535b7fa85d8aca981290..dd7dc1a28ec6ae92a9808b7ff8d3b8a0f8e4e23e 100644 (file)
@@ -54,19 +54,20 @@ static int format_uptime(unsigned long uptime_sec, char *buf, size_t bufsize) {
   return ret;
 }
 
-static int cu_notify(enum cache_event_type_e event_type, const metric_t *metric_p,
-                     gauge_t old_uptime, gauge_t new_uptime) {
+static int cu_notify(enum cache_event_type_e event_type,
+                     metric_single_t const *m, gauge_t old_uptime,
+                     gauge_t new_uptime) {
   notification_t n;
-  notification_init_metric(&n, NOTIF_FAILURE, NULL, metric_p);
+  notification_init_metric(&n, NOTIF_FAILURE, NULL, m);
 
   int status;
   char *buf = n.message;
   size_t bufsize = sizeof(n.message);
 
-  n.time = metric_p->time;
+  n.time = m->time;
 
   const char *service = "Service";
-  if (strcmp(metric_p->plugin, "uptime") == 0)
+  if (strcmp(m->plugin, "uptime") == 0)
     service = "Host";
 
   switch (event_type) {
@@ -132,10 +133,10 @@ static int cu_cache_event(cache_event_t *event,
   switch (event->type) {
   case CE_VALUE_NEW:
     DEBUG("check_uptime: CE_VALUE_NEW, %s", event->value_list_name);
-    if (c_avl_get(types_tree, event->metric_p->type, NULL) == 0) {
+    if (c_avl_get(types_tree, event->m->type, NULL) == 0) {
       event->ret = 1;
-      cu_notify(CE_VALUE_NEW, event->metric_p, NAN /* old */,
-                event->metric_p->value.gauge /* new */);
+      cu_notify(CE_VALUE_NEW, event->m, NAN /* old */,
+                event->m->value.gauge /* new */);
     }
     break;
   case CE_VALUE_UPDATE:
@@ -146,8 +147,8 @@ static int cu_cache_event(cache_event_t *event,
     } else {
       if (!isnan(values_history[0]) && !isnan(values_history[1]) &&
           values_history[0] < values_history[1]) {
-        cu_notify(CE_VALUE_UPDATE, event->metric_p,
-                  values_history[1] /* old */, values_history[0] /* new */);
+        cu_notify(CE_VALUE_UPDATE, event->m, values_history[1] /* old */,
+                  values_history[0] /* new */);
       }
     }
     break;
@@ -158,7 +159,7 @@ static int cu_cache_event(cache_event_t *event,
       old_uptime = value.gauge;
     }
 
-    cu_notify(CE_VALUE_EXPIRED, event->metric_p, old_uptime, NAN /* new */);
+    cu_notify(CE_VALUE_EXPIRED, event->m, old_uptime, NAN /* new */);
     break;
   }
   return 0;
index 522fe97bd8a671376a0bd4f26c49e5a650860736..d07acc82c3ccd93ee72a8207346ce82c7f8fc669 100644 (file)
@@ -40,9 +40,9 @@ extern "C" {
 #include <fnmatch.h>
 #include <stdbool.h>
 
+#include "collectd.h"
 #include "plugin.h"
 #include "utils/common/common.h"
-#include "collectd.h"
 
 #include "daemon/utils_cache.h"
 }
@@ -76,7 +76,8 @@ static grpc::string default_addr("0.0.0.0:50051");
  * helper functions
  */
 
-static bool ident_matches(const metric_t *vl, const metric_t *matcher) {
+static bool ident_matches(metric_single_t const *vl,
+                          const metric_single_t *matcher) {
   if (fnmatch(matcher->host, vl->host, 0))
     return false;
 
index bf9c87f1517a9b1355718a556a8f5f123e9daf3a..c1823c298dab52110d483492473f858e076420e5 100644 (file)
@@ -33,8 +33,8 @@
 /* do not automatically get the thread specific Perl interpreter */
 #define PERL_NO_GET_CONTEXT
 
-#include <stdbool.h>
 #include "collectd.h"
+#include <stdbool.h>
 
 #include <EXTERN.h>
 #include <perl.h>
@@ -115,7 +115,7 @@ static XS(Collectd__fc_register);
 static XS(Collectd_call_by_name);
 
 static int perl_read(user_data_t *ud);
-static int perl_write(const metric_t *metric_p, user_data_t *user_data);
+static int perl_write(metric_single_t const *m, user_data_t *user_data);
 static void perl_log(int level, const char *msg, user_data_t *user_data);
 static int perl_notify(const notification_t *notif, user_data_t *user_data);
 static int perl_flush(cdtime_t timeout, const char *identifier,
@@ -347,27 +347,26 @@ static size_t av2value(pTHX_ char *name, AV *array, value_t *value,
   return ds->ds_num;
 } /* static size_t av2value (char *, AV *, value_t *, size_t) */
 
-static int hv2metric_list(pTHX_ HV *hash, metric_t *metric_p) {
-  if ((NULL == hash) || (NULL == metric_p))
+static int hv2metric_list(pTHX_ HV *hash, metric_single_t *m) {
+  if ((NULL == hash) || (NULL == m))
     return -1;
   SV **tmp = av_fetch(array, 0, 0);
 
   if (NULL != tmp) {
-    if (DS_TYPE_COUNTER == metric_p->value_type)
-      metric_p->value.counter = SvIV(*tmp);
-    else if (DS_TYPE_GAUGE == metric_p->value_type)
-      metric_p->value.gauge = SvNV(*tmp);
-    else if (DS_TYPE_DERIVE == metric_p->value_type)
-      metric_p->value.derive = SvIV(*tmp);
-    else if (DS_TYPE_ABSOLUTE == metric_p->value_type)
-      metric_p->value.absolute = SvIV(*tmp);
+    if (DS_TYPE_COUNTER == m->value_type)
+      m->value.counter = SvIV(*tmp);
+    else if (DS_TYPE_GAUGE == m->value_type)
+      m->value.gauge = SvNV(*tmp);
+    else if (DS_TYPE_DERIVE == m->value_type)
+      m->value.derive = SvIV(*tmp);
+    else if (DS_TYPE_ABSOLUTE == m->value_type)
+      m->value.absolute = SvIV(*tmp);
   } else {
     return 0;
   }
   return 1;
 }
 
-
 /*
  * value list:
  * {
@@ -2133,8 +2132,7 @@ static int perl_read(user_data_t *user_data) {
   return pplugin_call(aTHX_ PLUGIN_READ, user_data->data);
 } /* static int perl_read (user_data_t *user_data) */
 
-static int perl_write(const metric_t *metric_p,
-                      user_data_t *user_data) {
+static int perl_write(metric_single_t const *m, user_data_t *user_data) {
   int status;
   dTHX;
 
@@ -2159,7 +2157,7 @@ static int perl_write(const metric_t *metric_p,
 
   log_debug("perl_write: c_ithread: interp = %p (active threads: %i)", aTHX,
             perl_threads->number_of_threads);
-  status = pplugin_call(aTHX_ PLUGIN_WRITE, user_data->data, metric_p);
+  status = pplugin_call(aTHX_ PLUGIN_WRITE, user_data->data, m);
 
   if (aTHX == perl_threads->head->interp)
     pthread_mutex_unlock(&perl_threads->mutex);
index 8d52b6a0a8fb5551edd68153810c25c953fdade1..12e2ffb03c44b54cf40d6b5c74a2d2ed0de05c2c 100644 (file)
@@ -710,25 +710,24 @@ static PyObject *Values_write(Values *self, PyObject *args, PyObject *kwds) {
   int ret;
   const data_set_t *ds;
   size_t size;
-  metric_t metric = STRUCT_METRIC_INIT;
+  metric_single_t metric = STRUCT_METRIC_INIT;
   PyObject *values = self->values, *meta = self->meta;
   double time = self->data.time, interval = self->interval;
-  char *host = NULL, *plugin = NULL, *type = NULL,
-       *data_source = NULL, *dest = NULL;
+  char *host = NULL, *plugin = NULL, *type = NULL, *data_source = NULL,
+       *dest = NULL;
 
-  static char *kwlist[] = {
-    "destination",   "type",   "values",
-      "dat_source", "plugin", "host",   "time",
-      "interval",      "meta",   NULL};
+  static char *kwlist[] = {"destination", "type", "values", "dat_source",
+                           "plugin",      "host", "time",   "interval",
+                           "meta",        NULL};
   if (!PyArg_ParseTupleAndKeywords(
           args, kwds, "et|etOetetetetdiO", kwlist, NULL, &dest, NULL, &type,
           &values, NULL, &plugin_instance, NULL, &type_instance, NULL, &plugin,
           NULL, &host, &time, &interval, &meta))
     return NULL;
 
-  metric.identity = identity_create_legacy((plugin ? plugin : self->data.plugin),
-                                    (type ? type : self->data.type),
-                                    (host ? host : self->data.host));
+  metric.identity = identity_create_legacy(
+      (plugin ? plugin : self->data.plugin), (type ? type : self->data.type),
+      (host ? host : self->data.host));
 
   sstrncpy(value_list.host, host ? host : self->data.host,
            sizeof(value_list.host));
index 8339cb45126f1ee02c77e8201da7d872a250d6aa..08006e4bba91965d24bb4b04281a06ccaef06ea4 100644 (file)
 
 #include "collectd.h"
 
-#include <regex.h>
 #include "utils/avltree/avltree.h"
 #include "utils/common/common.h"
 #include "utils_cache.h"
 #include "utils_llist.h"
+#include <regex.h>
 
 #include <net-snmp/net-snmp-config.h>
 
@@ -481,7 +481,7 @@ static int snmp_agent_tokenize(const char *input, c_avl_tree_t *tokens,
 }
 
 static int snmp_agent_fill_index_list(table_definition_t *td,
-                                      metric_t const *metric_p) {
+                                      metric_single_t const *m) {
   int ret;
   int i;
   netsnmp_variable_list *key = td->index_list_cont;
@@ -497,8 +497,8 @@ static int snmp_agent_fill_index_list(table_definition_t *td,
     /* Generating list filled with all data necessary to generate an OID */
     switch (source) {
     case INDEX_HOST:
-      ret = c_avl_get(metric_p->identity->root_p, (void *)"__host__",
-                      (void **)&host_p);
+      ret =
+          c_avl_get(m->identity->root_p, (void *)"__host__", (void **)&host_p);
       if (ret != 0) {
         ERROR(PLUGIN_NAME ": Unknown index key resource host");
         return -EINVAL;
@@ -506,13 +506,13 @@ static int snmp_agent_fill_index_list(table_definition_t *td,
       ptr = host_p;
       break;
     case INDEX_PLUGIN:
-      ptr = metric_p->plugin;
+      ptr = m->plugin;
       break;
     case INDEX_TYPE:
-      ptr = metric_p->type;
+      ptr = m->type;
       break;
     case INDEX_DATA_SOURCE:
-      ptr = metric_p->ds->name;
+      ptr = m->ds->name;
       break;
     default:
       ERROR(PLUGIN_NAME ": Unknown index key source provided");
@@ -595,13 +595,13 @@ static int snmp_agent_prep_index_list(table_definition_t const *td,
 }
 
 static int snmp_agent_generate_index(table_definition_t *td,
-                                     metric_t const *metric_p,
+                                     metric_single_t const *m,
                                      oid_t *index_oid) {
 
   /* According to given information by index_keys list
    * index OID is going to be built
    */
-  int ret = snmp_agent_fill_index_list(td, metric_p);
+  int ret = snmp_agent_fill_index_list(td, m);
   if (ret != 0)
     return -EINVAL;
 
@@ -760,9 +760,9 @@ static void snmp_agent_table_data_remove(data_definition_t *dd,
   }
 }
 
-static int snmp_agent_clear_missing(const metric_t *metric_p,
+static int snmp_agent_clear_missing(metric_single_t const *m,
                                     __attribute__((unused)) user_data_t *ud) {
-  if (metric_p == NULL)
+  if (m == NULL)
     return -EINVAL;
 
   for (llentry_t *te = llist_head(g_agent->tables); te != NULL; te = te->next) {
@@ -772,8 +772,7 @@ static int snmp_agent_clear_missing(const metric_t *metric_p,
       data_definition_t *dd = de->value;
 
       if (!dd->is_index_key) {
-        if (CHECK_DD_TYPE(dd, metric_p->plugin, metric_p->type,
-                          metric_p->ds->name)) {
+        if (CHECK_DD_TYPE(dd, m->plugin, metric_p->type, m->ds->name)) {
           oid_t *index_oid = calloc(1, sizeof(*index_oid));
 
           if (index_oid == NULL) {
@@ -781,7 +780,7 @@ static int snmp_agent_clear_missing(const metric_t *metric_p,
             return -ENOMEM;
           }
 
-          int ret = snmp_agent_generate_index(td, metric_p, index_oid);
+          int ret = snmp_agent_generate_index(td, m, index_oid);
 
           if (ret == 0)
             snmp_agent_table_data_remove(dd, td, index_oid);
@@ -995,8 +994,7 @@ static int snmp_agent_format_name(char *name, int name_len,
     int i = 0;
     netsnmp_variable_list *key = td->index_list_cont;
     char str[DATA_MAX_NAME_LEN];
-    char *fields[MAX_KEY_SOURCES] = {hostname_g, dd->plugin,
-                                     dd->type,
+    char *fields[MAX_KEY_SOURCES] = {hostname_g, dd->plugin, dd->type,
                                      dd->data_source};
 
     /* Looking for simple keys only */
@@ -1028,7 +1026,7 @@ static int snmp_agent_format_name(char *name, int name_len,
         return ret;
     }
     snprintf(name, name_len, fields[INDEX_HOST], fields[INDEX_PLUGIN],
-            fields[INDEX_TYPE],fields[INDEX_DATA_SOURCE]);
+             fields[INDEX_TYPE], fields[INDEX_DATA_SOURCE]);
     for (i = 0; i < MAX_KEY_SOURCES; i++) {
       if (td->tokens[i])
         sfree(fields[i]);
@@ -2011,8 +2009,8 @@ error:
   return ret;
 }
 
-static int snmp_agent_write(metric_t const *metric_p) {
-  if (metric_p == NULL)
+static int snmp_agent_write(metric_single_t const *m) {
+  if (m == NULL)
     return -EINVAL;
 
   for (llentry_t *te = llist_head(g_agent->tables); te != NULL; te = te->next) {
@@ -2022,8 +2020,7 @@ static int snmp_agent_write(metric_t const *metric_p) {
       data_definition_t *dd = de->value;
 
       if (!dd->is_index_key) {
-        if (CHECK_DD_TYPE(dd, metric_p->plugin, metric_p->type,
-                          metric_p->ds->name)) {
+        if (CHECK_DD_TYPE(dd, m->plugin, metric_p->type, m->ds->name)) {
           oid_t *index_oid = calloc(1, sizeof(*index_oid));
           bool free_index_oid = true;
 
@@ -2032,7 +2029,7 @@ static int snmp_agent_write(metric_t const *metric_p) {
             return -ENOMEM;
           }
 
-          int ret = snmp_agent_generate_index(td, metric_p, index_oid);
+          int ret = snmp_agent_generate_index(td, m, index_oid);
 
           if (ret == 0)
             ret = snmp_agent_update_index(dd, td, index_oid, &free_index_oid);
@@ -2050,12 +2047,12 @@ static int snmp_agent_write(metric_t const *metric_p) {
   return 0;
 }
 
-static int snmp_agent_collect(const metric_t *metric_p,
+static int snmp_agent_collect(metric_single_t const *m,
                               user_data_t __attribute__((unused)) * user_data) {
 
   pthread_mutex_lock(&g_agent->lock);
 
-  snmp_agent_write(metric_p);
+  snmp_agent_write(m);
 
   pthread_mutex_unlock(&g_agent->lock);
 
index ba940e8f132ff9f89c6f00b70ca894a1ca354bb7..210fe72272da968c854ada95595fc09c4c8acef5 100644 (file)
@@ -275,7 +275,7 @@ static int ut_config_host(const threshold_t *th_orig, oconfig_item_t *ci) {
  * if appropriate.
  * Does not fail.
  */
-static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
+static int ut_report_state(metric_single_t const *m, const threshold_t *th,
                            const gauge_t value, int state) { /* {{{ */
   int state_old;
   notification_t n;
@@ -287,22 +287,22 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
 
   /* Check if hits matched */
   if ((th->hits != 0)) {
-    int hits = uc_get_hits(metric_p);
+    int hits = uc_get_hits(m);
     /* STATE_OKAY resets hits unless PERSIST_OK flag is set. Hits resets if
      * threshold is hit. */
     if (((state == STATE_OKAY) && ((th->flags & UT_FLAG_PERSIST_OK) == 0)) ||
         (hits > th->hits)) {
       DEBUG("ut_report_state: reset uc_get_hits_vl = 0");
-      uc_set_hits(metric_p, 0); /* reset hit counter and notify */
+      uc_set_hits(m, 0); /* reset hit counter and notify */
     } else {
       DEBUG("ut_report_state: th->hits = %d, uc_get_hits = %d", th->hits,
             uc_get_hits(mstric_p));
-      (void)uc_inc_hits(metric_p, 1); /* increase hit counter */
+      (void)uc_inc_hits(m, 1); /* increase hit counter */
       return 0;
     }
   } /* end check hits */
 
-  state_old = uc_get_state(metric_p);
+  state_old = uc_get_state(m);
 
   /* If the state didn't change, report if `persistent' is specified. If the
    * state is `okay', then only report if `persist_ok` flag is set. */
@@ -317,9 +317,9 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
   }
 
   if (state != state_old)
-    uc_set_state(metric_p, state);
+    uc_set_state(m, state);
 
-  notification_init_metric(&n, NOTIF_FAILURE, NULL, metric_p);
+  notification_init_metric(&n, NOTIF_FAILURE, NULL, m);
 
   buf = n.message;
   bufsize = sizeof(n.message);
@@ -331,14 +331,14 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
   else
     n.severity = NOTIF_FAILURE;
 
-  n.time = metric_p->time;
+  n.time = m->time;
 
-  status = ssnprintf(buf, bufsize, "Name %s", metric_p->identity->name);
+  status = ssnprintf(buf, bufsize, "Name %s", m->identity->name);
   buf += status;
   bufsize -= status;
 
-  if (metric_p->identity->root_p != NULL) {
-    c_avl_iterator_t *iter_p = c_avl_get_iterator(metric_p->identity->root_p);
+  if (m->identity->root_p != NULL) {
+    c_avl_iterator_t *iter_p = c_avl_get_iterator(m->identity->root_p);
     if (iter_p != NULL) {
       char *key_p = NULL;
       char *value_p = NULL;
@@ -357,7 +357,7 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
     c_avl_iterator_destroy(iter_p);
   }
 
-  plugin_notification_meta_add_string(&n, "DataSource", metric_p->ds->name);
+  plugin_notification_meta_add_string(&n, "DataSource", m->ds->name);
   plugin_notification_meta_add_double(&n, "CurrentValue", value);
   plugin_notification_meta_add_double(&n, "WarningMin", th->warning_min);
   plugin_notification_meta_add_double(&n, "WarningMax", th->warning_max);
@@ -372,7 +372,7 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
       ssnprintf(buf, bufsize,
                 ": All data sources are within range again. "
                 "Current value of \"%s\" is %f.",
-                metric_p->ds->name, value);
+                m->ds->name, value);
   } else if (state == STATE_UNKNOWN) {
     ERROR("ut_report_state: metric transition to UNKNOWN from a different "
           "state. This shouldn't happen.");
@@ -389,7 +389,7 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
         ssnprintf(buf, bufsize,
                   ": Data source \"%s\" is currently "
                   "%f. That is within the %s region of %f%s and %f%s.",
-                  metric_p->ds->name, value,
+                  m->ds->name, value,
                   (state == STATE_ERROR) ? "failure" : "warning", min,
                   ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "", max,
                   ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
@@ -397,7 +397,7 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
         ssnprintf(buf, bufsize,
                   ": Data source \"%s\" is currently "
                   "%f. That is %s the %s threshold of %f%s.",
-                  metric_p->ds->name, value, isnan(min) ? "below" : "above",
+                  m->ds->name, value, isnan(min) ? "below" : "above",
                   (state == STATE_ERROR) ? "failure" : "warning",
                   isnan(min) ? max : min,
                   ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
@@ -406,8 +406,7 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
       ssnprintf(buf, bufsize,
                 ": Data source \"%s\" is currently "
                 "%g (%.2f%%). That is %s the %s threshold of %.2f%%.",
-                metric_p->ds->name, value, value,
-                (value < min) ? "below" : "above",
+                m->ds->name, value, value, (value < min) ? "below" : "above",
                 (state == STATE_ERROR) ? "failure" : "warning",
                 (value < min) ? min : max);
     } else /* is not inverted */
@@ -415,7 +414,7 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
       ssnprintf(buf, bufsize,
                 ": Data source \"%s\" is currently "
                 "%f. That is %s the %s threshold of %f.",
-                metric_p->ds->name, value, (value < min) ? "below" : "above",
+                m->ds->name, value, (value < min) ? "below" : "above",
                 (state == STATE_ERROR) ? "failure" : "warning",
                 (value < min) ? min : max);
     }
@@ -437,7 +436,7 @@ static int ut_report_state(const metric_t *metric_p, const threshold_t *th,
  * appropriate.
  * Does not fail.
  */
-static int ut_check_one_data_source(const metric_t *metric_p,
+static int ut_check_one_data_source(metric_single_t const *m,
                                     const threshold_t *th,
                                     const gauge_t value) { /* {{{ */
   int is_warning = 0;
@@ -445,8 +444,7 @@ static int ut_check_one_data_source(const metric_t *metric_p,
   int prev_state = STATE_OKAY;
 
   /* check if this threshold applies to this data source */
-  if ((th->data_source[0] != 0) &&
-      (strcmp(metric_p->ds->name, th->data_source) != 0))
+  if ((th->data_source[0] != 0) && (strcmp(m->ds->name, th->data_source) != 0))
     return STATE_UNKNOWN;
 
   if ((th->flags & UT_FLAG_INVERT) != 0) {
@@ -457,7 +455,7 @@ static int ut_check_one_data_source(const metric_t *metric_p,
   /* XXX: This is an experimental code, not optimized, not fast, not reliable,
    * and probably, do not work as you expect. Enjoy! :D */
   if (th->hysteresis > 0) {
-    prev_state = uc_get_state(metric_p);
+    prev_state = uc_get_state(m);
     /* The purpose of hysteresis is elliminating flapping state when the value
      * oscilates around the thresholds. In other words, what is important is
      * the previous state; if the new value would trigger a transition, make
@@ -521,7 +519,7 @@ static int ut_check_one_data_source(const metric_t *metric_p,
  * defined.
  * Returns less than zero if the data set doesn't have any data sources.
  */
-static int ut_check_one_threshold(const metric_t *metric_p,
+static int ut_check_one_threshold(metric_single_t const *m,
                                   const threshold_t *th,
                                   const gauge_t value) { /* {{{ */
   int ret = -1;
@@ -549,7 +547,7 @@ static int ut_check_one_threshold(const metric_t *metric_p,
 
   int status;
 
-  status = ut_check_one_data_source(metric_p, th, values_copy);
+  status = ut_check_one_data_source(m, th, values_copy);
   if (ret < status) {
     ret = status;
   }
@@ -565,7 +563,7 @@ static int ut_check_one_threshold(const metric_t *metric_p,
  * Returns zero on success and if no threshold has been configured. Returns
  * less than zero on failure.
  */
-static int ut_check_threshold(const metric_t *metric_p,
+static int ut_check_threshold(metric_single_t const *m,
                               __attribute__((unused))
                               user_data_t *ud) { /* {{{ */
   threshold_t *th;
@@ -581,20 +579,20 @@ static int ut_check_threshold(const metric_t *metric_p,
   /* Is this lock really necessary? So far, thresholds are only inserted at
    * startup. -octo */
   pthread_mutex_lock(&threshold_lock);
-  th = threshold_search(metric_p);
+  th = threshold_search(m);
   pthread_mutex_unlock(&threshold_lock);
   if (th == NULL)
     return 0;
 
   DEBUG("ut_check_threshold: Found matching threshold(s)");
 
-  status = uc_get_rate(metric_p, &value);
+  status = uc_get_rate(m, &value);
   if (status != 0)
     return 0;
 
   while (th != NULL) {
 
-    status = ut_check_one_threshold(metric_p, th, value);
+    status = ut_check_one_threshold(m, th, value);
     if (status < 0) {
       ERROR("ut_check_threshold: ut_check_one_threshold failed.");
       return -1;
@@ -608,7 +606,7 @@ static int ut_check_threshold(const metric_t *metric_p,
     th = th->next;
   } /* while (th) */
 
-  status = ut_report_state(metric_p, worst_th, value, worst_state);
+  status = ut_report_state(m, worst_th, value, worst_state);
   if (status != 0) {
     ERROR("ut_check_threshold: ut_report_state failed.");
     return -1;
@@ -622,7 +620,7 @@ static int ut_check_threshold(const metric_t *metric_p,
  *
  * This function is called whenever a value goes "missing".
  */
-static int ut_missing(const metric_t *metric_p,
+static int ut_missing(metric_single_t const *m,
                       __attribute__((unused)) user_data_t *ud) { /* {{{ */
   threshold_t *th;
   cdtime_t missing_time;
@@ -633,18 +631,18 @@ static int ut_missing(const metric_t *metric_p,
   if (threshold_tree == NULL)
     return 0;
 
-  th = threshold_search(metric_p);
+  th = threshold_search(m);
   /* dispatch notifications for "interesting" values only */
   if ((th == NULL) || ((th->flags & UT_FLAG_INTERESTING) == 0))
     return 0;
 
   now = cdtime();
-  missing_time = now - metric_p->time;
-  if ((identifier_p = metric_marshal_text(metric_p)) != 0) {
+  missing_time = now - m->time;
+  if ((identifier_p = metric_marshal_text(m)) != 0) {
     ERROR("uc_update: metric_marshal_text failed.");
   }
 
-  notification_init_metric(&n, NOTIF_FAILURE, NULL, metric_p);
+  notification_init_metric(&n, NOTIF_FAILURE, NULL, m);
   ssnprintf(n.message, sizeof(n.message),
             "%s has not been updated for %.3f seconds.", identifier_p,
             CDTIME_T_TO_DOUBLE(missing_time));
index 822f7266768c00489fad6add9efedfa83639cdd9..5dfe28da4d27d5a714b19ecf1dc2914f660c7a27 100644 (file)
@@ -388,10 +388,11 @@ static int wg_send_message(char const *message, struct wg_callback *cb) {
   return 0;
 }
 
-static int wg_write_messages(metric_t const *m, struct wg_callback *cb) {
+static int wg_write_messages(metric_single_t const *m, struct wg_callback *cb) {
   strbuf_t buf = STRBUF_CREATE;
 
-  int status = format_graphite(&buf, m, cb->prefix, cb->postfix, cb->escape_char, cb->format_flags);
+  int status = format_graphite(&buf, m, cb->prefix, cb->postfix,
+                               cb->escape_char, cb->format_flags);
   if (status != 0) {
     STRBUF_DESTROY(buf);
     return status;
@@ -403,7 +404,7 @@ static int wg_write_messages(metric_t const *m, struct wg_callback *cb) {
   return status;
 } /* int wg_write_messages */
 
-static int wg_write(metric_t const *m, user_data_t *user_data) {
+static int wg_write(metric_single_t const *m, user_data_t *user_data) {
   if ((m == NULL) || (user_data == NULL)) {
     return EINVAL;
   }
index c343b5444ea688b82eecca913f288518ef3222a4..c250747a2dc30dea0bcfcc7d576733644422a25c 100644 (file)
@@ -399,7 +399,7 @@ static void wh_callback_free(void *data) /* {{{ */
   sfree(cb);
 } /* }}} void wh_callback_free */
 
-static int wh_write_command(const metric_t *metric_p, /* {{{ */
+static int wh_write_command(metric_single_t const *m, /* {{{ */
                             wh_callback_t *cb) {
   char values[512];
   char command[1024];
@@ -413,7 +413,7 @@ static int wh_write_command(const metric_t *metric_p, /* {{{ */
 
   /* Copy the identifier to `key' and escape it. */
   char *metric_string_p = NULL;
-  if ((metric_string_p = metric_marshal_text(metric_p)) != 0) {
+  if ((metric_string_p = metric_marshal_text(m)) != 0) {
     return -1;
   }
 
@@ -421,7 +421,7 @@ static int wh_write_command(const metric_t *metric_p, /* {{{ */
 
   /* Convert the values to an ASCII representation and put that into
    * `values'. */
-  status = format_values(values, sizeof(values), metric_p, cb->store_rates);
+  status = format_values(values, sizeof(values), m, cb->store_rates);
   if (status != 0) {
     ERROR("write_http plugin: error with "
           "wh_value_list_to_string");
@@ -431,7 +431,7 @@ static int wh_write_command(const metric_t *metric_p, /* {{{ */
 
   command_len = (size_t)snprintf(
       command, sizeof(command), "PUTVAL %s interval=%.3f %s\r\n",
-      metric_string_p, CDTIME_T_TO_DOUBLE(metric_p->interval), values);
+      metric_string_p, CDTIME_T_TO_DOUBLE(m->interval), values);
   if (command_len >= sizeof(command)) {
     ERROR("write_http plugin: Command buffer too small: "
           "Need %" PRIsz " bytes.",
@@ -477,7 +477,7 @@ static int wh_write_command(const metric_t *metric_p, /* {{{ */
   return 0;
 } /* }}} int wh_write_command */
 
-static int wh_write_json(const metric_t *metric_p, /* {{{ */
+static int wh_write_json(metric_single_t const *m, /* {{{ */
                          wh_callback_t *cb) {
   int status;
 
@@ -488,9 +488,8 @@ static int wh_write_json(const metric_t *metric_p, /* {{{ */
     return -1;
   }
 
-  status =
-      format_json_metric(cb->send_buffer, &cb->send_buffer_fill,
-                        &cb->send_buffer_free, metric_p, cb->store_rates);
+  status = format_json_metric(cb->send_buffer, &cb->send_buffer_fill,
+                              &cb->send_buffer_free, m, cb->store_rates);
   if (status == -ENOMEM) {
     status = wh_flush_nolock(/* timeout = */ 0, cb);
     if (status != 0) {
@@ -499,9 +498,8 @@ static int wh_write_json(const metric_t *metric_p, /* {{{ */
       return status;
     }
 
-    status =
-        format_json_metric(cb->send_buffer, &cb->send_buffer_fill,
-                          &cb->send_buffer_free, metric_p, cb->store_rates);
+    status = format_json_metric(cb->send_buffer, &cb->send_buffer_fill,
+                                &cb->send_buffer_free, m, cb->store_rates);
   }
   if (status != 0) {
     pthread_mutex_unlock(&cb->send_lock);
@@ -519,7 +517,7 @@ static int wh_write_json(const metric_t *metric_p, /* {{{ */
   return 0;
 } /* }}} int wh_write_json */
 
-static int wh_write_kairosdb(const metric_t *metric_p, /* {{{ */
+static int wh_write_kairosdb(metric_single_t const *m, /* {{{ */
                              wh_callback_t *cb) {
   int status;
 
@@ -535,7 +533,7 @@ static int wh_write_kairosdb(const metric_t *metric_p, /* {{{ */
   }
 
   status = format_kairosdb_metric(
-      cb->send_buffer, &cb->send_buffer_fill, &cb->send_buffer_free, metric_p,
+      cb->send_buffer, &cb->send_buffer_fill, &cb->send_buffer_free, m,
       cb->store_rates, (char const *const *)http_attrs, http_attrs_num,
       cb->data_ttl, cb->metrics_prefix);
   if (status == -ENOMEM) {
@@ -547,7 +545,7 @@ static int wh_write_kairosdb(const metric_t *metric_p, /* {{{ */
     }
 
     status = format_kairosdb_metric(
-        cb->send_buffer, &cb->send_buffer_fill, &cb->send_buffer_free, metric_p,
+        cb->send_buffer, &cb->send_buffer_fill, &cb->send_buffer_free, m,
         cb->store_rates, (char const *const *)http_attrs, http_attrs_num,
         cb->data_ttl, cb->metrics_prefix);
   }
@@ -567,7 +565,7 @@ static int wh_write_kairosdb(const metric_t *metric_p, /* {{{ */
   return 0;
 } /* }}} int wh_write_kairosdb */
 
-static int wh_write(const metric_t *metric_p, /* {{{ */
+static int wh_write(metric_single_t const *m, /* {{{ */
                     user_data_t *user_data) {
   wh_callback_t *cb;
   int status;
@@ -580,13 +578,13 @@ static int wh_write(const metric_t *metric_p, /* {{{ */
 
   switch (cb->format) {
   case WH_FORMAT_JSON:
-    status = wh_write_json(metric_p, cb);
+    status = wh_write_json(m, cb);
     break;
   case WH_FORMAT_KAIROSDB:
-    status = wh_write_kairosdb(metric_p, cb);
+    status = wh_write_kairosdb(m, cb);
     break;
   default:
-    status = wh_write_command(metric_p, cb);
+    status = wh_write_command(m, cb);
     break;
   }
   return status;
index 5307bcd2a4d6a61cd4ab6dcd3b830c6981607d57..8f7f36cbaa21eefe19c75ba0aec73b1ff94847cc 100644 (file)
@@ -57,7 +57,7 @@ struct kafka_topic_context {
 };
 
 static int kafka_handle(struct kafka_topic_context *);
-static int kafka_write(const metric_t *, user_data_t *);
+static int kafka_write(metric_single_t const *, user_data_t *);
 static int32_t kafka_partition(const rd_kafka_topic_t *, const void *, size_t,
                                int32_t, void *, void *);
 
@@ -171,7 +171,7 @@ static int kafka_handle(struct kafka_topic_context *ctx) /* {{{ */
 } /* }}} int kafka_handle */
 
 static int kafka_write(/* {{{ */
-                       const metric_t *metric_p, user_data_t *ud) {
+                       metric_single_t const *m, user_data_t *ud) {
   int status = 0;
   void *key;
   size_t keylen = 0;
@@ -181,8 +181,8 @@ static int kafka_write(/* {{{ */
   size_t blen = 0;
   struct kafka_topic_context *ctx = ud->data;
 
-  if ((metric_p == NULL) || (metric_p->ds == NULL) ||
-      (metric_p->identity == NULL) || (ctx == NULL))
+  if ((m == NULL) || (metric_p->ds == NULL) || (m->identity == NULL) ||
+      (ctx == NULL))
     return EINVAL;
 
   pthread_mutex_lock(&ctx->lock);
@@ -195,7 +195,7 @@ static int kafka_write(/* {{{ */
 
   switch (ctx->format) {
   case KAFKA_FORMAT_COMMAND:
-    status = cmd_create_putval(buffer, sizeof(buffer), metric_p);
+    status = cmd_create_putval(buffer, sizeof(buffer), m);
     if (status != 0) {
       ERROR("write_kafka plugin: cmd_create_putval failed with status %i.",
             status);
@@ -205,14 +205,14 @@ static int kafka_write(/* {{{ */
     break;
   case KAFKA_FORMAT_JSON:
     format_json_initialize(buffer, &bfill, &bfree);
-    format_json_metric(buffer, &bfill, &bfree, metric_p, ctx->store_rates);
+    format_json_metric(buffer, &bfill, &bfree, m, ctx->store_rates);
     format_json_finalize(buffer, &bfill, &bfree);
     blen = strlen(buffer);
     break;
   case KAFKA_FORMAT_GRAPHITE:
     status =
-        format_graphite(buffer, sizeof(buffer), metric_p, ctx->prefix,
-                        ctx->postfix, ctx->escape_char, ctx->graphite_flags);
+        format_graphite(buffer, sizeof(buffer), m, ctx->prefix, ctx->postfix,
+                        ctx->escape_char, ctx->graphite_flags);
     if (status != 0) {
       ERROR("write_kafka plugin: format_graphite failed with status %i.",
             status);
index 9a35e2d08ef4c63d99cc0dbd0c5c1e11ac009bc0..d532e60c55afd9a64a2e40045ee6459c7dcf3ebe 100644 (file)
@@ -57,7 +57,7 @@ typedef struct wr_node_s wr_node_t;
  * Functions
  */
 static int wr_write(/* {{{ */
-                    const metric_t *metric_p, user_data_t *ud) {
+                    metric_single_t const *m, user_data_t *ud) {
   wr_node_t *node = ud->data;
   char key[512];
   char value[512] = {0};
@@ -68,18 +68,18 @@ static int wr_write(/* {{{ */
   redisReply *rr;
 
   char *metric_string_p = NULL;
-  if ((metric_string_p = metric_marshal_text(metric_p)) != 0) {
+  if ((metric_string_p = metric_marshal_text(m)) != 0) {
     return -1;
   }
 
   ssnprintf(key, sizeof(key), "%s%s",
             (node->prefix != NULL) ? node->prefix : REDIS_DEFAULT_PREFIX,
             metric_string_p);
-  ssnprintf(time, sizeof(time), "%.9f", CDTIME_T_TO_DOUBLE(metric_p->time));
+  ssnprintf(time, sizeof(time), "%.9f", CDTIME_T_TO_DOUBLE(m->time));
 
   value_size = sizeof(value);
   value_ptr = &value[0];
-  status = format_values(value_ptr, value_size, metric_p, node->store_rates);
+  status = format_values(value_ptr, value_size, m, node->store_rates);
   if (status != 0) {
     sfree(metric_string_p);
     return status;
@@ -137,9 +137,8 @@ static int wr_write(/* {{{ */
      * remove element, scored less than 'current-max_set_duration'
      * '(...' indicates 'less than' in redis CLI.
      */
-    rr = redisCommand(
-        node->conn, "ZREMRANGEBYSCORE %s -1 (%.9f", key,
-        (CDTIME_T_TO_DOUBLE(metric_p->time) - node->max_set_duration));
+    rr = redisCommand(node->conn, "ZREMRANGEBYSCORE %s -1 (%.9f", key,
+                      (CDTIME_T_TO_DOUBLE(m->time) - node->max_set_duration));
     if (rr == NULL)
       WARNING("ZREMRANGEBYSCORE command error. key:%s message:%s", key,
               node->conn->errstr);