summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4fd631a)
raw | patch | inline | side by side (parent: 4fd631a)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 5 Dec 2010 15:40:34 +0000 (16:40 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 5 Dec 2010 15:40:34 +0000 (16:40 +0100) |
19 files changed:
src/bind.c | patch | blob | history | |
src/dns.c | patch | blob | history | |
src/gmond.c | patch | blob | history | |
src/iptables.c | patch | blob | history | |
src/ipvs.c | patch | blob | history | |
src/irq.c | patch | blob | history | |
src/libvirt.c | patch | blob | history | |
src/madwifi.c | patch | blob | history | |
src/memcached.c | patch | blob | history | |
src/mysql.c | patch | blob | history | |
src/netlink.c | patch | blob | history | |
src/nfs.c | patch | blob | history | |
src/nginx.c | patch | blob | history | |
src/openvpn.c | patch | blob | history | |
src/protocols.c | patch | blob | history | |
src/redis.c | patch | blob | history | |
src/routeros.c | patch | blob | history | |
src/tape.c | patch | blob | history | |
src/teamspeak2.c | patch | blob | history |
diff --git a/src/bind.c b/src/bind.c
index 47215c74bae0b6422d058dd5697a9d1fc180f0b6..497fcb657ad307272e6e87ba6d10c41a91cb480d 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
/**
* 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)
@@ -527,7 +522,7 @@ static int bind_parse_generic_name_value (const char *xpath_expression, /* {{{ *
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;
@@ -600,7 +595,7 @@ static int bind_parse_generic_value_list (const char *xpath_expression, /* {{{ *
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;
diff --git a/src/dns.c b/src/dns.c
index 47da4e94c122e60dbd3084212e09e71cb3e5fbc1..f6c3504731cfe55bef6c810d3abe1d41a2e33624 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
#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);
diff --git a/src/gmond.c b/src/gmond.c
index 8c774e536ff9c23e112c3e440d18aa15284478c4..3c746c48887c3e678d42e2417b3d11bd38a7b1ec 100644 (file)
--- a/src/gmond.c
+++ b/src/gmond.c
/**
* 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,
diff --git a/src/iptables.c b/src/iptables.c
index aa53074a641aae4acf9b8d98e0f6907591f04904..c39aff8fcd8d7d0ce3078bfad5d17ea0ccb2ed02 100644 (file)
--- a/src/iptables.c
+++ b/src/iptables.c
/**
* 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);
diff --git a/src/ipvs.c b/src/ipvs.c
index f3a583b9d510edfbdae487d4aed2ab7ac2a91538..ab76f1eb8638d2517dd1e56ddb981148d17ed556 100644 (file)
--- a/src/ipvs.c
+++ b/src/ipvs.c
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;
diff --git a/src/irq.c b/src/irq.c
index 401cc6f9cb3f13e84e1a5e2fd961238565c6632c..94e425371dfed11dc68a8fdd27dc912d6187d12a 100644 (file)
--- a/src/irq.c
+++ b/src/irq.c
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);
diff --git a/src/libvirt.c b/src/libvirt.c
index 5d9d84b6fa1a124d79fda845b3d0fba8fbbba39e..b5e7e99ca6ea28c9944359df7c555d84fd8dce22 100644 (file)
--- a/src/libvirt.c
+++ b/src/libvirt.c
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) */
diff --git a/src/madwifi.c b/src/madwifi.c
index 8b3266dc80c706cd9552beb2d9ef4009effa9ed6..13301fffe15aea8afbce76c3ce06105ededfa195 100644 (file)
--- a/src/madwifi.c
+++ b/src/madwifi.c
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]);
}
}
@@ -625,14 +625,14 @@ process_stat_struct (int which, const void *ptr, const char *dev, const char *ma
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 */
diff --git a/src/memcached.c b/src/memcached.c
index 8b4a8fc1b9a2495fb966442ff96ffad386787f5a..ee3dbe12d67c4998b3ac65ede2f808016370023f 100644 (file)
--- a/src/memcached.c
+++ b/src/memcached.c
/**
* 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))
{
diff --git a/src/mysql.c b/src/mysql.c
index 1ca3b484ce6d2ebadc490196ed64260140c7d18c..f4ad01c685c48e0e6b123c0f49563558bf228081 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
} /* 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 */
diff --git a/src/netlink.c b/src/netlink.c
index 49c4e990fb47d8ea5c15e5c8ae2b8f132c959d1f..ef851d354937a0069969b7822b5ce6de0879a739 100644 (file)
--- a/src/netlink.c
+++ b/src/netlink.c
/**
* 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;
diff --git a/src/nfs.c b/src/nfs.c
index e4d12e342a6e6b275b38b956c84ea93acceef465..f3c636ecce9cd14aead260b9cfdd3149750b5c31 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
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",
diff --git a/src/nginx.c b/src/nginx.c
index 36d3d8d2bed85f9de5867f9f381f0102e85f51c0..1cb7a90a13ad75f0405b4228eb589b984396b608 100644 (file)
--- a/src/nginx.c
+++ b/src/nginx.c
/**
* 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;
diff --git a/src/openvpn.c b/src/openvpn.c
index 2aca4145cdae3d36c2e1ead682b9ab0343a418b6..9ce23b4f4cb9c9e2550e86d337a866a451931404 100644 (file)
--- a/src/openvpn.c
+++ b/src/openvpn.c
/**
* 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
@@ -144,13 +144,13 @@ static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx
/* 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;
diff --git a/src/protocols.c b/src/protocols.c
index e90c1a4e234269edc2b4ab5d497fc55eb309fa3b..0dfba2101fa578e92c56c360b795f1e989ff1a29 100644 (file)
--- a/src/protocols.c
+++ b/src/protocols.c
/**
* 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);
diff --git a/src/redis.c b/src/redis.c
index 30bd8da34761f62bfd7448aa48db3581d858c072..b694e09db8f84a6be6767b20cacd50d37791b074 100644 (file)
--- a/src/redis.c
+++ b/src/redis.c
} /* }}} */
__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);
}
diff --git a/src/routeros.c b/src/routeros.c
index ff8789ed4a365692d2f9a928a4c0b191738fd20b..d61ffe984d36cfa2eaa3b74efce9872abdc9d648 100644 (file)
--- a/src/routeros.c
+++ b/src/routeros.c
/**
* 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);
}
diff --git a/src/tape.c b/src/tape.c
index 32b42965c55d5e31ca6a5e53f54554cd0842aa54..a8e7dc45faab08bdf18ffd42fbebd242f3f3477f 100644 (file)
--- a/src/tape.c
+++ b/src/tape.c
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;
diff --git a/src/teamspeak2.c b/src/teamspeak2.c
index d4bf2aa40dcb1d3172fce8f6d4878f19461e296c..7528406cc61a131e9fa276dcdacb1fe3345f23fc 100644 (file)
--- a/src/teamspeak2.c
+++ b/src/teamspeak2.c
} /* 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;