const char *type,
derive_t read, derive_t write)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = read;
- values[1].derive = write;
+ value_t values[] = {
+ { .derive = read },
+ { .derive = write },
+ };
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, plugin_instance,
#if KERNEL_FREEBSD || KERNEL_LINUX
static void submit_io_time (char const *plugin_instance, derive_t io_time, derive_t weighted_time)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = io_time;
- values[1].derive = weighted_time;
+ value_t values[] = {
+ { .derive = io_time },
+ { .derive = weighted_time },
+ };
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
static void submit_octets (derive_t queries, derive_t responses)
{
- value_t values[2];
+ value_t values[] = {
+ { .derive = queries },
+ { .derive = responses },
+ };
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = queries;
- values[1].derive = responses;
-
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "dns", sizeof (vl.plugin));
sstrncpy (vl.type, "dns_octets", sizeof (vl.type));
static void submit_hp(const char *plug_inst, const char *type,
const char *type_instance, gauge_t free_value, gauge_t used_value)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].gauge = free_value;
- values[1].gauge = used_value;
+ value_t values[] = {
+ { .gauge = free_value },
+ { .gauge = used_value },
+ };
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, g_plugin_name, sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, plug_inst, sizeof (vl.plugin_instance));
derive_t rx,
derive_t tx)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
if (ignorelist_match (ignorelist, dev) != 0)
return;
- values[0].derive = rx;
- values[1].derive = tx;
-
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "interface", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
static void cipvs_submit_if (const char *pi, const char *t, const char *ti,
derive_t rx, derive_t tx)
{
- value_t values[2];
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = rx;
- values[1].derive = tx;
-
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "ipvs", sizeof (vl.plugin));
}
static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum)
{
- value_t values[3];
- value_list_t vl = VALUE_LIST_INIT;
int cores = 0;
char errbuf[1024];
lnum /= cores;
}
- values[0].gauge = snum;
- values[1].gauge = mnum;
- values[2].gauge = lnum;
+ value_list_t vl = VALUE_LIST_INIT;
+ value_t values[] = {
+ { .gauge = snum },
+ { .gauge = mnum },
+ { .gauge = lnum },
+ };
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
static void submit_derive2 (const char *dev, const char *type, const char *ti1,
const char *ti2, derive_t val1, derive_t val2)
{
- value_t items[2];
- items[0].derive = val1;
- items[1].derive = val2;
- submit (dev, type, ti1, ti2, items, 2);
+ value_t values[] = {
+ { .derive = val1 },
+ { .derive = val2 },
+ };
+
+ submit (dev, type, ti1, ti2, values, STATIC_ARRAY_SIZE (values));
}
static void submit_gauge (const char *dev, const char *type, const char *ti1,
static void submit_derive2 (const char *type, const char *type_inst,
derive_t value0, derive_t value1, memcached_t *st)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- memcached_init_vl (&vl, st);
-
- values[0].derive = value0;
- values[1].derive = value1;
+ value_t values[] = {
+ { .derive = value0 },
+ { .derive = value1 },
+ };
+ memcached_init_vl (&vl, st);
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
static void submit_gauge2 (const char *type, const char *type_inst,
gauge_t value0, gauge_t value1, memcached_t *st)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- memcached_init_vl (&vl, st);
-
- values[0].gauge = value0;
- values[1].gauge = value1;
+ value_t values[] = {
+ { .gauge = value0 },
+ { .gauge = value1 },
+ };
+ memcached_init_vl (&vl, st);
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
static void traffic_submit (derive_t rx, derive_t tx, mysql_database_t *db)
{
- value_t values[2];
-
- values[0].derive = rx;
- values[1].derive = tx;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
submit ("mysql_octets", NULL, values, STATIC_ARRAY_SIZE (values), db);
} /* void traffic_submit */
const char *type, const char *type_inst, derive_t val0, derive_t val1,
cdtime_t timestamp, cdtime_t interval)
{
- value_t values[2];
-
- values[0].derive = val0;
- values[1].derive = val1;
+ value_t values[] = {
+ { .derive = val0 },
+ { .derive = val1 },
+ };
return (submit_values (host, plugin_inst, type, type_inst,
- values, 2, timestamp, interval));
+ values, STATIC_ARRAY_SIZE (values), timestamp, interval));
} /* }}} int submit_two_derive */
static int submit_derive (const char *host, const char *plugin_inst, /* {{{ */
const char *type, const char *type_inst, gauge_t val0, gauge_t val1,
cdtime_t timestamp, cdtime_t interval)
{
- value_t values[2];
-
- values[0].gauge = val0;
- values[1].gauge = val1;
+ value_t values[] = {
+ { .gauge = val0 },
+ { .gauge = val1 },
+ };
return (submit_values (host, plugin_inst, type, type_inst,
- values, 2, timestamp, interval));
+ values, STATIC_ARRAY_SIZE (values), timestamp, interval));
} /* }}} int submit_two_gauge */
static int submit_double (const char *host, const char *plugin_inst, /* {{{ */
const char *type_instance,
derive_t rx, derive_t tx)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = rx;
- values[1].derive = tx;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "netlink", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
static void iostats_submit (const char *pinst, const char *tinst,
derive_t rx, derive_t tx)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = rx;
- values[1].derive = tx;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
/* NOTE ON THE NEW NAMING SCHEMA:
* using plugin_instance to identify each vpn config (and
static void compression_submit (const char *pinst, const char *tinst,
derive_t uncompressed, derive_t compressed)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = uncompressed;
- values[1].derive = compressed;
+ value_t values[] = {
+ { .derive = uncompressed },
+ { .derive = compressed },
+ };
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
/* submit info about specific process (e.g.: memory taken, cpu usage, etc..) */
static void ps_submit_proc_list (procstat_t *ps)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
+ value_t values[2];
vl.values = values;
- vl.values_len = 2;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "processes", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance));
static void cr_submit_io (cr_data_t *rd, const char *type, /* {{{ */
const char *type_instance, derive_t rx, derive_t tx)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = rx;
- values[1].derive = tx;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
static void serial_submit (const char *type_instance,
derive_t rx, derive_t tx)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = rx;
- values[1].derive = tx;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "serial", sizeof (vl.plugin));
sstrncpy (vl.type, "serial_octets", sizeof (vl.type));
void* userdata)
{
const char *dev = userdata;
- value_t values[4];
- value_list_t vl = VALUE_LIST_INIT;
- if (!a->current_value_valid || !a->worst_value_valid) return;
- values[0].gauge = a->current_value;
- values[1].gauge = a->worst_value;
- values[2].gauge = a->threshold_valid?a->threshold:0;
- values[3].gauge = a->pretty_value;
+ if (!a->current_value_valid || !a->worst_value_valid)
+ return;
+
+ value_list_t vl = VALUE_LIST_INIT;
+ value_t values[] = {
+ { .gauge = a->current_value },
+ { .gauge = a->worst_value },
+ { .gauge = a->threshold_valid ? a->threshold : 0 },
+ { .gauge = a->pretty_value },
+ };
vl.values = values;
- vl.values_len = 4;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "smart", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
const char *type,
derive_t read, derive_t write)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = read;
- values[1].derive = write;
+ value_t values[] = {
+ { .derive = read },
+ { .derive = write },
+ };
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "tape", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, plugin_instance,
static int v5_zfs_arc_l2_bytes (const data_set_t *ds, value_list_t *vl) /* {{{ */
{
value_list_t new_vl;
- value_t new_values[2];
if (vl->values_len != 2)
return (FC_TARGET_STOP);
memcpy (&new_vl, vl, sizeof (new_vl));
/* Reset data we can't simply copy */
- new_vl.values = new_values;
- new_vl.values_len = 2;
new_vl.meta = NULL;
/* Change the type/-instance to "io_octets-L2" */
sstrncpy (new_vl.type_instance, "L2", sizeof (new_vl.type_instance));
/* Copy the actual values. */
- new_vl.values[0].derive = (derive_t) vl->values[0].counter;
- new_vl.values[1].derive = (derive_t) vl->values[1].counter;
+ value_t values[] = {
+ { .derive = (derive_t) vl->values[0].counter },
+ { .derive = (derive_t) vl->values[1].counter },
+ };
+ new_vl.values = values;
+ new_vl.values_len = STATIC_ARRAY_SIZE (values);
/* Dispatch new value lists instead of this one */
plugin_dispatch_values (&new_vl);
/*
* Submits the io rx/tx tuple to the collectd daemon
*/
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = rx;
- values[1].derive = tx;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
vl.values = values;
- vl.values_len = 2;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "teamspeak2", sizeof (vl.plugin));
submit_derive2 (const char *type, derive_t v0, derive_t v1,
virDomainPtr dom, const char *devname)
{
- value_t values[2];
- value_list_t vl = VALUE_LIST_INIT;
-
- init_value_list (&vl, dom);
-
- values[0].derive = v0;
- values[1].derive = v1;
- vl.values = values;
- vl.values_len = 2;
-
- sstrncpy (vl.type, type, sizeof (vl.type));
- sstrncpy (vl.type_instance, devname, sizeof (vl.type_instance));
+ value_t values[] = {
+ { .derive = v0 },
+ { .derive = v1 },
+ };
- plugin_dispatch_values (&vl);
+ submit (dom, type, devname, values, STATIC_ARRAY_SIZE (values));
} /* void submit_derive2 */
static int
static void submit_two (const char *plugin_instance, const char *type,
const char *type_instance, derive_t c0, derive_t c1)
{
- value_t values[2];
+ value_t values[] = {
+ { .derive = c0 },
+ { .derive = c1 },
+ };
- values[0].derive = c0;
- values[1].derive = c1;
-
- submit (plugin_instance, type, type_instance, values, 2);
+ submit (plugin_instance, type, type_instance,
+ values, STATIC_ARRAY_SIZE (values));
} /* void submit_one */
static void submit_one (const char *plugin_instance, const char *type,
static void traffic_submit (const char *plugin_instance,
const char *type_instance, derive_t rx, derive_t tx)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = rx;
- values[1].derive = tx;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
static void load_submit (const char *plugin_instance,
gauge_t snum, gauge_t mnum, gauge_t lnum)
{
- value_t values[3];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].gauge = snum;
- values[1].gauge = mnum;
- values[2].gauge = lnum;
+ value_t values[] = {
+ { .gauge = snum },
+ { .gauge = mnum },
+ { .gauge = lnum },
+ };
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
static int za_read (void)
{
gauge_t arc_hits, arc_misses, l2_hits, l2_misses;
- value_t l2_io[2];
kstat_t *ksp = NULL;
#if defined(KERNEL_LINUX)
za_submit_ratio ("L2", l2_hits, l2_misses);
/* I/O */
- l2_io[0].derive = get_zfs_value(ksp, "l2_read_bytes");
- l2_io[1].derive = get_zfs_value(ksp, "l2_write_bytes");
-
- za_submit ("io_octets", "L2", l2_io, /* num values = */ 2);
+ value_t l2_io[] = {
+ { .derive = (derive_t) get_zfs_value(ksp, "l2_read_bytes") },
+ { .derive = (derive_t) get_zfs_value(ksp, "l2_write_bytes") },
+ };
+ za_submit ("io_octets", "L2", l2_io, STATIC_ARRAY_SIZE (l2_io));
#if defined(KERNEL_LINUX)
free_zfs_values (ksp);