summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0a95b83)
raw | patch | inline | side by side (parent: 0a95b83)
author | Florian Forster <octo@collectd.org> | |
Wed, 14 Sep 2016 06:19:41 +0000 (08:19 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 14 Sep 2016 06:45:58 +0000 (08:45 +0200) |
74 files changed:
diff --git a/src/apache.c b/src/apache.c
index c02dfe0fb19588b5d54bd6e90f534c85f9403fa9..20a2a3cdca6b28c0adae06817f422714b2a05369 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
} /* void submit_value */
static void submit_derive (const char *type, const char *type_instance,
- derive_t c, apache_t *st)
+ derive_t d, apache_t *st)
{
- value_t v;
- v.derive = c;
- submit_value (type, type_instance, v, st);
+ submit_value (type, type_instance, (value_t) { .derive = d }, st);
} /* void submit_derive */
static void submit_gauge (const char *type, const char *type_instance,
gauge_t g, apache_t *st)
{
- value_t v;
- v.gauge = g;
- submit_value (type, type_instance, v, st);
+ submit_value (type, type_instance, (value_t) { .gauge = g }, st);
} /* void submit_gauge */
static void submit_scoreboard (char *buf, apache_t *st)
diff --git a/src/apcups.c b/src/apcups.c
index af5f24c70f2f2d1e5544a7a1c62cd7f880b27ba4..821bd65edbed1f3fd70244aed5d1e3866e7d32d9 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
static void apc_submit_generic (const char *type, const char *type_inst, double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "apcups", sizeof (vl.plugin));
diff --git a/src/apple_sensors.c b/src/apple_sensors.c
index 48fbcb91e53117832fc26160df4f8ecd4fa96947..06ca7a85958661aab3851aae6d4be497dd99dcb7 100644 (file)
--- a/src/apple_sensors.c
+++ b/src/apple_sensors.c
static void as_submit (const char *type, const char *type_instance,
double val)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- DEBUG ("type = %s; type_instance = %s; val = %f;",
- type, type_instance, val);
-
- values[0].gauge = val;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = val };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "apple_sensors", sizeof (vl.plugin));
diff --git a/src/aquaero.c b/src/aquaero.c
index 81a4efd4337257865dd78d293d065572c3aa7b7e..08271f87a4b4bdf8124676ec4322ee4932bb9cdd 100644 (file)
--- a/src/aquaero.c
+++ b/src/aquaero.c
double value)
{
const char *instance = conf_device?conf_device:"default";
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
/* Don't report undefined values. */
if (value == AQ5_FLOAT_UNDEF)
return;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
diff --git a/src/ascent.c b/src/ascent.c
index 11bb97f0c6bce3b3abe457090053173d91a01737..16568e6ca27a3d69ce5860458499ce9182862277 100644 (file)
--- a/src/ascent.c
+++ b/src/ascent.c
static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */
const char *type, const char *type_instance, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ascent", sizeof (vl.plugin));
diff --git a/src/battery.c b/src/battery.c
index d227d5599fc3c1c6c76c22f88e30607d8a76ec26..ebf41debdab783fdf2b676e2219a994f86e1959b 100644 (file)
--- a/src/battery.c
+++ b/src/battery.c
static void battery_submit2 (char const *plugin_instance, /* {{{ */
char const *type, char const *type_instance, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "battery", sizeof (vl.plugin));
diff --git a/src/battery_statefs.c b/src/battery_statefs.c
index ee739bf5555824fb14765b8c107c3cef77e28293..03729fdb0c9d4900fe5d55bc72c1c9f375e2ee9d 100644 (file)
--- a/src/battery_statefs.c
+++ b/src/battery_statefs.c
static void battery_submit(const char *type, gauge_t value,
const char *type_instance) {
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "battery", sizeof(vl.plugin));
diff --git a/src/bind.c b/src/bind.c
index 9b6b32e3dada7811eca47ba32268b18decec1aff..09de4a3f7679bf8c94217e3d7a276f15a299dd79 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
static void submit (time_t ts, const char *plugin_instance, /* {{{ */
const char *type, const char *type_instance, value_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0] = value;
-
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
if (config_parse_time)
vl.time = TIME_T_TO_CDTIME_T (ts);
diff --git a/src/chrony.c b/src/chrony.c
index f6294e49112dabdcf70a0c84c78e96e40b2a5945..353ede792f0627aae2e512439151349f050aeccd 100644 (file)
--- a/src/chrony.c
+++ b/src/chrony.c
static void
chrony_push_data(const char *p_type, const char *p_type_inst, double p_value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = p_value; /* TODO: Check type??? (counter, gauge, derive, absolute) */
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = p_value };
vl.values_len = 1;
/* XXX: Shall g_chrony_host/g_chrony_port be reflected in the plugin's output? */
diff --git a/src/contextswitch.c b/src/contextswitch.c
index 76e2a6c0b935c9225d50e96e7c2405554f459476..3bd6d9f53cc849421760fa211dfab9caddb106a7 100644 (file)
--- a/src/contextswitch.c
+++ b/src/contextswitch.c
static void cs_submit (derive_t context_switches)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = (derive_t) context_switches;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = context_switches };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "contextswitch", sizeof (vl.plugin));
diff --git a/src/cpu.c b/src/cpu.c
index 1ac5b4a3b94a9cea50835485befc4adf7c934b88..fbd071432c3d09824c685c31e33fa21ed102a373 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
static void submit_value (int cpu_num, int cpu_state, const char *type, value_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- memcpy(&values[0], &value, sizeof(value));
-
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
@@ -346,26 +343,22 @@ static void submit_value (int cpu_num, int cpu_state, const char *type, value_t
plugin_dispatch_values (&vl);
}
-static void submit_percent(int cpu_num, int cpu_state, gauge_t percent)
+static void submit_percent (int cpu_num, int cpu_state, gauge_t value)
{
- value_t value;
-
/* This function is called for all known CPU states, but each read
* method will only report a subset. The remaining states are left as
* NAN and we ignore them here. */
- if (isnan (percent))
+ if (isnan (value))
return;
- value.gauge = percent;
- submit_value (cpu_num, cpu_state, "percent", value);
+ submit_value (cpu_num, cpu_state, "percent",
+ (value_t) { .gauge = value });
}
-static void submit_derive(int cpu_num, int cpu_state, derive_t derive)
+static void submit_derive (int cpu_num, int cpu_state, derive_t value)
{
- value_t value;
-
- value.derive = derive;
- submit_value (cpu_num, cpu_state, "cpu", value);
+ submit_value (cpu_num, cpu_state, "cpu",
+ (value_t) { .derive = value });
}
/* Takes the zero-index number of a CPU and makes sure that the module-global
} /* }}} void cpu_commit_one */
/* Commits the number of cores */
-static void cpu_commit_num_cpu (gauge_t num_cpu) /* {{{ */
+static void cpu_commit_num_cpu (gauge_t value) /* {{{ */
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = num_cpu;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
@@ -555,7 +545,7 @@ static int cpu_stage (size_t cpu_num, size_t state, derive_t d, cdtime_t now) /*
int status;
cpu_state_t *s;
gauge_t rate = NAN;
- value_t val = {.derive = d};
+ value_t val = { .derive = d };
if (state >= COLLECTD_CPU_STATE_ACTIVE)
return (EINVAL);
diff --git a/src/cpusleep.c b/src/cpusleep.c
index 326c29ce2bf2394346bfc46665cdde42d224d477..5de0e470bf2c3c1b7bddc1fb465740da2c082ec6 100644 (file)
--- a/src/cpusleep.c
+++ b/src/cpusleep.c
#include <time.h>
static void cpusleep_submit(derive_t cpu_sleep) {
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = cpu_sleep;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = cpu_sleep };
vl.values_len = 1;
sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "cpusleep", sizeof(vl.plugin));
diff --git a/src/curl.c b/src/curl.c
index 74ef13c97463469e42f878b3235f328b2ed11f1f..8401e6ca412e6bc4fd46c17ac4fa391d8ede87ec 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
} /* }}} int cc_init */
static void cc_submit (const web_page_t *wp, const web_match_t *wm, /* {{{ */
- const cu_match_value_t *mv)
+ value_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0] = mv->value;
-
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
static void cc_submit_response_code (const web_page_t *wp, long code) /* {{{ */
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = code;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = (gauge_t) code };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
@@ -647,12 +641,9 @@ static void cc_submit_response_code (const web_page_t *wp, long code) /* {{{ */
static void cc_submit_response_time (const web_page_t *wp, /* {{{ */
cdtime_t response_time)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = CDTIME_T_TO_DOUBLE (response_time);
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = CDTIME_T_TO_DOUBLE (response_time) };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
continue;
}
- cc_submit (wp, wm, mv);
+ cc_submit (wp, wm, mv->value);
match_value_reset (mv);
} /* for (wm = wp->matches; wm != NULL; wm = wm->next) */
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index c6efc3fe439b35ed396b22a391938e2af98c6e3c..d4b962fb5647cc7bdff4a0139554619d7b8c7d97 100644 (file)
--- a/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
}
static void plugin_update_internal_statistics (void) { /* {{{ */
- derive_t copy_write_queue_length;
- value_list_t vl = VALUE_LIST_INIT;
- value_t values[2];
- copy_write_queue_length = write_queue_length;
+ gauge_t copy_write_queue_length = (gauge_t) write_queue_length;
/* Initialize `vl' */
- vl.values = values;
- vl.values_len = 2;
- vl.time = 0;
+ value_list_t vl = VALUE_LIST_INIT;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "collectd", sizeof (vl.plugin));
- vl.type_instance[0] = 0;
- vl.values_len = 1;
-
/* Write queue */
sstrncpy (vl.plugin_instance, "write_queue",
sizeof (vl.plugin_instance));
/* Write queue : queue length */
- vl.values[0].gauge = (gauge_t) copy_write_queue_length;
+ vl.values = &(value_t) { .gauge = copy_write_queue_length };
+ vl.values_len = 1;
sstrncpy (vl.type, "queue_length", sizeof (vl.type));
vl.type_instance[0] = 0;
plugin_dispatch_values (&vl);
/* Write queue : Values dropped (queue length > low limit) */
- vl.values[0].derive = (derive_t) stats_values_dropped;
+ vl.values = &(value_t) { .gauge = (gauge_t) stats_values_dropped };
+ vl.values_len = 1;
sstrncpy (vl.type, "derive", sizeof (vl.type));
sstrncpy (vl.type_instance, "dropped", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
sizeof (vl.plugin_instance));
/* Cache : Nb entry in cache tree */
- vl.values[0].gauge = (gauge_t) uc_get_size();
+ vl.values = &(value_t) { .gauge = (gauge_t) uc_get_size() };
+ vl.values_len = 1;
sstrncpy (vl.type, "cache_size", sizeof (vl.type));
vl.type_instance[0] = 0;
plugin_dispatch_values (&vl);
diff --git a/src/df.c b/src/df.c
index af54c92f9f7da4ce3c919deb11d93c12478e8d85..632787b22be41b678f68487ac6347a6411c7715e 100644 (file)
--- a/src/df.c
+++ b/src/df.c
const char *type, const char *type_instance,
gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "df", sizeof (vl.plugin));
diff --git a/src/disk.c b/src/disk.c
index 465b005707dd73d64b95678ef5ee096c64cc71e9..f29029c584dce4d7375466069106e1572d2a3971 100644 (file)
--- a/src/disk.c
+++ b/src/disk.c
@@ -337,12 +337,9 @@ static void submit_io_time (char const *plugin_instance, derive_t io_time, deriv
#if KERNEL_LINUX
static void submit_in_progress (char const *disk_name, gauge_t in_progress)
{
- value_t v;
value_list_t vl = VALUE_LIST_INIT;
- v.gauge = in_progress;
-
- vl.values = &v;
+ vl.values = &(value_t) { .gauge = in_progress };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
plugin_dispatch_values (&vl);
}
-
static counter_t disk_calc_time_incr (counter_t delta_time, counter_t delta_ops)
{
double interval = CDTIME_T_TO_DOUBLE (plugin_get_interval ());
diff --git a/src/dns.c b/src/dns.c
index 0494b4baeb20494f3a00fdb629eb2d738b637077..ef80e575d1c8820f4227e105d360c15425f92529 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
static void submit_derive (const char *type, const char *type_instance,
derive_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "dns", sizeof (vl.plugin));
diff --git a/src/email.c b/src/email.c
index 2662da9e3590f83832c321355e353d016afa59d1..97fbdfe6f634aa7efefb7ebf157fe1757f6e60b5 100644 (file)
--- a/src/email.c
+++ b/src/email.c
static void email_submit (const char *type, const char *type_instance, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "email", sizeof (vl.plugin));
diff --git a/src/ethstat.c b/src/ethstat.c
index d0e77281e69b5d9ff4ff0d1c406a3aaa12b81e8c..f0b8d9f01f6d87c779d56e3d95cf0e5b4384b7cb 100644 (file)
--- a/src/ethstat.c
+++ b/src/ethstat.c
{
static c_complain_t complain_no_map = C_COMPLAIN_INIT_STATIC;
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_map_t *map = NULL;
return;
}
- values[0].derive = value;
- vl.values = values;
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
diff --git a/src/fhcount.c b/src/fhcount.c
index 4b3abff7276502efca4c9697b788a2770561ce41..a2f5aa8c9aabf87dc8623b2b9ac99a9023cb84ae 100644 (file)
--- a/src/fhcount.c
+++ b/src/fhcount.c
static void fhcount_submit(
const char *type, const char *type_instance, gauge_t value) {
-
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
// Compose the metric
plugin_dispatch_values(&vl);
}
-
static int fhcount_read(void) {
int numfields = 0;
int buffer_len = 60;
diff --git a/src/filecount.c b/src/filecount.c
index 9de9e6c53a5fced05d2d8ead5c1297a29195476a..c1e53a2d52e504845dc6a453acebedf7d3a84b6d 100644 (file)
--- a/src/filecount.c
+++ b/src/filecount.c
static void fc_submit_dir (const fc_directory_conf_t *dir)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = (gauge_t) dir->files_num;
-
- vl.values = values;
- vl.values_len = STATIC_ARRAY_SIZE (values);
+ vl.values = &(value_t) { .gauge = (gauge_t) dir->files_num };
+ vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "filecount", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, dir->instance, sizeof (vl.plugin_instance));
plugin_dispatch_values (&vl);
- values[0].gauge = (gauge_t) dir->files_size;
+ vl.values = &(value_t) { .gauge = (gauge_t) dir->files_size };
sstrncpy (vl.type, "bytes", sizeof (vl.type));
plugin_dispatch_values (&vl);
diff --git a/src/gps.c b/src/gps.c
index f72cef4961bfa860f2481b0663ce822a36f592ad..d5b7176b44560073260bef643ea88d811ecb80f3 100644 (file)
--- a/src/gps.c
+++ b/src/gps.c
*/
static void cgps_submit (const char *type, gauge_t value, const char *type_instance)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "gps", sizeof (vl.plugin));
diff --git a/src/hddtemp.c b/src/hddtemp.c
index 865ea8614afda35cee5993eeec8cf61e86c6f8b6..31960b54e9166b2d3be9eb20f82888668ceb90c0 100644 (file)
--- a/src/hddtemp.c
+++ b/src/hddtemp.c
static void hddtemp_submit (char *type_instance, double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "hddtemp", sizeof (vl.plugin));
diff --git a/src/ipc.c b/src/ipc.c
index b164cdf72b517da03de6847a4e7c68f4f6e5608e..d6d2bbd56850a11ade0239b564f296508417d23f 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
const char *type_instance,
gauge_t value) /* {{{ */
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ipc", sizeof (vl.plugin));
diff --git a/src/ipmi.c b/src/ipmi.c
index ad62299e3390bba91aedf9c5656f711643962e44..a42b787fe5a40e1b67126a7eaa884371d91b026e 100644 (file)
--- a/src/ipmi.c
+++ b/src/ipmi.c
ipmi_states_t __attribute__((unused)) *states,
void *user_data)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
c_ipmi_sensor_list_t *list_item = (c_ipmi_sensor_list_t *)user_data;
return;
}
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
diff --git a/src/iptables.c b/src/iptables.c
index f6911221df8739f31d77710eb59802a4d9fff1d4..35975e6d8adff4979a18c841fabe57035eec416f 100644 (file)
--- a/src/iptables.c
+++ b/src/iptables.c
int rule_num)
{
int status;
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
/* Select the rules to collect */
return (0);
}
- vl.values = values;
- vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ip6tables", sizeof (vl.plugin));
}
sstrncpy (vl.type, "ipt_bytes", sizeof (vl.type));
- values[0].derive = (derive_t) entry->counters.bcnt;
+ vl.values = &(value_t) { .derive = (derive_t) entry->counters.bcnt };
+ vl.values_len = 1;
plugin_dispatch_values (&vl);
sstrncpy (vl.type, "ipt_packets", sizeof (vl.type));
- values[0].derive = (derive_t) entry->counters.pcnt;
+ vl.values = &(value_t) { .derive = (derive_t) entry->counters.pcnt };
plugin_dispatch_values (&vl);
return (0);
-} /* int submit_match */
-
+} /* int submit6_match */
/* This needs to return `int' for IPT_MATCH_ITERATE to work. */
static int submit_match (const struct ipt_entry_match *match,
int rule_num)
{
int status;
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
/* Select the rules to collect */
return (0);
}
- vl.values = values;
- vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "iptables", sizeof (vl.plugin));
}
sstrncpy (vl.type, "ipt_bytes", sizeof (vl.type));
- values[0].derive = (derive_t) entry->counters.bcnt;
+ vl.values = &(value_t) { .derive = (derive_t) entry->counters.bcnt };
+ vl.values_len = 1;
plugin_dispatch_values (&vl);
sstrncpy (vl.type, "ipt_packets", sizeof (vl.type));
- values[0].derive = (derive_t) entry->counters.pcnt;
+ vl.values = &(value_t) { .derive = (derive_t) entry->counters.pcnt };
plugin_dispatch_values (&vl);
return (0);
diff --git a/src/ipvs.c b/src/ipvs.c
index 92690e88e0098635a8cc56fe9c6191116b81082e..a68d20fb0ca019c021eb91c677ed0b812d6a9403 100644 (file)
--- a/src/ipvs.c
+++ b/src/ipvs.c
static void cipvs_submit_connections (const char *pi, const char *ti,
derive_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
diff --git a/src/irq.c b/src/irq.c
index 0f1d3f0ce50954ffd7d4524a52cd36d5bd884744..cb444a47309c1bad1701e7389acd9eec5a037f8f 100644 (file)
--- a/src/irq.c
+++ b/src/irq.c
static void irq_submit (const char *irq_name, derive_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
if (ignorelist_match (ignorelist, irq_name) != 0)
return;
- values[0].derive = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "irq", sizeof (vl.plugin));
diff --git a/src/lpar.c b/src/lpar.c
index 5b0bd13d0cd1ea5881d2da1477311189664dc3e2..0e32c834506f6aa2cf85b48643e3c5f10ba5c4ae 100644 (file)
--- a/src/lpar.c
+++ b/src/lpar.c
static void lpar_submit (const char *type_instance, double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = (gauge_t)value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
if (report_by_serial)
{
diff --git a/src/lvm.c b/src/lvm.c
index 6b9a0317c2124eb78fe4c81ed485a319b85f8336..77cb6eb885c1e6afcbe62b40a60169f3d24ca66e 100644 (file)
--- a/src/lvm.c
+++ b/src/lvm.c
static void lvm_submit (char const *plugin_instance, char const *type_instance,
uint64_t ivalue)
{
- value_t v;
value_list_t vl = VALUE_LIST_INIT;
- v.gauge = (gauge_t) ivalue;
-
- vl.values = &v;
+ vl.values = &(value_t) { .gauge = (gauge_t) ivalue };
vl.values_len = 1;
sstrncpy(vl.host, hostname_g, sizeof (vl.host));
diff --git a/src/madwifi.c b/src/madwifi.c
index 053bd7fa2c7a47851c33ae1e19e5c5b38d058132..f8065a6d944dc12906a5605e474a001354e8ea33 100644 (file)
--- a/src/madwifi.c
+++ b/src/madwifi.c
static void submit (const char *dev, const char *type, const char *ti1,
- const char *ti2, value_t *val, int len)
+ const char *ti2, value_t *val, size_t len)
{
value_list_t vl = VALUE_LIST_INIT;
}
static void submit_derive (const char *dev, const char *type, const char *ti1,
- const char *ti2, derive_t val)
+ const char *ti2, derive_t value)
{
- value_t item;
- item.derive = val;
- submit (dev, type, ti1, ti2, &item, 1);
+ submit (dev, type, ti1, ti2, &(value_t) { .derive = value }, 1);
}
static void submit_derive2 (const char *dev, const char *type, const char *ti1,
@@ -575,11 +573,9 @@ static void submit_derive2 (const char *dev, const char *type, const char *ti1,
}
static void submit_gauge (const char *dev, const char *type, const char *ti1,
- const char *ti2, gauge_t val)
+ const char *ti2, gauge_t value)
{
- value_t item;
- item.gauge = val;
- submit (dev, type, ti1, ti2, &item, 1);
+ submit (dev, type, ti1, ti2, &(value_t) { .gauge = value }, 1);
}
static void submit_antx (const char *dev, const char *name,
diff --git a/src/mbmon.c b/src/mbmon.c
index 9629b8960d67da5960f957d89f48bfd0c40f500c..b72be896be4de7b8188ec5222fe8021c08a57d3e 100644 (file)
--- a/src/mbmon.c
+++ b/src/mbmon.c
static void mbmon_submit (const char *type, const char *type_instance,
double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "mbmon", sizeof (vl.plugin));
diff --git a/src/md.c b/src/md.c
index 44cad2edbeef32102cf7324fb73d5974c1159796..db85c46c2891d55195bd2c4d480423f280cfeee5 100644 (file)
--- a/src/md.c
+++ b/src/md.c
static void md_submit (const int minor, const char *type_instance,
gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "md", sizeof (vl.plugin));
diff --git a/src/memcachec.c b/src/memcachec.c
index dff5546179f1bade7201718889e1669f87b96d77..97e75c0c3ff3e49765f8624869a1a0562345da44 100644 (file)
--- a/src/memcachec.c
+++ b/src/memcachec.c
} /* }}} int cmc_init */
static void cmc_submit (const web_page_t *wp, const web_match_t *wm, /* {{{ */
- const cu_match_value_t *mv)
+ value_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0] = mv->value;
-
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "memcachec", sizeof (vl.plugin));
continue;
}
- cmc_submit (wp, wm, mv);
+ cmc_submit (wp, wm, mv->value);
match_value_reset (mv);
} /* for (wm = wp->matches; wm != NULL; wm = wm->next) */
diff --git a/src/memcached.c b/src/memcached.c
index d83d4c83fb74cd71fb5ba530b2610abb44448aa8..6d503ea779863aca4e7ce250d6e34bb280f69e87 100644 (file)
--- a/src/memcached.c
+++ b/src/memcached.c
static void submit_derive (const char *type, const char *type_inst,
derive_t value, memcached_t *st)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- memcached_init_vl (&vl, st);
-
- values[0].derive = value;
- vl.values = values;
+ memcached_init_vl (&vl, st);
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
static void submit_gauge (const char *type, const char *type_inst,
gauge_t value, memcached_t *st)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- memcached_init_vl (&vl, st);
-
- values[0].gauge = value;
- vl.values = values;
+ memcached_init_vl (&vl, st);
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
diff --git a/src/mic.c b/src/mic.c
index 3e31889fe83f560d89a09ce20df0d26c55d95dc6..5ec382ba10e879bf5f8362578c54f940b77ee157 100644 (file)
--- a/src/mic.c
+++ b/src/mic.c
return (0);
}
-static void mic_submit_memory_use(int micnumber, const char *type_instance, U32 val)
+static void mic_submit_memory_use(int micnumber, const char *type_instance, U32 value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
/* MicAccessAPI reports KB's of memory, adjust for this */
- DEBUG("mic plugin: Memory Value Report; %u %lf",val,((gauge_t)val)*1024.0);
- values[0].gauge = ((gauge_t)val)*1024.0;
+ DEBUG("mic plugin: Memory Value Report; %u %lf",value,((gauge_t)value)*1024.0);
- vl.values=values;
- vl.values_len=1;
+ vl.values = &(value_t) { .gauge = ((gauge_t)value) * 1024.0 };
+ vl.values_len = 1;
strncpy (vl.host, hostname_g, sizeof (vl.host));
strncpy (vl.plugin, "mic", sizeof (vl.plugin));
return (0);
}
-static void mic_submit_temp(int micnumber, const char *type, gauge_t val)
+static void mic_submit_temp(int micnumber, const char *type, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = val;
-
- vl.values=values;
- vl.values_len=1;
+ 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));
}
static void mic_submit_cpu(int micnumber, const char *type_instance,
- int core, derive_t val)
+ int core, derive_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = val;
-
- vl.values=values;
- vl.values_len=1;
+ 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));
return (0);
}
-static void mic_submit_power(int micnumber, const char *type, const char *type_instance, gauge_t val)
+static void mic_submit_power(int micnumber, const char *type, const char *type_instance, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = val;
-
- vl.values=values;
- vl.values_len=1;
+ 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));
U32 ret;
int error;
- error=0;
- for (int i=0;i<num_mics;i++) {
+ error = 0;
+ for (int i = 0;i<num_mics;i++) {
ret = MicInitAdapter(&mic_handle,&mics[i]);
if (ret != MIC_ACCESS_API_SUCCESS) {
ERROR("mic plugin: Problem initializing MicAdapter: %s",
MicGetErrorString(ret));
- error=1;
+ error = 1;
}
if (error == 0 && show_memory)
if (ret != MIC_ACCESS_API_SUCCESS) {
ERROR("mic plugin: Problem closing MicAdapter: %s",
MicGetErrorString(ret));
- error=2;
+ error = 2;
break;
}
}
if (num_mics==0)
- error=3;
+ error = 3;
return error;
}
diff --git a/src/multimeter.c b/src/multimeter.c
index 02fe1ad312f4be22a58982bb91f5ce033e29dd3f..2ffcc8f2ca97d2de8743418e051610dd54f22651 100644 (file)
--- a/src/multimeter.c
+++ b/src/multimeter.c
static void multimeter_submit (double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "multimeter", sizeof (vl.plugin));
diff --git a/src/mysql.c b/src/mysql.c
index 3bd8cb98159cf853d2e815a442c0de4575844d93..d9826d9fb09f9bea7862b81a78e8e86a560cd94f 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
plugin_dispatch_values (&vl);
} /* submit */
-static void counter_submit (const char *type, const char *type_instance,
- derive_t value, mysql_database_t *db)
-{
- value_t values[1];
-
- values[0].derive = value;
- submit (type, type_instance, values, STATIC_ARRAY_SIZE (values), db);
-} /* void counter_submit */
-
static void gauge_submit (const char *type, const char *type_instance,
gauge_t value, mysql_database_t *db)
{
- value_t values[1];
-
- values[0].gauge = value;
- submit (type, type_instance, values, STATIC_ARRAY_SIZE (values), db);
+ submit (type, type_instance, &(value_t) { .gauge = value }, 1, db);
} /* void gauge_submit */
static void derive_submit (const char *type, const char *type_instance,
derive_t value, mysql_database_t *db)
{
- value_t values[1];
-
- values[0].derive = value;
- submit (type, type_instance, values, STATIC_ARRAY_SIZE (values), db);
+ submit (type, type_instance, &(value_t) { .derive = value }, 1, db);
} /* void derive_submit */
static void traffic_submit (derive_t rx, derive_t tx, mysql_database_t *db)
}
position = atoll (row[1]);
- counter_submit ("mysql_log_position", "master-bin", position, db);
+ derive_submit ("mysql_log_position", "master-bin", position, db);
row = mysql_fetch_row (res);
if (row != NULL)
double gauge;
counter = atoll (row[READ_MASTER_LOG_POS_IDX]);
- counter_submit ("mysql_log_position", "slave-read", counter, db);
+ derive_submit ("mysql_log_position", "slave-read", counter, db);
counter = atoll (row[EXEC_MASTER_LOG_POS_IDX]);
- counter_submit ("mysql_log_position", "slave-exec", counter, db);
+ derive_submit ("mysql_log_position", "slave-exec", counter, db);
if (row[SECONDS_BEHIND_MASTER_IDX] != NULL)
{
switch (metrics[i].ds_type) {
case DS_TYPE_COUNTER:
- counter_submit(metrics[i].type, key, (counter_t)val, db);
+ derive_submit(metrics[i].type, key, (counter_t)val, db);
break;
case DS_TYPE_GAUGE:
gauge_submit(metrics[i].type, key, (gauge_t)val, db);
/* Ignore `prepared statements' */
if (strncmp (key, "Com_stmt_", strlen ("Com_stmt_")) != 0)
- counter_submit ("mysql_commands",
+ derive_submit ("mysql_commands",
key + strlen ("Com_"),
val, db);
}
if (val == 0ULL)
continue;
- counter_submit ("mysql_handler",
+ derive_submit ("mysql_handler",
key + strlen ("Handler_"),
val, db);
}
else if (strncmp (key, "Table_locks_",
strlen ("Table_locks_")) == 0)
{
- counter_submit ("mysql_locks",
+ derive_submit ("mysql_locks",
key + strlen ("Table_locks_"),
val, db);
}
else if (strcmp (key, "Innodb_buffer_pool_pages_dirty") == 0)
gauge_submit ("mysql_bpool_pages", "dirty", val, db);
else if (strcmp (key, "Innodb_buffer_pool_pages_flushed") == 0)
- counter_submit ("mysql_bpool_counters", "pages_flushed", val, db);
+ derive_submit ("mysql_bpool_counters", "pages_flushed", val, db);
else if (strcmp (key, "Innodb_buffer_pool_pages_free") == 0)
gauge_submit ("mysql_bpool_pages", "free", val, db);
else if (strcmp (key, "Innodb_buffer_pool_pages_misc") == 0)
else if (strcmp (key, "Innodb_buffer_pool_pages_total") == 0)
gauge_submit ("mysql_bpool_pages", "total", val, db);
else if (strcmp (key, "Innodb_buffer_pool_read_ahead_rnd") == 0)
- counter_submit ("mysql_bpool_counters", "read_ahead_rnd", val, db);
+ derive_submit ("mysql_bpool_counters", "read_ahead_rnd", val, db);
else if (strcmp (key, "Innodb_buffer_pool_read_ahead") == 0)
- counter_submit ("mysql_bpool_counters", "read_ahead", val, db);
+ derive_submit ("mysql_bpool_counters", "read_ahead", val, db);
else if (strcmp (key, "Innodb_buffer_pool_read_ahead_evicted") == 0)
- counter_submit ("mysql_bpool_counters", "read_ahead_evicted", val, db);
+ derive_submit ("mysql_bpool_counters", "read_ahead_evicted", val, db);
else if (strcmp (key, "Innodb_buffer_pool_read_requests") == 0)
- counter_submit ("mysql_bpool_counters", "read_requests", val, db);
+ derive_submit ("mysql_bpool_counters", "read_requests", val, db);
else if (strcmp (key, "Innodb_buffer_pool_reads") == 0)
- counter_submit ("mysql_bpool_counters", "reads", val, db);
+ derive_submit ("mysql_bpool_counters", "reads", val, db);
else if (strcmp (key, "Innodb_buffer_pool_wait_free") == 0)
- counter_submit ("mysql_bpool_counters", "wait_free", val, db);
+ derive_submit ("mysql_bpool_counters", "wait_free", val, db);
else if (strcmp (key, "Innodb_buffer_pool_write_requests") == 0)
- counter_submit ("mysql_bpool_counters", "write_requests", val, db);
+ derive_submit ("mysql_bpool_counters", "write_requests", val, db);
else if (strcmp (key, "Innodb_buffer_pool_bytes_data") == 0)
gauge_submit ("mysql_bpool_bytes", "data", val, db);
else if (strcmp (key, "Innodb_buffer_pool_bytes_dirty") == 0)
/* data */
if (strcmp (key, "Innodb_data_fsyncs") == 0)
- counter_submit ("mysql_innodb_data", "fsyncs", val, db);
+ derive_submit ("mysql_innodb_data", "fsyncs", val, db);
else if (strcmp (key, "Innodb_data_read") == 0)
- counter_submit ("mysql_innodb_data", "read", val, db);
+ derive_submit ("mysql_innodb_data", "read", val, db);
else if (strcmp (key, "Innodb_data_reads") == 0)
- counter_submit ("mysql_innodb_data", "reads", val, db);
+ derive_submit ("mysql_innodb_data", "reads", val, db);
else if (strcmp (key, "Innodb_data_writes") == 0)
- counter_submit ("mysql_innodb_data", "writes", val, db);
+ derive_submit ("mysql_innodb_data", "writes", val, db);
else if (strcmp (key, "Innodb_data_written") == 0)
- counter_submit ("mysql_innodb_data", "written", val, db);
+ derive_submit ("mysql_innodb_data", "written", val, db);
/* double write */
else if (strcmp (key, "Innodb_dblwr_writes") == 0)
- counter_submit ("mysql_innodb_dblwr", "writes", val, db);
+ derive_submit ("mysql_innodb_dblwr", "writes", val, db);
else if (strcmp (key, "Innodb_dblwr_pages_written") == 0)
- counter_submit ("mysql_innodb_dblwr", "written", val, db);
+ derive_submit ("mysql_innodb_dblwr", "written", val, db);
else if (strcmp (key, "Innodb_dblwr_page_size") == 0)
gauge_submit ("mysql_innodb_dblwr", "page_size", val, db);
/* log */
else if (strcmp (key, "Innodb_log_waits") == 0)
- counter_submit ("mysql_innodb_log", "waits", val, db);
+ derive_submit ("mysql_innodb_log", "waits", val, db);
else if (strcmp (key, "Innodb_log_write_requests") == 0)
- counter_submit ("mysql_innodb_log", "write_requests", val, db);
+ derive_submit ("mysql_innodb_log", "write_requests", val, db);
else if (strcmp (key, "Innodb_log_writes") == 0)
- counter_submit ("mysql_innodb_log", "writes", val, db);
+ derive_submit ("mysql_innodb_log", "writes", val, db);
else if (strcmp (key, "Innodb_os_log_fsyncs") == 0)
- counter_submit ("mysql_innodb_log", "fsyncs", val, db);
+ derive_submit ("mysql_innodb_log", "fsyncs", val, db);
else if (strcmp (key, "Innodb_os_log_written") == 0)
- counter_submit ("mysql_innodb_log", "written", val, db);
+ derive_submit ("mysql_innodb_log", "written", val, db);
/* pages */
else if (strcmp (key, "Innodb_pages_created") == 0)
- counter_submit ("mysql_innodb_pages", "created", val, db);
+ derive_submit ("mysql_innodb_pages", "created", val, db);
else if (strcmp (key, "Innodb_pages_read") == 0)
- counter_submit ("mysql_innodb_pages", "read", val, db);
+ derive_submit ("mysql_innodb_pages", "read", val, db);
else if (strcmp (key, "Innodb_pages_written") == 0)
- counter_submit ("mysql_innodb_pages", "written", val, db);
+ derive_submit ("mysql_innodb_pages", "written", val, db);
/* row lock */
else if (strcmp (key, "Innodb_row_lock_time") == 0)
- counter_submit ("mysql_innodb_row_lock", "time", val, db);
+ derive_submit ("mysql_innodb_row_lock", "time", val, db);
else if (strcmp (key, "Innodb_row_lock_waits") == 0)
- counter_submit ("mysql_innodb_row_lock", "waits", val, db);
+ derive_submit ("mysql_innodb_row_lock", "waits", val, db);
/* rows */
else if (strcmp (key, "Innodb_rows_deleted") == 0)
- counter_submit ("mysql_innodb_rows", "deleted", val, db);
+ derive_submit ("mysql_innodb_rows", "deleted", val, db);
else if (strcmp (key, "Innodb_rows_inserted") == 0)
- counter_submit ("mysql_innodb_rows", "inserted", val, db);
+ derive_submit ("mysql_innodb_rows", "inserted", val, db);
else if (strcmp (key, "Innodb_rows_read") == 0)
- counter_submit ("mysql_innodb_rows", "read", val, db);
+ derive_submit ("mysql_innodb_rows", "read", val, db);
else if (strcmp (key, "Innodb_rows_updated") == 0)
- counter_submit ("mysql_innodb_rows", "updated", val, db);
+ derive_submit ("mysql_innodb_rows", "updated", val, db);
}
else if (strncmp (key, "Select_", strlen ("Select_")) == 0)
{
- counter_submit ("mysql_select", key + strlen ("Select_"),
+ derive_submit ("mysql_select", key + strlen ("Select_"),
val, db);
}
else if (strncmp (key, "Sort_", strlen ("Sort_")) == 0)
{
if (strcmp (key, "Sort_merge_passes") == 0)
- counter_submit ("mysql_sort_merge_passes", NULL, val, db);
+ derive_submit ("mysql_sort_merge_passes", NULL, val, db);
else if (strcmp (key, "Sort_rows") == 0)
- counter_submit ("mysql_sort_rows", NULL, val, db);
+ derive_submit ("mysql_sort_rows", NULL, val, db);
else if (strcmp (key, "Sort_range") == 0)
- counter_submit ("mysql_sort", "range", val, db);
+ derive_submit ("mysql_sort", "range", val, db);
else if (strcmp (key, "Sort_scan") == 0)
- counter_submit ("mysql_sort", "scan", val, db);
+ derive_submit ("mysql_sort", "scan", val, db);
}
else if (strncmp (key, "Slow_queries", strlen ("Slow_queries")) == 0)
{
- counter_submit ("mysql_slow_queries", NULL , val, db);
+ derive_submit ("mysql_slow_queries", NULL , val, db);
}
}
mysql_free_result (res); res = NULL;
diff --git a/src/netapp.c b/src/netapp.c
index bf4c286c6a9b5dd8b98a3a8ee096c97ed90aa510..f238a6d0e82a4dd296a13c91e930eb80d6f55feb 100644 (file)
--- a/src/netapp.c
+++ b/src/netapp.c
static int submit_values (const char *host, /* {{{ */
const char *plugin_inst,
const char *type, const char *type_inst,
- value_t *values, int values_len,
+ value_t *values, size_t values_len,
cdtime_t timestamp, cdtime_t interval)
{
value_list_t vl = VALUE_LIST_INIT;
const char *type, const char *type_inst, derive_t counter,
cdtime_t timestamp, cdtime_t interval)
{
- value_t v;
-
- v.derive = counter;
-
return (submit_values (host, plugin_inst, type, type_inst,
- &v, 1, timestamp, interval));
+ &(value_t) { .derive = counter }, 1, timestamp, interval));
} /* }}} int submit_derive */
static int submit_two_gauge (const char *host, const char *plugin_inst, /* {{{ */
const char *type, const char *type_inst, double d,
cdtime_t timestamp, cdtime_t interval)
{
- value_t v;
-
- v.gauge = (gauge_t) d;
-
return (submit_values (host, plugin_inst, type, type_inst,
- &v, 1, timestamp, interval));
+ &(value_t) { .gauge = counter }, 1, timestamp, interval));
} /* }}} int submit_uint64 */
/* Calculate hit ratio from old and new counters and submit the resulting
cdtime_t timestamp,
cdtime_t interval)
{
- value_t v;
+ value_t v = { .gauge = NAN };
if ((new_hits >= old_hits) && (new_misses >= old_misses)) {
uint64_t hits;
misses = new_misses - old_misses;
v.gauge = 100.0 * ((gauge_t) hits) / ((gauge_t) (hits + misses));
- } else {
- v.gauge = NAN;
}
return (submit_values (host, plugin_inst, "cache_ratio", type_inst,
diff --git a/src/netlink.c b/src/netlink.c
index cfca46f7494084de4939288f72a95632c2fcdd44..dee62685558239e91af875c2d1d1560f49cef2f4 100644 (file)
--- a/src/netlink.c
+++ b/src/netlink.c
static void submit_one (const char *dev, const char *type,
const char *type_instance, derive_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "netlink", sizeof (vl.plugin));
diff --git a/src/nginx.c b/src/nginx.c
index 16ce3d5f6ba33d5207b0cbf44f0e0673ea539925..3850accf05c663cce1a7f799781c4142b9b7bd80 100644 (file)
--- a/src/nginx.c
+++ b/src/nginx.c
return;
vl.values = values;
- vl.values_len = 1;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "nginx", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
diff --git a/src/ntpd.c b/src/ntpd.c
index 30f29c97dbfcef7f50afbb8daa1a5d2b67f305e8..ccdecd98302e26362e2c3de949d52f513249c689 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
static void ntpd_submit (const char *type, const char *type_inst, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ntpd", sizeof (vl.plugin));
diff --git a/src/nut.c b/src/nut.c
index b5c6b41b6522142aba73716ed36b5a05e4886608..29074c4ea10fc90adbdd7ecf3d2adbd9e3a21296 100644 (file)
--- a/src/nut.c
+++ b/src/nut.c
static void nut_submit (nut_ups_t *ups, const char *type,
const char *type_instance, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
- vl.values_len = STATIC_ARRAY_SIZE (values);
+ vl.values = &(value_t) { .gauge = value };
+ vl.values_len = 1;
sstrncpy (vl.host,
(strcasecmp (ups->hostname, "localhost") == 0)
? hostname_g
diff --git a/src/olsrd.c b/src/olsrd.c
index 899ad3e8f2ef4e565cb782c4290f8cfbf08f39cf..3bf71280b46b51d4e1690472fac2feb1b4633d93 100644 (file)
--- a/src/olsrd.c
+++ b/src/olsrd.c
static void olsrd_submit (const char *plugin_instance, /* {{{ */
const char *type, const char *type_instance, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
diff --git a/src/onewire.c b/src/onewire.c
index 8bb2d8161de5b3c145556da1f2be0575d95f97b8..0b4b6f56d5e9a148cc9c2b0ae21a8f7e7fa91b7a 100644 (file)
--- a/src/onewire.c
+++ b/src/onewire.c
static int cow_read_values (const char *path, const char *name,
const ow_family_features_t *family_info)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
int success = 0;
return 0;
}
- vl.values = values;
- vl.values_len = 1;
-
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "onewire", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, name, sizeof (vl.plugin_instance));
DEBUG ("Read onewire device %s as %s", file, buffer);
endptr = NULL;
- values[0].gauge = strtod (buffer, &endptr);
+ gauge_t g = strtod (buffer, &endptr);
if (endptr == NULL)
{
ERROR ("onewire plugin: Buffer is not a number: %s", buffer);
sstrncpy (vl.type_instance, family_info->features[i].type_instance,
sizeof (vl.type_instance));
+ vl.values = &(value_t) { .gauge = g };
+ vl.values_len = 1;
+
plugin_dispatch_values (&vl);
success++;
static int cow_simple_read (void)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
char *buffer;
size_t buffer_size;
/* traverse list and check entries */
for (traverse = direct_list; traverse != NULL; traverse = traverse->next)
{
- vl.values = values;
- vl.values_len = 1;
-
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "onewire", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, traverse->address, sizeof (vl.plugin_instance));
}
DEBUG ("onewire plugin: Read onewire device %s as %s", traverse->path, buffer);
-
endptr = NULL;
- values[0].gauge = strtod (buffer, &endptr);
+ gauge_t g = strtod (buffer, &endptr);
if (endptr == NULL)
{
ERROR ("onewire plugin: Buffer is not a number: %s", buffer);
sstrncpy (vl.type, traverse->file, sizeof (vl.type));
sstrncpy (vl.type_instance, "", sizeof (""));
+ vl.values = &(value_t) { .gauge = g };
+ vl.values_len = 1;
+
plugin_dispatch_values (&vl);
free (buffer);
} /* for (traverse) */
diff --git a/src/openldap.c b/src/openldap.c
index 066dabcd1e6e52a03bf7bb5bd265fb133e2cfa80..dd3226d3a193d1478d8f3ec8ce06b0226b01e9fb 100644 (file)
--- a/src/openldap.c
+++ b/src/openldap.c
@@ -192,17 +192,13 @@ static void cldap_submit_value (const char *type, const char *type_instance, /*
static void cldap_submit_derive (const char *type, const char *type_instance, /* {{{ */
derive_t d, cldap_t *st)
{
- value_t v;
- v.derive = d;
- cldap_submit_value (type, type_instance, v, st);
+ cldap_submit_value (type, type_instance, (value_t) { .derive = d }, st);
} /* }}} void cldap_submit_derive */
static void cldap_submit_gauge (const char *type, const char *type_instance, /* {{{ */
gauge_t g, cldap_t *st)
{
- value_t v;
- v.gauge = g;
- cldap_submit_value (type, type_instance, v, st);
+ cldap_submit_value (type, type_instance, (value_t) { .gauge = g }, st);
} /* }}} void cldap_submit_gauge */
static int cldap_read_host (user_data_t *ud) /* {{{ */
diff --git a/src/openvpn.c b/src/openvpn.c
index 00ae736ad4b01c70555f509c0b3580afb8fa8329..69ab9fb14dbf237459cbc19c120a3fdc773589e1 100644 (file)
--- a/src/openvpn.c
+++ b/src/openvpn.c
static void numusers_submit (const char *pinst, const char *tinst,
gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
- vl.values_len = STATIC_ARRAY_SIZE (values);
+ vl.values = &(value_t) { .gauge = value };
+ vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "openvpn", sizeof (vl.plugin));
sstrncpy (vl.type, "users", sizeof (vl.type));
diff --git a/src/pinba.c b/src/pinba.c
index 8a0902aa9c0136a0b6b4dce87498bd55f67b087e..76b765b8c0b4e096398da12601e64f1f4e06fcbf 100644 (file)
--- a/src/pinba.c
+++ b/src/pinba.c
static int plugin_submit (const pinba_statnode_t *res) /* {{{ */
{
- value_t value;
value_list_t vl = VALUE_LIST_INIT;
- vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "pinba", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, res->name, sizeof (vl.plugin_instance));
- value.derive = res->req_count;
+ vl.values = &(value_t) { .derive = res->req_count };
sstrncpy (vl.type, "total_requests", sizeof (vl.type));
plugin_dispatch_values (&vl);
- value.derive = float_counter_get (&res->req_time, /* factor = */ 1000);
+ vl.values = &(value_t) { .derive = float_counter_get (&res->req_time, /* factor = */ 1000) };
sstrncpy (vl.type, "total_time_in_ms", sizeof (vl.type));
plugin_dispatch_values (&vl);
- value.derive = res->doc_size;
+ vl.values = &(value_t) { .derive = res->doc_size };
sstrncpy (vl.type, "total_bytes", sizeof (vl.type));
plugin_dispatch_values (&vl);
- value.derive = float_counter_get (&res->ru_utime, /* factor = */ 100);
+ vl.values = &(value_t) { .derive = float_counter_get (&res->ru_utime, /* factor = */ 100) };
sstrncpy (vl.type, "cpu", sizeof (vl.type));
sstrncpy (vl.type_instance, "user", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
- value.derive = float_counter_get (&res->ru_stime, /* factor = */ 100);
+ vl.values = &(value_t) { .derive = float_counter_get (&res->ru_stime, /* factor = */ 100) };
sstrncpy (vl.type, "cpu", sizeof (vl.type));
sstrncpy (vl.type_instance, "system", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
- value.gauge = res->mem_peak;
+ vl.values = &(value_t) { .gauge = res->mem_peak };
sstrncpy (vl.type, "memory", sizeof (vl.type));
sstrncpy (vl.type_instance, "peak", sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
diff --git a/src/ping.c b/src/ping.c
index 5f66aab341f552cadb2d786bde09784d2272b2be..39e9de51098ce16f2df873fedfe0a4df95880165 100644 (file)
--- a/src/ping.c
+++ b/src/ping.c
static void submit (const char *host, const char *type, /* {{{ */
gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ping", sizeof (vl.plugin));
diff --git a/src/powerdns.c b/src/powerdns.c
index f907d006ed6172a5cf9129ba374e0bffd41a0d4c..eb541800363b2f67a47b6f11812a752bf8b1af3b 100644 (file)
--- a/src/powerdns.c
+++ b/src/powerdns.c
/* <https://doc.powerdns.com/md/recursor/stats/> */
static void submit (const char *plugin_instance, /* {{{ */
- const char *pdns_type, const char *value)
+ const char *pdns_type, const char *value_str)
{
value_list_t vl = VALUE_LIST_INIT;
- value_t values[1];
+ value_t value;
const char *type = NULL;
const char *type_instance = NULL;
if (i >= lookup_table_length)
{
INFO ("powerdns plugin: submit: Not found in lookup table: %s = %s;",
- pdns_type, value);
+ pdns_type, value_str);
return;
}
return;
}
- if (0 != parse_value (value, &values[0], ds->ds[0].type))
+ if (0 != parse_value (value_str, &value, ds->ds[0].type))
{
ERROR ("powerdns plugin: Cannot convert `%s' "
- "to a number.", value);
+ "to a number.", value_str);
return;
}
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "powerdns", sizeof (vl.plugin));
diff --git a/src/processes.c b/src/processes.c
index 0513a156a999d4330ca63599b176abc31b68682d..f07785a18f51631a118cc2becb64fd4d117c4300 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
/* submit global state (e.g.: qty of zombies, running, etc..) */
static void ps_submit_state (const char *state, double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "processes", sizeof (vl.plugin));
#if KERNEL_LINUX || KERNEL_SOLARIS
static void ps_submit_fork_rate (derive_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
sstrncpy(vl.host, hostname_g, sizeof (vl.host));
sstrncpy(vl.plugin, "processes", sizeof (vl.plugin));
diff --git a/src/protocols.c b/src/protocols.c
index 208da8b20f41b9c89e6342c4d7bac71bc81dcfb5..ae35c42533bcf208c8d15829c12f044759974858 100644 (file)
--- a/src/protocols.c
+++ b/src/protocols.c
static void submit (const char *protocol_name,
const char *str_key, const char *str_value)
{
- value_t values[1];
+ value_t value;
value_list_t vl = VALUE_LIST_INIT;
int status;
- status = parse_value (str_value, values, DS_TYPE_DERIVE);
+ status = parse_value (str_value, &value, DS_TYPE_DERIVE);
if (status != 0)
{
ERROR ("protocols plugin: Parsing string as integer failed: %s",
return;
}
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "protocols", sizeof (vl.plugin));
diff --git a/src/redis.c b/src/redis.c
index 5214eccc1e6efc39db7ae37579c6b7d6a5db897f..7f57571ed9f1f5f0c60d13531c39d10a4f76a6ff 100644 (file)
--- a/src/redis.c
+++ b/src/redis.c
const char *type, const char *type_instance,
value_t value) /* {{{ */
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0] = value;
-
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "redis", sizeof (vl.plugin));
diff --git a/src/rrdcached.c b/src/rrdcached.c
index 0425419445d738a6e80992c77c51b229112ca173..07eac7b67c1672a6b1da902a03d0c983d1fe2b41 100644 (file)
--- a/src/rrdcached.c
+++ b/src/rrdcached.c
int status;
rrdc_stats_t *head;
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
+ vl.values = &(value_t) { .gauge = NAN };
+ vl.values_len = 1;
if (daemon_address == NULL)
return (-1);
if (!config_collect_stats)
return (-1);
- vl.values = values;
- vl.values_len = 1;
-
if ((strncmp ("unix:", daemon_address, strlen ("unix:")) == 0)
|| (daemon_address[0] == '/'))
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
for (rrdc_stats_t *ptr = head; ptr != NULL; ptr = ptr->next)
{
if (ptr->type == RRDC_STATS_TYPE_GAUGE)
- values[0].gauge = (gauge_t) ptr->value.gauge;
+ vl.values[0].gauge = (gauge_t) ptr->value.gauge;
else if (ptr->type == RRDC_STATS_TYPE_COUNTER)
- values[0].counter = (counter_t) ptr->value.counter;
+ vl.values[0].counter = (counter_t) ptr->value.counter;
else
continue;
diff --git a/src/sensors.c b/src/sensors.c
index 4f3d0d6032b33b6d3e13d11a3223bbf326efd33b..f13b3ea18f4c294ed30d0d30030bd5d12614c6e9 100644 (file)
--- a/src/sensors.c
+++ b/src/sensors.c
static void sensors_submit (const char *plugin_instance,
const char *type, const char *type_instance,
- double val)
+ double value)
{
char match_key[1024];
int status;
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
status = ssnprintf (match_key, sizeof (match_key), "%s/%s-%s",
return;
}
- values[0].gauge = val;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
diff --git a/src/sigrok.c b/src/sigrok.c
index 400645538d7d842f5d47f422f1347a2be5d7112d..5b850040f30b4f324e29480172b402e7d55a3ea6 100644 (file)
--- a/src/sigrok.c
+++ b/src/sigrok.c
{
const struct sr_datafeed_analog *analog;
struct config_device *cfdev;
- value_t value;
value_list_t vl = VALUE_LIST_INIT;
/* Find this device's configuration. */
/* Ignore all but the first sample on the first probe. */
analog = packet->payload;
- value.gauge = analog->data[0];
- vl.values = &value;
+ vl.values = &(value_t) { .gauge = analog->data[0] };
vl.values_len = 1;
sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "sigrok", sizeof(vl.plugin));
diff --git a/src/smart.c b/src/smart.c
index 752cb74cbe603baf47be59d482c0475983f063a6..5b7a34b31d87d3fe364a322d50f13f177b5095f3 100644 (file)
--- a/src/smart.c
+++ b/src/smart.c
static void smart_submit (const char *dev, const char *type,
const char *type_inst, double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "smart", sizeof (vl.plugin));
diff --git a/src/statsd.c b/src/statsd.c
index 9c138f978bb6dec71e600bf49a72682f62664ab4..82ae387b0c4024b3994ae8042538b36f1628df1b 100644 (file)
--- a/src/statsd.c
+++ b/src/statsd.c
/* Must hold metrics_lock when calling this function. */
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metric) /* {{{ */
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- vl.values = values;
+ vl.values = &(value_t) { .gauge = NAN };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "statsd", sizeof (vl.plugin));
@@ -772,7 +771,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
sstrncpy (vl.type_instance, name, sizeof (vl.type_instance));
if (metric->type == STATSD_GAUGE)
- values[0].gauge = (gauge_t) metric->value;
+ vl.values[0].gauge = (gauge_t) metric->value;
else if (metric->type == STATSD_TIMER)
{
_Bool have_events = (metric->updates_num > 0);
@@ -782,7 +781,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-average", name);
- values[0].gauge = have_events
+ vl.values[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_average (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
@@ -790,7 +789,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
if (conf_timer_lower) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-lower", name);
- values[0].gauge = have_events
+ vl.values[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_min (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
@@ -799,7 +798,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
if (conf_timer_upper) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-upper", name);
- values[0].gauge = have_events
+ vl.values[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_max (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
@@ -808,7 +807,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
if (conf_timer_sum) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-sum", name);
- values[0].gauge = have_events
+ vl.values[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_sum (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
@@ -818,7 +817,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
{
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-percentile-%.0f", name, conf_timer_percentile[i]);
- values[0].gauge = have_events
+ vl.values[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_percentile (metric->latency, conf_timer_percentile[i]))
: NAN;
plugin_dispatch_values (&vl);
@@ -830,7 +829,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
sstrncpy (vl.type, "gauge", sizeof (vl.type));
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-count", name);
- values[0].gauge = latency_counter_get_num (metric->latency);
+ vl.values[0].gauge = latency_counter_get_num (metric->latency);
plugin_dispatch_values (&vl);
}
@@ -840,9 +839,9 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
else if (metric->type == STATSD_SET)
{
if (metric->set == NULL)
- values[0].gauge = 0.0;
+ vl.values[0].gauge = 0.0;
else
- values[0].gauge = (gauge_t) c_avl_size (metric->set);
+ vl.values[0].gauge = (gauge_t) c_avl_size (metric->set);
}
else { /* STATSD_COUNTER */
gauge_t delta = nearbyint (metric->value);
@@ -854,7 +853,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
if (conf_counter_sum)
{
sstrncpy (vl.type, "count", sizeof (vl.type));
- values[0].gauge = delta;
+ vl.values[0].gauge = delta;
plugin_dispatch_values (&vl);
/* restore vl.type */
@@ -866,7 +865,7 @@ static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
metric->value -= delta;
metric->counter += (derive_t) delta;
- values[0].derive = metric->counter;
+ vl.values[0].derive = metric->counter;
}
return (plugin_dispatch_values (&vl));
diff --git a/src/swap.c b/src/swap.c
index 9c63e9bbb56ca82a7e4ce25de7219d79aa8040d2..3cc9516e567c07da468c889610eccd4180e4b220 100644 (file)
--- a/src/swap.c
+++ b/src/swap.c
gauge_t used, gauge_t free,
char const *other_name, gauge_t other_value)
{
- value_t v[1];
value_list_t vl = VALUE_LIST_INIT;
- vl.values = v;
- vl.values_len = STATIC_ARRAY_SIZE (v);
+ vl.values = &(value_t) { .gauge = NAN };
+ vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
if (plugin_instance != NULL)
derive_t value)
{
value_list_t vl = VALUE_LIST_INIT;
- value_t v[1];
- v[0].derive = value;
-
- vl.values = v;
- vl.values_len = STATIC_ARRAY_SIZE (v);
+ vl.values = &(value_t) { .derive = value };
+ vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
sstrncpy (vl.type, "swap_io", sizeof (vl.type));
diff --git a/src/target_v5upgrade.c b/src/target_v5upgrade.c
index f7baa3aee468ce5e1a5cac6f29ea7f2a8ee8ecc9..345ca73f4f0b7d47ee90f64e8b4de436caf58784 100644 (file)
--- a/src/target_v5upgrade.c
+++ b/src/target_v5upgrade.c
static int v5_df (const data_set_t *ds, value_list_t *vl) /* {{{ */
{
value_list_t new_vl;
- value_t new_value;
/* Can't upgrade if both instances have been set. */
if ((vl->plugin_instance[0] != 0)
memcpy (&new_vl, vl, sizeof (new_vl));
/* Reset data we can't simply copy */
- new_vl.values = &new_value;
+ new_vl.values = &(value_t) { .gauge = NAN };
new_vl.values_len = 1;
new_vl.meta = NULL;
static int v5_mysql_qcache (const data_set_t *ds, value_list_t *vl) /* {{{ */
{
value_list_t new_vl;
- value_t new_value;
if (vl->values_len != 5)
return (FC_TARGET_STOP);
memcpy (&new_vl, vl, sizeof (new_vl));
/* Reset data we can't simply copy */
- new_vl.values = &new_value;
+ new_vl.values = &(value_t) { .gauge = NAN };
new_vl.values_len = 1;
new_vl.meta = NULL;
static int v5_mysql_threads (const data_set_t *ds, value_list_t *vl) /* {{{ */
{
value_list_t new_vl;
- value_t new_value;
if (vl->values_len != 4)
return (FC_TARGET_STOP);
memcpy (&new_vl, vl, sizeof (new_vl));
/* Reset data we can't simply copy */
- new_vl.values = &new_value;
+ new_vl.values = &(value_t) { .gauge = NAN };
new_vl.values_len = 1;
new_vl.meta = NULL;
static int v5_zfs_arc_counts (const data_set_t *ds, value_list_t *vl) /* {{{ */
{
value_list_t new_vl;
- value_t new_value;
_Bool is_hits;
if (vl->values_len != 4)
memcpy (&new_vl, vl, sizeof (new_vl));
/* Reset data we can't simply copy */
- new_vl.values = &new_value;
+ new_vl.values = &(value_t) { .gauge = NAN };
new_vl.values_len = 1;
new_vl.meta = NULL;
@@ -322,7 +318,6 @@ static int v5_zfs_arc_l2_bytes (const data_set_t *ds, value_list_t *vl) /* {{{ *
static int v5_zfs_arc_l2_size (const data_set_t *ds, value_list_t *vl) /* {{{ */
{
value_list_t new_vl;
- value_t new_value;
if (vl->values_len != 1)
return (FC_TARGET_STOP);
@@ -331,7 +326,7 @@ static int v5_zfs_arc_l2_size (const data_set_t *ds, value_list_t *vl) /* {{{ */
memcpy (&new_vl, vl, sizeof (new_vl));
/* Reset data we can't simply copy */
- new_vl.values = &new_value;
+ new_vl.values = &(value_t) { .gauge = NAN };
new_vl.values_len = 1;
new_vl.meta = NULL;
@@ -359,7 +354,6 @@ static int v5_zfs_arc_l2_size (const data_set_t *ds, value_list_t *vl) /* {{{ */
static int v5_zfs_arc_ratio (const data_set_t *ds, value_list_t *vl) /* {{{ */
{
value_list_t new_vl;
- value_t new_value;
if (vl->values_len != 1)
return (FC_TARGET_STOP);
memcpy (&new_vl, vl, sizeof (new_vl));
/* Reset data we can't simply copy */
- new_vl.values = &new_value;
+ new_vl.values = &(value_t) { .gauge = NAN };
new_vl.values_len = 1;
new_vl.meta = NULL;
static int v5_zfs_arc_size (const data_set_t *ds, value_list_t *vl) /* {{{ */
{
value_list_t new_vl;
- value_t new_value;
if (vl->values_len != 4)
return (FC_TARGET_STOP);
memcpy (&new_vl, vl, sizeof (new_vl));
/* Reset data we can't simply copy */
- new_vl.values = &new_value;
+ new_vl.values = &(value_t) { .gauge = NAN };
new_vl.values_len = 1;
new_vl.meta = NULL;
diff --git a/src/teamspeak2.c b/src/teamspeak2.c
index a1cde320dd2cb3e9a83f9910da40beb31eefbb43..f5eb26877fe170c57ed6940342595aede5595fe6 100644 (file)
--- a/src/teamspeak2.c
+++ b/src/teamspeak2.c
/*
* Submits a gauge value to the collectd daemon
*/
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "teamspeak2", sizeof (vl.plugin));
diff --git a/src/ted.c b/src/ted.c
index 5ed6c278d0f985f52f1c8267027d501c370bf362..f167546baf755a19cf400f6ac089e36212020806 100644 (file)
--- a/src/ted.c
+++ b/src/ted.c
static void ted_submit (const char *type, double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ted", sizeof (vl.plugin));
diff --git a/src/tokyotyrant.c b/src/tokyotyrant.c
index 7c6d9129e709ee9b71a30a3a57848fc9fca56b06..154215f867bcc16ed0c6e4cec866883628c3af6c 100644 (file)
--- a/src/tokyotyrant.c
+++ b/src/tokyotyrant.c
ecode, tcrdberrmsg(ecode));
}
-static void tt_submit (gauge_t val, const char* type)
+static void tt_submit (gauge_t value, const char* type)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = val;
-
- vl.values = values;
- vl.values_len = STATIC_ARRAY_SIZE (values);
+ vl.values = &(value_t) { .gauge = value };
+ vl.values_len = 1;
sstrncpy (vl.host, config_host, sizeof (vl.host));
sstrncpy (vl.plugin, "tokyotyrant", sizeof (vl.plugin));
diff --git a/src/turbostat.c b/src/turbostat.c
index 7b813c9f1ce8922f29dcaf8374df28d8f3e02364..e74cba285ca2ac6f1834f5137fe74b9368ae401e 100644 (file)
--- a/src/turbostat.c
+++ b/src/turbostat.c
gauge_t value)
{
value_list_t vl = VALUE_LIST_INIT;
- value_t v;
- v.gauge = value;
- vl.values = &v;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, PLUGIN_NAME, sizeof (vl.plugin));
diff --git a/src/uptime.c b/src/uptime.c
index cbe2f8c5dcaf2ebcaf4ff4fc059bbffa684d805e..34c3e85a42bec59b11ff91dc652c8478ed8d50fb 100644 (file)
--- a/src/uptime.c
+++ b/src/uptime.c
extern kstat_ctl_t *kc;
#endif /* #endif HAVE_LIBKSTAT */
-static void uptime_submit (gauge_t uptime)
+static void uptime_submit (gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = uptime;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
diff --git a/src/users.c b/src/users.c
index 30e0dbe67020817ed0d4b2630eb0341f99cdd5be..ce626ae3a902e32d47c410cd354a5afe7b6deb36 100644 (file)
--- a/src/users.c
+++ b/src/users.c
static void users_submit (gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "users", sizeof (vl.plugin));
diff --git a/src/varnish.c b/src/varnish.c
index c2149126bea18963ad9964119ba21ee6b937477f..18f5902fc686a9005fc2fbc15d7f1c4b917bee1d 100644 (file)
--- a/src/varnish.c
+++ b/src/varnish.c
const char *category, const char *type, const char *type_instance,
uint64_t gauge_value)
{
- value_t value;
-
- value.gauge = (gauge_t) gauge_value;
-
- return (varnish_submit (plugin_instance, category, type, type_instance, value));
+ return (varnish_submit (plugin_instance, category, type, type_instance,
+ (value_t) { .gauge = (gauge_t) gauge_value }));
} /* }}} int varnish_submit_gauge */
static int varnish_submit_derive (const char *plugin_instance, /* {{{ */
const char *category, const char *type, const char *type_instance,
uint64_t derive_value)
{
- value_t value;
-
- value.derive = (derive_t) derive_value;
-
- return (varnish_submit (plugin_instance, category, type, type_instance, value));
+ return (varnish_submit (plugin_instance, category, type, type_instance,
+ (value_t) { .derive = (derive_t) derive_value }));
} /* }}} int varnish_submit_derive */
#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
diff --git a/src/virt.c b/src/virt.c
index c1c77bcf135e18ed7e0feff620868915b2a89614..431ac413c45a9d3a163a4352c55b0b5937a6e7ef 100644 (file)
--- a/src/virt.c
+++ b/src/virt.c
} /* void init_value_list */
-static void
-memory_submit (gauge_t memory, virDomainPtr dom)
+static void submit (virDomainPtr dom,
+ char const *type, char const *type_instance,
+ value_t *values, size_t values_len)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
-
init_value_list (&vl, dom);
- values[0].gauge = memory;
-
vl.values = values;
- vl.values_len = 1;
+ vl.values_len = values_len;
- sstrncpy (vl.type, "memory", sizeof (vl.type));
- sstrncpy (vl.type_instance, "total", sizeof (vl.type_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ if (type_instance != NULL)
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
}
static void
-memory_stats_submit (gauge_t memory, virDomainPtr dom, int tag_index)
+memory_submit (gauge_t value, virDomainPtr dom)
+{
+ submit (dom, "memory", "total", &(value_t) { .gauge = value }, 1);
+}
+
+static void
+memory_stats_submit (gauge_t value, virDomainPtr dom, int tag_index)
{
static const char *tags[] = { "swap_in", "swap_out", "major_fault", "minor_fault",
"unused", "available", "actual_balloon", "rss"};
- value_t values[1];
- value_list_t vl = VALUE_LIST_INIT;
-
- init_value_list (&vl, dom);
-
- values[0].gauge = memory;
-
- vl.values = values;
- vl.values_len = 1;
-
- sstrncpy (vl.type, "memory", sizeof (vl.type));
- sstrncpy (vl.type_instance, tags[tag_index], sizeof (vl.type_instance));
+ if ((tag_index < 0) || (tag_index >= STATIC_ARRAY_SIZE (tags))) {
+ ERROR ("virt plugin: Array index out of bounds: tag_index = %d", tag_index);
+ return;
+ }
- plugin_dispatch_values (&vl);
+ submit (dom, "memory", tags[tag_index], &(value_t) { .gauge = value }, 1);
}
static void
-cpu_submit (unsigned long long cpu_time,
+cpu_submit (unsigned long long value,
virDomainPtr dom, const char *type)
{
- value_t values[1];
- value_list_t vl = VALUE_LIST_INIT;
-
- init_value_list (&vl, dom);
-
- values[0].derive = cpu_time;
-
- vl.values = values;
- vl.values_len = 1;
-
- sstrncpy (vl.type, type, sizeof (vl.type));
-
- plugin_dispatch_values (&vl);
+ submit (dom, type, NULL, &(value_t) { .derive = (derive_t) value }, 1);
}
static void
-vcpu_submit (derive_t cpu_time,
+vcpu_submit (derive_t value,
virDomainPtr dom, int vcpu_nr, const char *type)
{
- value_t values[1];
- value_list_t vl = VALUE_LIST_INIT;
-
- init_value_list (&vl, dom);
+ char type_instance[DATA_MAX_NAME_LEN];
- values[0].derive = cpu_time;
- vl.values = values;
- vl.values_len = 1;
-
- sstrncpy (vl.type, type, sizeof (vl.type));
- ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr);
+ ssnprintf (type_instance, sizeof (type_instance), "%d", vcpu_nr);
- plugin_dispatch_values (&vl);
+ submit (dom, type, type_instance, &(value_t) { .derive = value }, 1);
}
static void
diff --git a/src/vserver.c b/src/vserver.c
index a730593654bb79c3c0d6b58d69aef812ef2cb838..c7adc5c4d966e53d710276e37c1e95e9fb022823 100644 (file)
--- a/src/vserver.c
+++ b/src/vserver.c
const char *type_instance, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
- vl.values_len = STATIC_ARRAY_SIZE (values);
+ vl.values = &(value_t) { .gauge = value };
+ vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
diff --git a/src/wireless.c b/src/wireless.c
index b998462598fd764c1214ebf5c7d07a7fae81a44d..7d57fea9dc926e3a4423050a26b6428fd0aade53 100644 (file)
--- a/src/wireless.c
+++ b/src/wireless.c
static void wireless_submit (const char *plugin_instance, const char *type,
double value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "wireless", sizeof (vl.plugin));
diff --git a/src/xencpu.c b/src/xencpu.c
index f1cd938810ac80b1640004ff98916e349a4b8229..93575df22887ff9e3935f9ee741654918079807b 100644 (file)
--- a/src/xencpu.c
+++ b/src/xencpu.c
return 0;
} /* static int xencpu_shutdown */
-static void submit_value (int cpu_num, gauge_t percent)
+static void submit_value (int cpu_num, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = percent;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
int status;
for (int cpu = 0; cpu < nr_cpus; cpu++) {
gauge_t rate = NAN;
- value_t value = {.derive = cpu_info[cpu].idletime};
- status = value_to_rate (&rate, value, DS_TYPE_DERIVE, now, &cpu_states[cpu]);
+ status = value_to_rate (&rate,
+ (value_t) { .derive = cpu_info[cpu].idletime }, DS_TYPE_DERIVE,
+ now, &cpu_states[cpu]);
if (status == 0) {
submit_value(cpu, 100 - rate/10000000);
}
diff --git a/src/xmms.c b/src/xmms.c
index 353599502fe5f53f3193fbc59ccac2a38ef8f24a..2ba30827c608a9ab1c93cbf1373cf1aa43f727a4 100644 (file)
--- a/src/xmms.c
+++ b/src/xmms.c
static void cxmms_submit (const char *type, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "xmms", sizeof (vl.plugin));
diff --git a/src/zfs_arc.c b/src/zfs_arc.c
index 8261282a825e1fc5ea13dea2bfacf222a35b4037..e2d2da4c5deb321319c19d8e09b23984cd7fce1a 100644 (file)
--- a/src/zfs_arc.c
+++ b/src/zfs_arc.c
}
#endif
-static void za_submit (const char* type, const char* type_instance, value_t* values, int values_len)
+static void za_submit (const char* type, const char* type_instance, value_t* values, size_t values_len)
{
value_list_t vl = VALUE_LIST_INIT;
@@ -155,45 +155,34 @@ static void za_submit (const char* type, const char* type_instance, value_t* val
static void za_submit_gauge (const char* type, const char* type_instance, gauge_t value)
{
- value_t vv;
-
- vv.gauge = value;
- za_submit (type, type_instance, &vv, 1);
+ za_submit (type, type_instance, &(value_t) { .gauge = value }, 1);
}
static int za_read_derive (kstat_t *ksp, const char *kstat_value,
const char *type, const char *type_instance)
{
- long long tmp;
- value_t v;
-
- tmp = get_zfs_value (ksp, (char *)kstat_value);
+ long long tmp = get_zfs_value (ksp, (char *)kstat_value);
if (tmp == -1LL)
{
WARNING ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
return (-1);
}
- v.derive = (derive_t) tmp;
- za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1);
+ za_submit (type, type_instance, &(value_t) { .derive = (derive_t) tmp }, /* values_num = */ 1);
return (0);
}
static int za_read_gauge (kstat_t *ksp, const char *kstat_value,
const char *type, const char *type_instance)
{
- long long tmp;
- value_t v;
-
- tmp = get_zfs_value (ksp, (char *)kstat_value);
+ long long tmp = get_zfs_value (ksp, (char *)kstat_value);
if (tmp == -1LL)
{
WARNING ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
return (-1);
}
- v.gauge = (gauge_t) tmp;
- za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1);
+ za_submit (type, type_instance, &(value_t) { .gauge = (gauge_t) tmp }, /* values_num = */ 1);
return (0);
}
diff --git a/src/zookeeper.c b/src/zookeeper.c
index 84174853d24c62bd8ba22aaa17bc28e5f68aaa3d..7e551918d2303b5fa68d759a63cc981e4ef20f86 100644 (file)
--- a/src/zookeeper.c
+++ b/src/zookeeper.c
return 0;
}
-static void zookeeper_submit_gauge (const char * type, const char * type_inst, gauge_t val)
+static void zookeeper_submit_gauge (const char * type, const char * type_inst, gauge_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = val;
-
- vl.values = values;
+ vl.values = &(value_t) { .gauge = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "zookeeper", sizeof (vl.plugin));
@@ -84,14 +81,11 @@ static void zookeeper_submit_gauge (const char * type, const char * type_inst, g
plugin_dispatch_values (&vl);
} /* zookeeper_submit_gauge */
-static void zookeeper_submit_derive (const char * type, const char * type_inst, derive_t val)
+static void zookeeper_submit_derive (const char * type, const char * type_inst, derive_t value)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = val;
-
- vl.values = values;
+ vl.values = &(value_t) { .derive = value };
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "zookeeper", sizeof (vl.plugin));