/**
* collectd - src/bind.c
- * Copyright (C) 2009 Bruno Prémont
- * Copyright (C) 2009 Florian Forster
+ * Copyright (C) 2009 Bruno Prémont
+ * Copyright (C) 2009,2010 Florian Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* Authors:
* Bruno Prémont <bonbons at linux-vserver.org>
- * Florian Forster <octo at verplant.org>
+ * Florian Forster <octo at collectd.org>
**/
#include "config.h"
return (0);
} /* }}} int bind_xml_list_callback */
-static int bind_xml_read_counter (xmlDoc *doc, xmlNode *node, /* {{{ */
- counter_t *ret_value)
+static int bind_xml_read_derive (xmlDoc *doc, xmlNode *node, /* {{{ */
+ derive_t *ret_value)
{
- char *str_ptr, *end_ptr;
- long long int value;
+ char *str_ptr;
+ value_t value;
+ int status;
str_ptr = (char *) xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
if (str_ptr == NULL)
{
- ERROR ("bind plugin: bind_xml_read_counter: xmlNodeListGetString failed.");
+ ERROR ("bind plugin: bind_xml_read_derive: xmlNodeListGetString failed.");
return (-1);
}
- errno = 0;
- value = strtoll (str_ptr, &end_ptr, 10);
- xmlFree(str_ptr);
- if (str_ptr == end_ptr || errno)
+ status = parse_value (str_ptr, &value, DS_TYPE_DERIVE);
+ if (status != 0)
{
- if (errno && (value < 0))
- ERROR ("bind plugin: bind_xml_read_counter: strtoll failed with underflow.");
- else if (errno && (value > 0))
- ERROR ("bind plugin: bind_xml_read_counter: strtoll failed with overflow.");
- else
- ERROR ("bind plugin: bind_xml_read_counter: strtoll failed.");
+ ERROR ("bind plugin: Parsing string \"%s\" to derive value failed.",
+ str_ptr);
return (-1);
}
- *ret_value = value;
+ *ret_value = value.derive;
return (0);
-} /* }}} int bind_xml_read_counter */
+} /* }}} int bind_xml_read_derive */
static int bind_xml_read_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */
gauge_t *ret_value)
if (ds_type == DS_TYPE_GAUGE)
status = bind_xml_read_gauge (doc, counter, &value.gauge);
else
- status = bind_xml_read_counter (doc, counter, &value.counter);
+ status = bind_xml_read_derive (doc, counter, &value.derive);
if (status != 0)
continue;
if (ds_type == DS_TYPE_GAUGE)
status = bind_xml_read_gauge (doc, child, &value.gauge);
else
- status = bind_xml_read_counter (doc, child, &value.counter);
+ status = bind_xml_read_derive (doc, child, &value.derive);
if (status != 0)
continue;
#define PCAP_SNAPLEN 1460
static char *pcap_device = NULL;
-static counter_t tr_queries;
-static counter_t tr_responses;
+static derive_t tr_queries;
+static derive_t tr_responses;
static counter_list_t *qtype_list;
static counter_list_t *opcode_list;
static counter_list_t *rcode_list;
return (0);
} /* int dns_init */
-static void submit_counter (const char *type, const char *type_instance,
- counter_t value)
+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].counter = value;
+ values[0].derive = value;
vl.values = values;
vl.values_len = 1;
sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
-} /* void submit_counter */
+} /* void submit_derive */
-static void submit_octets (counter_t queries, counter_t responses)
+static void submit_octets (derive_t queries, derive_t responses)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = queries;
- values[1].counter = responses;
+ values[0].derive = queries;
+ values[1].derive = responses;
vl.values = values;
vl.values_len = 2;
sstrncpy (vl.type, "dns_octets", sizeof (vl.type));
plugin_dispatch_values (&vl);
-} /* void submit_counter */
+} /* void submit_octets */
static int dns_read (void)
{
for (i = 0; i < len; i++)
{
DEBUG ("dns plugin: qtype = %u; counter = %u;", keys[i], values[i]);
- submit_counter ("dns_qtype", qtype_str (keys[i]), values[i]);
+ submit_derive ("dns_qtype", qtype_str (keys[i]), values[i]);
}
pthread_mutex_lock (&opcode_mutex);
for (i = 0; i < len; i++)
{
DEBUG ("dns plugin: opcode = %u; counter = %u;", keys[i], values[i]);
- submit_counter ("dns_opcode", opcode_str (keys[i]), values[i]);
+ submit_derive ("dns_opcode", opcode_str (keys[i]), values[i]);
}
pthread_mutex_lock (&rcode_mutex);
for (i = 0; i < len; i++)
{
DEBUG ("dns plugin: rcode = %u; counter = %u;", keys[i], values[i]);
- submit_counter ("dns_rcode", rcode_str (keys[i]), values[i]);
+ submit_derive ("dns_rcode", rcode_str (keys[i]), values[i]);
}
return (0);
/**
* collectd - src/gmond.c
- * Copyright (C) 2009 Florian octo Forster
+ * Copyright (C) 2009,2010 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
**/
#include "collectd.h"
se->vl.values[ds_index].derive += value.derive;
else if (ds_type == DS_TYPE_ABSOLUTE)
se->vl.values[ds_index].absolute = value.absolute;
+ else
+ assert (23 == 42);
se->flags |= (0x01 << ds_index);
case gmetric_string:
{
Ganglia_gmetric_string msg_string;
- char *endptr;
+ int status;
msg_string = msg->Ganglia_value_msg_u.gstr;
host = msg_string.metric_id.host;
name = msg_string.metric_id.name;
- endptr = NULL;
- errno = 0;
- value_counter.counter = (counter_t) strtoull (msg_string.str,
- &endptr, /* base = */ 0);
- if ((endptr == msg_string.str) || (errno != 0))
- value_counter.counter = -1;
-
- endptr = NULL;
- errno = 0;
- value_gauge.gauge = (gauge_t) strtod (msg_string.str, &endptr);
- if ((endptr == msg_string.str) || (errno != 0))
+ status = parse_value (msg_string.str, &value_derive, DS_TYPE_DERIVE);
+ if (status != 0)
+ value_derive.derive = -1;
+
+ status = parse_value (msg_string.str, &value_gauge, DS_TYPE_GAUGE);
+ if (status != 0)
value_gauge.gauge = NAN;
- endptr = NULL;
- errno = 0;
- value_derive.derive = (derive_t) strtoll (msg_string.str,
- &endptr, /* base = */ 0);
- if ((endptr == msg_string.str) || (errno != 0))
- value_derive.derive = 0;
+ status = parse_value (msg_string.str, &value_counter, DS_TYPE_COUNTER);
+ if (status != 0)
+ value_counter.counter = 0;
break;
}
{
value_t val_copy;
- val_copy = value_counter;
+ if ((map->ds_type == DS_TYPE_COUNTER)
+ || (map->ds_type == DS_TYPE_ABSOLUTE))
+ val_copy = value_counter;
if (map->ds_type == DS_TYPE_GAUGE)
val_copy = value_gauge;
else if (map->ds_type == DS_TYPE_DERIVE)
val_copy = value_derive;
+ else
+ assert (23 == 42);
return (staging_entry_update (host, name,
map->type, map->type_instance,
/**
* collectd - src/iptables.c
- * Copyright (C) 2007 Sjoerd van der Berg
- * Copyright (C) 2007 Florian octo Forster
- * Copyright (C) 2009 Marco Chiappero
+ * Copyright (C) 2007 Sjoerd van der Berg
+ * Copyright (C) 2007-2010 Florian octo Forster
+ * Copyright (C) 2009 Marco Chiappero
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* Authors:
* Sjoerd van der Berg <harekiet at users.sourceforge.net>
- * Florian Forster <octo at verplant.org>
+ * Florian Forster <octo at collectd.org>
* Marco Chiappero <marco at absence.it>
**/
}
sstrncpy (vl.type, "ipt_bytes", sizeof (vl.type));
- values[0].counter = (counter_t) entry->counters.bcnt;
+ values[0].derive = (derive_t) entry->counters.bcnt;
plugin_dispatch_values (&vl);
sstrncpy (vl.type, "ipt_packets", sizeof (vl.type));
- values[0].counter = (counter_t) entry->counters.pcnt;
+ values[0].derive = (derive_t) entry->counters.pcnt;
plugin_dispatch_values (&vl);
return (0);
}
sstrncpy (vl.type, "ipt_bytes", sizeof (vl.type));
- values[0].counter = (counter_t) entry->counters.bcnt;
+ values[0].derive = (derive_t) entry->counters.bcnt;
plugin_dispatch_values (&vl);
sstrncpy (vl.type, "ipt_packets", sizeof (vl.type));
- values[0].counter = (counter_t) entry->counters.pcnt;
+ values[0].derive = (derive_t) entry->counters.pcnt;
plugin_dispatch_values (&vl);
return (0);
return 0;
} /* get_ti */
-static void cipvs_submit_connections (char *pi, char *ti, counter_t value)
+static void cipvs_submit_connections (char *pi, char *ti, derive_t value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = value;
+ values[0].derive = value;
vl.values = values;
vl.values_len = 1;
} /* cipvs_submit_connections */
static void cipvs_submit_if (char *pi, char *t, char *ti,
- counter_t rx, counter_t tx)
+ derive_t rx, derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
vl.values = values;
vl.values_len = 2;
return (1 - irq_list_action);
}
-static void irq_submit (unsigned int irq, counter_t value)
+static void irq_submit (unsigned int irq, derive_t value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
if (check_ignore_irq (irq))
return;
- values[0].counter = value;
+ values[0].derive = value;
vl.values = values;
vl.values_len = 1;
static int irq_read (void)
{
-#undef BUFSIZE
-#define BUFSIZE 256
-
FILE *fh;
- char buffer[BUFSIZE];
- unsigned int irq;
- unsigned long long irq_value;
- unsigned long long value;
- char *endptr;
- int i;
+ char buffer[1024];
- char *fields[64];
- int fields_num;
-
- if ((fh = fopen ("/proc/interrupts", "r")) == NULL)
+ fh = fopen ("/proc/interrupts", "r");
+ if (fh == NULL)
{
char errbuf[1024];
- WARNING ("irq plugin: fopen (/proc/interrupts): %s",
+ ERROR ("irq plugin: fopen (/proc/interrupts): %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
+
while (fgets (buffer, BUFSIZE, fh) != NULL)
{
+ unsigned int irq;
+ derive_t irq_value;
+ char *endptr;
+ int i;
+
+ char *fields[64];
+ int fields_num;
+
fields_num = strsplit (buffer, fields, 64);
if (fields_num < 2)
continue;
errno = 0; /* To distinguish success/failure after call */
- irq = strtol (fields[0], &endptr, 10);
+ irq = (unsigned int) strtoul (fields[0], &endptr, /* base = */ 10);
if ((endptr == fields[0]) || (errno != 0) || (*endptr != ':'))
continue;
irq_value = 0;
for (i = 1; i < fields_num; i++)
{
- errno = 0;
- value = strtoull (fields[i], &endptr, 10);
+ /* Per-CPU value */
+ value_t v;
+ int status;
- if ((*endptr != '\0') || (errno != 0))
+ status = parse_value (fields[i], &v, DS_TYPE_DERIVE);
+ if (status != 0)
break;
- irq_value += value;
+ irq_value += v.derive;
} /* for (i) */
- /* Force 32bit wrap-around */
- irq_submit (irq, irq_value % 4294967296ULL);
+ if (i < fields_num)
+ continue;
+
+ irq_submit (irq, irq_value);
}
fclose (fh);
init_value_list (&vl, dom);
- values[0].counter = cpu_time;
+ values[0].derive = cpu_time;
vl.values = values;
vl.values_len = 1;
}
static void
-vcpu_submit (counter_t cpu_time,
+vcpu_submit (derive_t cpu_time,
virDomainPtr dom, int vcpu_nr, const char *type)
{
value_t values[1];
init_value_list (&vl, dom);
- values[0].counter = cpu_time;
+ values[0].derive = cpu_time;
vl.values = values;
vl.values_len = 1;
}
static void
-submit_counter2 (const char *type, counter_t v0, counter_t v1,
+submit_derive2 (const char *type, derive_t v0, derive_t v1,
virDomainPtr dom, const char *devname)
{
value_t values[2];
init_value_list (&vl, dom);
- values[0].counter = v0;
- values[1].counter = v1;
+ values[0].derive = v0;
+ values[1].derive = v1;
vl.values = values;
vl.values_len = 2;
sstrncpy (vl.type_instance, devname, sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
-} /* void submit_counter2 */
+} /* void submit_derive2 */
static int
lv_init (void)
continue;
if ((stats.rd_req != -1) && (stats.wr_req != -1))
- submit_counter2 ("disk_ops",
- (counter_t) stats.rd_req, (counter_t) stats.wr_req,
+ submit_derive2 ("disk_ops",
+ (derive_t) stats.rd_req, (derive_t) stats.wr_req,
block_devices[i].dom, block_devices[i].path);
if ((stats.rd_bytes != -1) && (stats.wr_bytes != -1))
- submit_counter2 ("disk_octets",
- (counter_t) stats.rd_bytes, (counter_t) stats.wr_bytes,
+ submit_derive2 ("disk_octets",
+ (derive_t) stats.rd_bytes, (derive_t) stats.wr_bytes,
block_devices[i].dom, block_devices[i].path);
} /* for (nr_block_devices) */
continue;
if ((stats.rx_bytes != -1) && (stats.tx_bytes != -1))
- submit_counter2 ("if_octets",
- (counter_t) stats.rx_bytes, (counter_t) stats.tx_bytes,
+ submit_derive2 ("if_octets",
+ (derive_t) stats.rx_bytes, (derive_t) stats.tx_bytes,
interface_devices[i].dom, display_name);
if ((stats.rx_packets != -1) && (stats.tx_packets != -1))
- submit_counter2 ("if_packets",
- (counter_t) stats.rx_packets, (counter_t) stats.tx_packets,
+ submit_derive2 ("if_packets",
+ (derive_t) stats.rx_packets, (derive_t) stats.tx_packets,
interface_devices[i].dom, display_name);
if ((stats.rx_errs != -1) && (stats.tx_errs != -1))
- submit_counter2 ("if_errors",
- (counter_t) stats.rx_errs, (counter_t) stats.tx_errs,
+ submit_derive2 ("if_errors",
+ (derive_t) stats.rx_errs, (derive_t) stats.tx_errs,
interface_devices[i].dom, display_name);
if ((stats.rx_drop != -1) && (stats.tx_drop != -1))
- submit_counter2 ("if_dropped",
- (counter_t) stats.rx_drop, (counter_t) stats.tx_drop,
+ submit_derive2 ("if_dropped",
+ (derive_t) stats.rx_drop, (derive_t) stats.tx_drop,
interface_devices[i].dom, display_name);
} /* for (nr_interface_devices) */
plugin_dispatch_values (&vl);
}
-static void submit_counter (const char *dev, const char *type, const char *ti1,
- const char *ti2, counter_t val)
+static void submit_derive (const char *dev, const char *type, const char *ti1,
+ const char *ti2, derive_t val)
{
value_t item;
- item.counter = val;
+ item.derive = val;
submit (dev, type, ti1, ti2, &item, 1);
}
-static void submit_counter2 (const char *dev, const char *type, const char *ti1,
- const char *ti2, counter_t val1, counter_t val2)
+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].counter = val1;
- items[1].counter = val2;
+ items[0].derive = val1;
+ items[1].derive = val2;
submit (dev, type, ti1, ti2, items, 2);
}
continue;
ssnprintf (ti2, sizeof (ti2), "%i", i);
- submit_counter (dev, "ath_stat", name, ti2,
- (counter_t) vals[i]);
+ submit_derive (dev, "ath_stat", name, ti2,
+ (derive_t) vals[i]);
}
}
uint32_t val = *(uint32_t *)(((char *) ptr) + specs[i].offset) ;
if (item_watched (i) && (val != 0))
- submit_counter (dev, type_name, specs[i].name, mac, val);
+ submit_derive (dev, type_name, specs[i].name, mac, val);
if (item_summed (i))
misc += val;
}
if (misc != 0)
- submit_counter (dev, type_name, misc_name, mac, misc);
+ submit_derive (dev, type_name, misc_name, mac, misc);
}
/* These two stats are handled as a special case as they are
a pair of 64bit values */
if (item_watched (STAT_NODE_OCTETS))
- submit_counter2 (dev, "node_octets", mac, NULL,
+ submit_derive2 (dev, "node_octets", mac, NULL,
ns->ns_rx_bytes, ns->ns_tx_bytes);
/* This stat is handled as a special case, because it is stored
as uin64_t, but we will ignore upper half */
if (item_watched (STAT_NS_RX_BEACONS))
- submit_counter (dev, "node_stat", "ns_rx_beacons", mac,
+ submit_derive (dev, "node_stat", "ns_rx_beacons", mac,
(ns->ns_rx_beacons & 0xFFFFFFFF));
/* All other node statistics */
/**
* collectd - src/memcached.c, based on src/hddtemp.c
* Copyright (C) 2007 Antony Dovgal
- * Copyright (C) 2007-2009 Florian Forster
+ * Copyright (C) 2007-2010 Florian Forster
* Copyright (C) 2009 Doug MacEachern
* Copyright (C) 2009 Franck Lombardi
*
*
* Authors:
* Antony Dovgal <tony at daylessday dot org>
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
* Doug MacEachern <dougm at hyperic.com>
* Franck Lombardi
**/
}
/* }}} */
-static void submit_counter (const char *type, const char *type_inst,
- counter_t value) /* {{{ */
+static void 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].counter = value;
+ values[0].derive = value;
vl.values = values;
vl.values_len = 1;
} /* void memcached_submit_cmd */
/* }}} */
-static void submit_counter2 (const char *type, const char *type_inst,
- counter_t value0, counter_t value1) /* {{{ */
+static void submit_derive2 (const char *type, const char *type_inst,
+ derive_t value0, derive_t value1) /* {{{ */
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = value0;
- values[1].counter = value1;
+ values[0].derive = value0;
+ values[1].derive = value1;
vl.values = values;
vl.values_len = 2;
gauge_t bytes_total = NAN;
gauge_t hits = NAN;
gauge_t gets = NAN;
- counter_t rusage_user = 0;
- counter_t rusage_syst = 0;
- counter_t octets_rx = 0;
- counter_t octets_tx = 0;
+ derive_t rusage_user = 0;
+ derive_t rusage_syst = 0;
+ derive_t octets_rx = 0;
+ derive_t octets_tx = 0;
/* get data from daemon */
if (memcached_query_daemon (buf, sizeof (buf)) < 0) {
else if ((name_len > 4) && (strncmp (fields[1], "cmd_", 4) == 0))
{
const char *name = fields[1] + 4;
- submit_counter ("memcached_command", name, atoll (fields[2]));
+ submit_derive ("memcached_command", name, atoll (fields[2]));
if (strcmp (name, "get") == 0)
gets = atof (fields[2]);
}
*/
else if (FIELD_IS ("get_hits"))
{
- submit_counter ("memcached_ops", "hits", atoll (fields[2]));
+ submit_derive ("memcached_ops", "hits", atoll (fields[2]));
hits = atof (fields[2]);
}
else if (FIELD_IS ("get_misses"))
{
- submit_counter ("memcached_ops", "misses", atoll (fields[2]));
+ submit_derive ("memcached_ops", "misses", atoll (fields[2]));
}
else if (FIELD_IS ("evictions"))
{
- submit_counter ("memcached_ops", "evictions", atoll (fields[2]));
+ submit_derive ("memcached_ops", "evictions", atoll (fields[2]));
}
/*
submit_gauge2 ("df", "cache", bytes_used, bytes_total - bytes_used);
if ((rusage_user != 0) || (rusage_syst != 0))
- submit_counter2 ("ps_cputime", NULL, rusage_user, rusage_syst);
+ submit_derive2 ("ps_cputime", NULL, rusage_user, rusage_syst);
if ((octets_rx != 0) || (octets_tx != 0))
- submit_counter2 ("memcached_octets", NULL, octets_rx, octets_tx);
+ submit_derive2 ("memcached_octets", NULL, octets_rx, octets_tx);
if (!isnan (gets) && !isnan (hits))
{
} /* submit */
static void counter_submit (const char *type, const char *type_instance,
- counter_t value, mysql_database_t *db)
+ derive_t value, mysql_database_t *db)
{
value_t values[1];
- values[0].counter = value;
+ values[0].derive = value;
submit (type, type_instance, values, STATIC_ARRAY_SIZE (values), db);
} /* void counter_submit */
submit (type, type_instance, values, STATIC_ARRAY_SIZE (values), db);
} /* void derive_submit */
-static void traffic_submit (counter_t rx, counter_t tx, mysql_database_t *db)
+static void traffic_submit (derive_t rx, derive_t tx, mysql_database_t *db)
{
value_t values[2];
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
submit ("mysql_octets", NULL, values, STATIC_ARRAY_SIZE (values), db);
} /* void traffic_submit */
/**
* collectd - src/netlink.c
- * Copyright (C) 2007 Florian octo Forster
+ * Copyright (C) 2007-2010 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
**/
#include "collectd.h"
} /* int check_ignorelist */
static void submit_one (const char *dev, const char *type,
- const char *type_instance, counter_t value)
+ const char *type_instance, derive_t value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = value;
+ values[0].derive = value;
vl.values = values;
vl.values_len = 1;
static void submit_two (const char *dev, const char *type,
const char *type_instance,
- counter_t rx, counter_t tx)
+ derive_t rx, derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
vl.values = values;
vl.values_len = 2;
for (i = 0; i < len; i++)
{
- values[0].counter = val[i];
+ values[0].derive = val[i];
sstrncpy (vl.type_instance, names[i],
sizeof (vl.type_instance));
DEBUG ("%s-%s/nfs_procedure-%s = %llu",
/**
* collectd - src/nginx.c
- * Copyright (C) 2006,2007 Florian octo Forster
+ * Copyright (C) 2006-2010 Florian octo Forster
* Copyright (C) 2008 Sebastian Harl
*
* This program is free software; you can redistribute it and/or modify it
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
* Sebastian Harl <sh at tokkee.org>
**/
if (strcmp (type, "nginx_connections") == 0)
values[0].gauge = value;
else if (strcmp (type, "nginx_requests") == 0)
- values[0].counter = value;
+ values[0].derive = value;
else
return;
/**
* collectd - src/openvpn.c
- * Copyright (C) 2008 Doug MacEachern
- * Copyright (C) 2009 Florian octo Forster
- * Copyright (C) 2009 Marco Chiappero
- * Copyright (C) 2009 Fabian Schuh
+ * Copyright (C) 2008 Doug MacEachern
+ * Copyright (C) 2009,2010 Florian octo Forster
+ * Copyright (C) 2009 Marco Chiappero
+ * Copyright (C) 2009 Fabian Schuh
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* Authors:
* Doug MacEachern <dougm at hyperic.com>
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
* Marco Chiappero <marco at absence.it>
* Fabian Schuh <mail at xeroc.org>
**/
} /* void numusers_submit */
/* dispatches stats about traffic (TCP or UDP) generated by the tunnel per single endpoint */
-static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx)
+static void iostats_submit (char *pinst, char *tinst, derive_t rx, derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
/* NOTE ON THE NEW NAMING SCHEMA:
* using plugin_instance to identify each vpn config (and
/* dispatches stats about data compression shown when in single mode */
static void compression_submit (char *pinst, char *tinst,
- counter_t uncompressed, counter_t compressed)
+ derive_t uncompressed, derive_t compressed)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = uncompressed;
- values[1].counter = compressed;
+ values[0].derive = uncompressed;
+ values[1].derive = compressed;
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
const int max_fields = STATIC_ARRAY_SIZE (fields);
int fields_num, read = 0;
- counter_t link_rx, link_tx;
- counter_t tun_rx, tun_tx;
- counter_t pre_compress, post_compress;
- counter_t pre_decompress, post_decompress;
- counter_t overhead_rx, overhead_tx;
+ derive_t link_rx, link_tx;
+ derive_t tun_rx, tun_tx;
+ derive_t pre_compress, post_compress;
+ derive_t pre_decompress, post_decompress;
+ derive_t overhead_rx, overhead_tx;
link_rx = 0;
link_tx = 0;
/**
* collectd - src/protocols.c
- * Copyright (C) 2009 Florian octo Forster
+ * Copyright (C) 2009,2010 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
+ int status;
- char *tmp_ptr;
-
- errno = 0;
- tmp_ptr = NULL;
- values[0].counter = (counter_t) strtoll (str_value, &tmp_ptr,
- /* base = */ 0);
- if ((errno != 0) || (tmp_ptr == str_value))
+ status = parse_value (str_value, values, DS_TYPE_DERIVE);
+ if (status != 0)
{
ERROR ("protocols plugin: Parsing string as integer failed: %s",
str_value);
} /* }}} */
__attribute__ ((nonnull(2)))
-static void redis_submit_c (char *plugin_instance,
+static void redis_submit_d (char *plugin_instance,
const char *type, const char *type_instance,
- counter_t value) /* {{{ */
+ derive_t value) /* {{{ */
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = value;
+ values[0].derive = value;
vl.values = values;
vl.values_len = 1;
redis_submit_g (rn->name, "current_connections", "slaves", info.connected_slaves);
redis_submit_g (rn->name, "memory", "used", info.used_memory);
redis_submit_g (rn->name, "volatile_changes", NULL, info.changes_since_last_save);
- redis_submit_c (rn->name, "total_connections", NULL, info.total_connections_received);
- redis_submit_c (rn->name, "total_operations", NULL, info.total_commands_processed);
+ redis_submit_d (rn->name, "total_connections", NULL, info.total_connections_received);
+ redis_submit_d (rn->name, "total_operations", NULL, info.total_commands_processed);
credis_close (rh);
}
/**
* collectd - src/routeros.c
- * Copyright (C) 2009 Florian octo Forster
+ * Copyright (C) 2009,2010 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <octo at collectd.org>
**/
#include "collectd.h"
typedef struct cr_data_s cr_data_t;
static void cr_submit_io (cr_data_t *rd, const char *type, /* {{{ */
- const char *type_instance, counter_t rx, counter_t tx)
+ const char *type_instance, derive_t rx, derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
}
cr_submit_io (rd, "if_packets", i->name,
- (counter_t) i->rx_packets, (counter_t) i->tx_packets);
+ (derive_t) i->rx_packets, (derive_t) i->tx_packets);
cr_submit_io (rd, "if_octets", i->name,
- (counter_t) i->rx_bytes, (counter_t) i->tx_bytes);
+ (derive_t) i->rx_bytes, (derive_t) i->tx_bytes);
cr_submit_io (rd, "if_errors", i->name,
- (counter_t) i->rx_errors, (counter_t) i->tx_errors);
+ (derive_t) i->rx_errors, (derive_t) i->tx_errors);
cr_submit_io (rd, "if_dropped", i->name,
- (counter_t) i->rx_drops, (counter_t) i->tx_drops);
+ (derive_t) i->rx_drops, (derive_t) i->tx_drops);
submit_interface (rd, i->next);
} /* }}} void submit_interface */
#if ROS_VERSION >= ROS_VERSION_ENCODE(1, 1, 0)
static void cr_submit_counter (cr_data_t *rd, const char *type, /* {{{ */
- const char *type_instance, counter_t value)
+ const char *type_instance, derive_t value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = value;
+ values[0].derive = value;
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
ssnprintf (type_instance, sizeof (type_instance), "%s-%s",
r->interface, r->radio_name);
cr_submit_io (rd, "if_octets", type_instance,
- (counter_t) r->rx_bytes, (counter_t) r->tx_bytes);
+ (derive_t) r->rx_bytes, (derive_t) r->tx_bytes);
cr_submit_gauge (rd, "snr", type_instance, (gauge_t) r->signal_to_noise);
submit_regtable (rd, r->next);
if (rd->collect_disk)
{
- cr_submit_counter (rd, "counter", "secors_written", (counter_t) r->write_sect_total);
+ cr_submit_counter (rd, "counter", "secors_written", (derive_t) r->write_sect_total);
cr_submit_gauge (rd, "gauge", "bad_blocks", (gauge_t) r->bad_blocks);
}
static void tape_submit (const char *plugin_instance,
const char *type,
- counter_t read, counter_t write)
+ derive_t read, derive_t write)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = read;
- values[1].counter = write;
+ values[0].derive = read;
+ values[1].derive = write;
vl.values = values;
vl.values_len = 2;
} /* void tss2_submit_gauge */
static void tss2_submit_io (const char *plugin_instance, const char *type,
- counter_t rx, counter_t tx)
+ derive_t rx, derive_t tx)
{
/*
* Submits the io rx/tx tuple to the collectd daemon
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
vl.values = values;
vl.values_len = 2;
gauge_t users = NAN;
gauge_t channels = NAN;
gauge_t servers = NAN;
- counter_t rx_octets = 0;
- counter_t tx_octets = 0;
- counter_t rx_packets = 0;
- counter_t tx_packets = 0;
+ derive_t rx_octets = 0;
+ derive_t tx_octets = 0;
+ derive_t rx_packets = 0;
+ derive_t tx_packets = 0;
gauge_t packet_loss = NAN;
int valid = 0;