[collectd] [PATCH] Added "type" to the value_list_t struct.

Sebastian Harl sh at tokkee.org
Sun Apr 20 23:19:28 CEST 2008


This way, the complete tuple (host, plugin, plugin instance, type, type
instance) is stored in a single data-type which is more straight forward
and allows a more flexible use of that data-type. As a consequence, there
is no longer a need to explicitly pass the type to some functions, most
notably plugin_dispatch_values(), which have been updated in that respect.

The "perl" plugin has also been updated to reflect this change. For
backwards compatibility, plugin_dispatch_values() still accepts a second
argument - however, a warning will be submitted to the daemon in that
case.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
 src/apache.c           |    6 +++-
 src/apcups.c           |    3 +-
 src/apple_sensors.c    |    5 ++-
 src/ascent.c           |    4 ++-
 src/battery.c          |    5 ++-
 src/collectd-perl.pod  |   11 ++++++++-
 src/cpu.c              |    5 ++-
 src/cpufreq.c          |    3 +-
 src/csv.c              |   13 ++++++++++-
 src/df.c               |    3 +-
 src/disk.c             |    3 +-
 src/dns.c              |    6 +++-
 src/email.c            |    3 +-
 src/entropy.c          |    3 +-
 src/hddtemp.c          |    3 +-
 src/interface.c        |    3 +-
 src/ipmi.c             |    3 +-
 src/iptables.c         |    6 +++-
 src/ipvs.c             |   16 +++++++++-----
 src/irq.c              |    3 +-
 src/libvirt.c          |   10 ++++++--
 src/load.c             |    3 +-
 src/mbmon.c            |    3 +-
 src/memcached.c        |   12 +++++++---
 src/memory.c           |    3 +-
 src/multimeter.c       |    3 +-
 src/mysql.c            |   12 +++++++---
 src/netlink.c          |    6 +++-
 src/network.c          |   24 ++++++++++------------
 src/nfs.c              |    3 +-
 src/nginx.c            |    3 +-
 src/ntpd.c             |    3 +-
 src/nut.c              |    3 +-
 src/perl.c             |   52 +++++++++++++++++++++++++++++++++++------------
 src/ping.c             |    3 +-
 src/plugin.c           |   22 ++++++++++++++++---
 src/plugin.h           |    8 +++---
 src/powerdns.c         |    3 +-
 src/processes.c        |   15 +++++++++----
 src/rrdtool.c          |    9 ++++++-
 src/sensors.c          |    4 ++-
 src/serial.c           |    3 +-
 src/snmp.c             |   10 ++++++--
 src/swap.c             |    3 +-
 src/tape.c             |    3 +-
 src/tcpconns.c         |    5 ++-
 src/teamspeak2.c       |   12 +++++++---
 src/users.c            |    3 +-
 src/utils_cmd_putval.c |    6 ++--
 src/utils_tail_match.c |    3 +-
 src/utils_threshold.c  |   35 ++++++++++++++++---------------
 src/vmem.c             |    3 +-
 src/vserver.c          |    9 +++++--
 src/wireless.c         |    3 +-
 src/xmms.c             |    3 +-
 55 files changed, 273 insertions(+), 139 deletions(-)

diff --git a/src/apache.c b/src/apache.c
index 3cda565..55d8cd4 100644
--- a/src/apache.c
+++ b/src/apache.c
@@ -202,6 +202,7 @@ static void submit_counter (const char *type, const char *type_instance,
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "apache");
 	strcpy (vl.plugin_instance, "");
+	strncpy (vl.type, type, sizeof (vl.type));
 
 	if (type_instance != NULL)
 	{
@@ -210,7 +211,7 @@ static void submit_counter (const char *type, const char *type_instance,
 		vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 	}
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void submit_counter */
 
 static void submit_gauge (const char *type, const char *type_instance,
@@ -227,6 +228,7 @@ static void submit_gauge (const char *type, const char *type_instance,
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "apache");
 	strcpy (vl.plugin_instance, "");
+	strncpy (vl.type, type, sizeof (vl.type));
 
 	if (type_instance != NULL)
 	{
@@ -235,7 +237,7 @@ static void submit_gauge (const char *type, const char *type_instance,
 		vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 	}
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void submit_counter */
 
 static void submit_scoreboard (char *buf)
diff --git a/src/apcups.c b/src/apcups.c
index 5a03764..7f8afd4 100644
--- a/src/apcups.c
+++ b/src/apcups.c
@@ -376,9 +376,10 @@ static void apc_submit_generic (char *type, char *type_inst, double value)
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "apcups");
 	strcpy (vl.plugin_instance, "");
+	strncpy (vl.type, type, sizeof (vl.type));
 	strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static void apc_submit (struct apc_detail_s *apcups_detail)
diff --git a/src/apple_sensors.c b/src/apple_sensors.c
index 2726ad2..5db6e9c 100644
--- a/src/apple_sensors.c
+++ b/src/apple_sensors.c
@@ -91,9 +91,10 @@ static void as_submit (const char *type, const char *type_instance,
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "apple_sensors");
 	strcpy (vl.plugin_instance, "");
-	strcpy (vl.type_instance, type_instance);
+	strncpy (vl.type, type, sizeof (vl.type))
+	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int as_read (void)
diff --git a/src/ascent.c b/src/ascent.c
index 94691d6..e8ac0c2 100644
--- a/src/ascent.c
+++ b/src/ascent.c
@@ -130,10 +130,12 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */
     sstrncpy (vl.plugin_instance, plugin_instance,
         sizeof (vl.plugin_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 (type, &vl);
+  plugin_dispatch_values (&vl);
   return (0);
 } /* }}} int ascent_submit_gauge */
 
diff --git a/src/battery.c b/src/battery.c
index 345f606..0522015 100644
--- a/src/battery.c
+++ b/src/battery.c
@@ -100,9 +100,10 @@ static void battery_submit (const char *plugin_instance, const char *type, doubl
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "battery");
-	strcpy (vl.plugin_instance, plugin_instance);
+	strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+	strncpy (vl.type, type, sizeof (vl.type));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void battery_submit */
 
 #if HAVE_IOKIT_PS_IOPOWERSOURCES_H || HAVE_IOKIT_IOKITLIB_H
diff --git a/src/collectd-perl.pod b/src/collectd-perl.pod
index 4a01d14..5a58d35 100644
--- a/src/collectd-perl.pod
+++ b/src/collectd-perl.pod
@@ -160,6 +160,7 @@ layout looks like this:
     time   => time (),
     host   => $hostname_g,
     plugin => 'myplugin',
+    type   => 'myplugin',
     plugin_instance => '',
     type_instance   => ''
   }
@@ -272,13 +273,19 @@ data type.
 Removes a callback or data-set from collectd's internal list of
 functionsE<nbsp>/ datasets.
 
-=item B<plugin_dispatch_values> (I<type>, I<value-list>)
+=item B<plugin_dispatch_values> (I<value-list>)
 
-Submits a I<value-list> of type I<type> to the daemon. If the data-set I<type>
+Submits a I<value-list> to the daemon. If the data-set identified by
+I<value-list>->{I<type>}
 is found (and the number of values matches the number of data-sources) then the
 type, data-set and value-list is passed to all write-callbacks that are
 registered with the daemon.
 
+B<Note>: Prior to version 4.4 of collectd, the data-set type used to be passed
+as the first argument to B<plugin_register>. This syntax is still supported
+for backwards compatibility but has been deprecated and will be removed in
+some future version of collectd.
+
 =item B<plugin_dispatch_notification> (I<notification>)
 
 Submits a I<notification> to the daemon which will then pass it to all
diff --git a/src/cpu.c b/src/cpu.c
index c79c4b6..49d5eff 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -172,9 +172,10 @@ static void submit (int cpu_num, const char *type_instance, counter_t value)
 	snprintf (vl.plugin_instance, sizeof (vl.type_instance),
 			"%i", cpu_num);
 	vl.plugin_instance[DATA_MAX_NAME_LEN - 1] = '\0';
-	strcpy (vl.type_instance, type_instance);
+	strcpy (vl.type, "cpu");
+	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("cpu", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int cpu_read (void)
diff --git a/src/cpufreq.c b/src/cpufreq.c
index 42248a9..5cb1b4e 100644
--- a/src/cpufreq.c
+++ b/src/cpufreq.c
@@ -70,10 +70,11 @@ static void cpufreq_submit (int cpu_num, double value)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "cpufreq");
+	strcpy (vl.type, "cpufreq");
 	snprintf (vl.type_instance, sizeof (vl.type_instance),
 			"%i", cpu_num);
 
-	plugin_dispatch_values ("cpufreq", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int cpufreq_read (void)
diff --git a/src/csv.c b/src/csv.c
index ff59f91..b5de302 100644
--- a/src/csv.c
+++ b/src/csv.c
@@ -45,6 +45,8 @@ static int value_list_to_string (char *buffer, int buffer_len,
 	int i;
 	gauge_t *rates = NULL;
 
+	assert (0 == strcmp (ds->type, vl->type));
+
 	memset (buffer, '\0', buffer_len);
 
 	status = snprintf (buffer, buffer_len, "%u", (unsigned int) vl->time);
@@ -107,6 +109,8 @@ static int value_list_to_filename (char *buffer, int buffer_len,
 	int offset = 0;
 	int status;
 
+	assert (0 == strcmp (ds->type, vl->type));
+
 	if (datadir != NULL)
 	{
 		status = snprintf (buffer + offset, buffer_len - offset,
@@ -134,10 +138,10 @@ static int value_list_to_filename (char *buffer, int buffer_len,
 
 	if (strlen (vl->type_instance) > 0)
 		status = snprintf (buffer + offset, buffer_len - offset,
-				"%s-%s", ds->type, vl->type_instance);
+				"%s-%s", vl->type, vl->type_instance);
 	else
 		status = snprintf (buffer + offset, buffer_len - offset,
-				"%s", ds->type);
+				"%s", vl->type);
 	if ((status < 1) || (status >= buffer_len - offset))
 		return (-1);
 	offset += status;
@@ -242,6 +246,11 @@ static int csv_write (const data_set_t *ds, const value_list_t *vl)
 	struct flock fl;
 	int          status;
 
+	if (0 != strcmp (ds->type, vl->type)) {
+		ERROR ("csv plugin: DS type does not match value list type");
+		return -1;
+	}
+
 	if (value_list_to_filename (filename, sizeof (filename), ds, vl) != 0)
 		return (-1);
 
diff --git a/src/df.c b/src/df.c
index 0f357d8..f422743 100644
--- a/src/df.c
+++ b/src/df.c
@@ -128,9 +128,10 @@ static void df_submit (char *df_name,
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "df");
 	strcpy (vl.plugin_instance, "");
+	strcpy (vl.type, "df");
 	strncpy (vl.type_instance, df_name, sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("df", &vl);
+	plugin_dispatch_values (&vl);
 } /* void df_submit */
 
 static int df_read (void)
diff --git a/src/disk.c b/src/disk.c
index 5491dcb..50beb46 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -210,8 +210,9 @@ static void disk_submit (const char *plugin_instance,
 	strcpy (vl.plugin, "disk");
 	strncpy (vl.plugin_instance, plugin_instance,
 			sizeof (vl.plugin_instance));
+	strncpy (vl.type, type, sizeof (vl.type));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void disk_submit */
 
 #if HAVE_IOKIT_IOKITLIB_H
diff --git a/src/dns.c b/src/dns.c
index e9996b9..b61d768 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -301,9 +301,10 @@ static void submit_counter (const char *type, const char *type_instance,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "dns");
+	strncpy (vl.type, type, sizeof (vl.type));
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void submit_counter */
 
 static void submit_octets (counter_t queries, counter_t responses)
@@ -319,8 +320,9 @@ static void submit_octets (counter_t queries, counter_t responses)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "dns");
+	strcpy (vl.type, "dns_octets");
 
-	plugin_dispatch_values ("dns_octets", &vl);
+	plugin_dispatch_values (&vl);
 } /* void submit_counter */
 
 static int dns_read (void)
diff --git a/src/email.c b/src/email.c
index 869b7c3..50599c0 100644
--- a/src/email.c
+++ b/src/email.c
@@ -735,9 +735,10 @@ static void email_submit (const char *type, const char *type_instance, gauge_t v
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "email");
+	strncpy (vl.type, type, sizeof (vl.type));
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void email_submit */
 
 /* Copy list l1 to list l2. l2 may partly exist already, but it is assumed
diff --git a/src/entropy.c b/src/entropy.c
index 5f9eb53..85d41cf 100644
--- a/src/entropy.c
+++ b/src/entropy.c
@@ -42,9 +42,10 @@ static void entropy_submit (double entropy)
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "entropy");
 	strcpy (vl.plugin_instance, "");
+	strcpy (vl.type, "entropy");
 	strcpy (vl.type_instance, "");
 
-	plugin_dispatch_values ("entropy", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int entropy_read (void)
diff --git a/src/hddtemp.c b/src/hddtemp.c
index 36ada53..b4a50ac 100644
--- a/src/hddtemp.c
+++ b/src/hddtemp.c
@@ -451,9 +451,10 @@ static void hddtemp_submit (char *type_instance, double value)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "hddtemp");
+	strcpy (vl.type, "temperature");
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("temperature", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int hddtemp_read (void)
diff --git a/src/interface.c b/src/interface.c
index 741ff76..6edecc4 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -195,9 +195,10 @@ static void if_submit (const char *dev, const char *type,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "interface");
+	strncpy (vl.type, type, sizeof (vl.type));
 	strncpy (vl.type_instance, dev, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void if_submit */
 
 static int interface_read (void)
diff --git a/src/ipmi.c b/src/ipmi.c
index 95e2e7c..7a00c88 100644
--- a/src/ipmi.c
+++ b/src/ipmi.c
@@ -193,9 +193,10 @@ static void sensor_read_handler (ipmi_sensor_t *sensor,
 
   sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "ipmi", sizeof (vl.plugin));
+  sstrncpy (vl.type, type, sizeof (vl.type));
   sstrncpy (vl.type_instance, sensor_name_ptr, sizeof (vl.type_instance));
 
-  plugin_dispatch_values (type, &vl);
+  plugin_dispatch_values (&vl);
 } /* void sensor_read_handler */
 
 static int sensor_list_add (ipmi_sensor_t *sensor)
diff --git a/src/iptables.c b/src/iptables.c
index 72b4481..5e9619a 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -242,11 +242,13 @@ static int submit_match (const struct ipt_entry_match *match,
     }
     vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
+    strcpy (vl.type, "ipt_bytes");
     values[0].counter = (counter_t) entry->counters.bcnt;
-    plugin_dispatch_values ("ipt_bytes", &vl);
+    plugin_dispatch_values (&vl);
 
+    strcpy (vl.type, "ipt_packets");
     values[0].counter = (counter_t) entry->counters.pcnt;
-    plugin_dispatch_values ("ipt_packets", &vl);
+    plugin_dispatch_values (&vl);
 
     return (0);
 } /* void submit_match */
diff --git a/src/ipvs.c b/src/ipvs.c
index 68a3d7f..c5054a8 100644
--- a/src/ipvs.c
+++ b/src/ipvs.c
@@ -240,10 +240,12 @@ static void cipvs_submit_connections (char *pi, char *ti, counter_t value)
 
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "ipvs");
-	strcpy (vl.plugin_instance, pi);
-	strcpy (vl.type_instance, (NULL != ti) ? ti : "total");
+	strncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance));
+	strcpy (vl.type, "connections");
+	strncpy (vl.type_instance, (NULL != ti) ? ti : "total",
+		sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("connections", &vl);
+	plugin_dispatch_values (&vl);
 	return;
 } /* cipvs_submit_connections */
 
@@ -264,10 +266,12 @@ static void cipvs_submit_if (char *pi, char *t, char *ti,
 
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "ipvs");
-	strcpy (vl.plugin_instance, pi);
-	strcpy (vl.type_instance, (NULL != ti) ? ti : "total");
+	strncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance));
+	strncpy (vl.type, t, sizeof (vl.type));
+	strncpy (vl.type_instance, (NULL != ti) ? ti : "total",
+		sizeof (vl.type_instance));
 
-	plugin_dispatch_values (t, &vl);
+	plugin_dispatch_values (&vl);
 	return;
 } /* cipvs_submit_if */
 
diff --git a/src/irq.c b/src/irq.c
index 9eb1de4..a8866b7 100644
--- a/src/irq.c
+++ b/src/irq.c
@@ -134,13 +134,14 @@ static void irq_submit (unsigned int irq, counter_t value)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "irq");
+	strcpy (vl.type, "irq");
 
 	status = snprintf (vl.type_instance, sizeof (vl.type_instance),
 			"%u", irq);
 	if ((status < 1) || ((unsigned int)status >= sizeof (vl.type_instance)))
 		return;
 
-	plugin_dispatch_values ("irq", &vl);
+	plugin_dispatch_values (&vl);
 } /* void irq_submit */
 
 static int irq_read (void)
diff --git a/src/libvirt.c b/src/libvirt.c
index 327536a..bd09abf 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -706,7 +706,9 @@ cpu_submit (unsigned long long cpu_time,
     vl.values = values;
     vl.values_len = 1;
 
-    plugin_dispatch_values (type, &vl);
+    strncpy (vl.type, type, sizeof (vl.type));
+
+    plugin_dispatch_values (&vl);
 }
 
 static void
@@ -723,10 +725,11 @@ vcpu_submit (counter_t cpu_time,
     vl.values = values;
     vl.values_len = 1;
 
+    strncpy (vl.type, type, sizeof (vl.type));
     snprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr);
     vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
-    plugin_dispatch_values (type, &vl);
+    plugin_dispatch_values (&vl);
 }
 
 static void
@@ -744,10 +747,11 @@ submit_counter2 (const char *type, counter_t v0, counter_t v1,
     vl.values = values;
     vl.values_len = 2;
 
+    strncpy (vl.type, type, sizeof (vl.type));
     strncpy (vl.type_instance, devname, sizeof (vl.type_instance));
     vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
-    plugin_dispatch_values (type, &vl);
+    plugin_dispatch_values (&vl);
 } /* void submit_counter2 */
 
 static int
diff --git a/src/load.c b/src/load.c
index c9f130b..e9ce7be 100644
--- a/src/load.c
+++ b/src/load.c
@@ -49,8 +49,9 @@ static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "load");
+	strcpy (vl.type, "load");
 
-	plugin_dispatch_values ("load", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int load_read (void)
diff --git a/src/mbmon.c b/src/mbmon.c
index 50d7363..e223b95 100644
--- a/src/mbmon.c
+++ b/src/mbmon.c
@@ -230,9 +230,10 @@ static void mbmon_submit (const char *type, const char *type_instance,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "mbmon");
+	strncpy (vl.type, type, sizeof (vl.type));
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void mbmon_submit */
 
 /* Trim trailing whitespace from a string. */
diff --git a/src/memcached.c b/src/memcached.c
index a182578..c2c8d27 100644
--- a/src/memcached.c
+++ b/src/memcached.c
@@ -226,13 +226,14 @@ static void submit_counter (const char *type, const char *type_inst,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "memcached");
+	strncpy (vl.type, type, sizeof (vl.type));
 	if (type_inst != NULL)
 	{
 		strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 		vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 	}
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void memcached_submit_cmd */
 /* }}} */
 
@@ -250,13 +251,14 @@ static void submit_counter2 (const char *type, const char *type_inst,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "memcached");
+	strncpy (vl.type, type, sizeof (vl.type));
 	if (type_inst != NULL)
 	{
 		strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 		vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 	}
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void memcached_submit_cmd */
 /* }}} */
 
@@ -273,13 +275,14 @@ static void submit_gauge (const char *type, const char *type_inst,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "memcached");
+	strncpy (vl.type, type, sizeof (vl.type));
 	if (type_inst != NULL)
 	{
 		strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 		vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 	}
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 }
 /* }}} */
 
@@ -297,13 +300,14 @@ static void submit_gauge2 (const char *type, const char *type_inst,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "memcached");
+	strncpy (vl.type, type, sizeof (vl.type));
 	if (type_inst != NULL)
 	{
 		strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 		vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 	}
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 }
 /* }}} */
 
diff --git a/src/memory.c b/src/memory.c
index 3fbd33f..5cb574d 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -103,10 +103,11 @@ static void memory_submit (const char *type_instance, gauge_t value)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "memory");
+	strcpy (vl.type, "memory");
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 	vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
-	plugin_dispatch_values ("memory", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int memory_read (void)
diff --git a/src/multimeter.c b/src/multimeter.c
index 11ca42c..e09d9f9 100644
--- a/src/multimeter.c
+++ b/src/multimeter.c
@@ -218,8 +218,9 @@ static void multimeter_submit (double value)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "multimeter");
+	strcpy (vl.type, "multimeter");
 
-	plugin_dispatch_values ("multimeter", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int multimeter_read (void)
diff --git a/src/mysql.c b/src/mysql.c
index d472853..5994183 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -128,9 +128,10 @@ static void counter_submit (const char *type, const char *type_instance,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "mysql");
+	strncpy (vl.type, type, sizeof (vl.type));
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void counter_submit */
 
 static void qcache_submit (counter_t hits, counter_t inserts,
@@ -151,8 +152,9 @@ static void qcache_submit (counter_t hits, counter_t inserts,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "mysql");
+	strcpy (vl.type, "mysql_qcache");
 
-	plugin_dispatch_values ("mysql_qcache", &vl);
+	plugin_dispatch_values (&vl);
 } /* void qcache_submit */
 
 static void threads_submit (gauge_t running, gauge_t connected, gauge_t cached,
@@ -171,8 +173,9 @@ static void threads_submit (gauge_t running, gauge_t connected, gauge_t cached,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "mysql");
+	strcpy (vl.type, "mysql_threads");
 
-	plugin_dispatch_values ("mysql_threads", &vl);
+	plugin_dispatch_values (&vl);
 } /* void threads_submit */
 
 static void traffic_submit (counter_t rx, counter_t tx)
@@ -188,8 +191,9 @@ static void traffic_submit (counter_t rx, counter_t tx)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "mysql");
+	strcpy (vl.type, "mysql_octets");
 
-	plugin_dispatch_values ("mysql_octets", &vl);
+	plugin_dispatch_values (&vl);
 } /* void traffic_submit */
 
 static int mysql_read (void)
diff --git a/src/netlink.c b/src/netlink.c
index 22afdc7..55371c3 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -174,11 +174,12 @@ static void submit_one (const char *dev, const char *type,
   strcpy (vl.host, hostname_g);
   strcpy (vl.plugin, "netlink");
   strncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
+  strncpy (vl.type, type, sizeof (vl.type));
 
   if (type_instance != NULL)
     strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-  plugin_dispatch_values (type, &vl);
+  plugin_dispatch_values (&vl);
 } /* void submit_one */
 
 static void submit_two (const char *dev, const char *type,
@@ -197,11 +198,12 @@ static void submit_two (const char *dev, const char *type,
   strcpy (vl.host, hostname_g);
   strcpy (vl.plugin, "netlink");
   strncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
+  strncpy (vl.type, type, sizeof (vl.type));
 
   if (type_instance != NULL)
     strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-  plugin_dispatch_values (type, &vl);
+  plugin_dispatch_values (&vl);
 } /* void submit_two */
 
 static int link_filter (const struct sockaddr_nl *sa,
diff --git a/src/network.c b/src/network.c
index e150364..4e1504f 100644
--- a/src/network.c
+++ b/src/network.c
@@ -246,7 +246,7 @@ static int cache_flush (void)
 	return (0);
 } /* int cache_flush */
 
-static int cache_check (const char *type, const value_list_t *vl)
+static int cache_check (const value_list_t *vl)
 {
 	char key[1024];
 	time_t *value = NULL;
@@ -256,7 +256,7 @@ static int cache_check (const char *type, const value_list_t *vl)
 		return (-1);
 
 	if (format_name (key, sizeof (key), vl->host, vl->plugin,
-				vl->plugin_instance, type, vl->type_instance))
+				vl->plugin_instance, vl->type, vl->type_instance))
 		return (-1);
 
 	pthread_mutex_lock (&cache_lock);
@@ -678,14 +678,12 @@ static int parse_packet (void *buffer, int buffer_len)
 	int status;
 
 	value_list_t vl = VALUE_LIST_INIT;
-	char type[DATA_MAX_NAME_LEN];
 	notification_t n;
 
 	DEBUG ("network plugin: parse_packet: buffer = %p; buffer_len = %i;",
 			buffer, buffer_len);
 
 	memset (&vl, '\0', sizeof (vl));
-	memset (&type, '\0', sizeof (type));
 	memset (&n, '\0', sizeof (n));
 	status = 0;
 
@@ -722,10 +720,10 @@ static int parse_packet (void *buffer, int buffer_len)
 			if ((vl.time > 0)
 					&& (strlen (vl.host) > 0)
 					&& (strlen (vl.plugin) > 0)
-					&& (strlen (type) > 0)
-					&& (cache_check (type, &vl) == 0))
+					&& (strlen (vl.type) > 0)
+					&& (cache_check (&vl) == 0))
 			{
-				plugin_dispatch_values (type, &vl);
+				plugin_dispatch_values (&vl);
 			}
 			else
 			{
@@ -782,9 +780,9 @@ static int parse_packet (void *buffer, int buffer_len)
 		else if (pkg_type == TYPE_TYPE)
 		{
 			status = parse_part_string (&buffer, &buffer_len,
-					type, sizeof (type));
+					vl.type, sizeof (vl.type));
 			if (status == 0)
-				sstrncpy (n.type, type, sizeof (n.type));
+				sstrncpy (n.type, vl.type, sizeof (n.type));
 		}
 		else if (pkg_type == TYPE_TYPE_INSTANCE)
 		{
@@ -1441,12 +1439,12 @@ static int add_to_buffer (char *buffer, int buffer_size,
 		strcpy (vl_def->plugin_instance, vl->plugin_instance);
 	}
 
-	if (strcmp (type_def, ds->type) != 0)
+	if (strcmp (type_def, vl->type) != 0)
 	{
 		if (write_part_string (&buffer, &buffer_size, TYPE_TYPE,
-					ds->type, strlen (ds->type)) != 0)
+					vl->type, strlen (vl->type)) != 0)
 			return (-1);
-		strcpy (type_def, ds->type);
+		strcpy (type_def, vl->type);
 	}
 
 	if (strcmp (vl_def->type_instance, vl->type_instance) != 0)
@@ -1483,7 +1481,7 @@ static int network_write (const data_set_t *ds, const value_list_t *vl)
 	/* If the value is already in the cache, we have received it via the
 	 * network. We write it again if forwarding is activated. It's then in
 	 * the cache and should we receive it again we will ignore it. */
-	status = cache_check (ds->type, vl);
+	status = cache_check (vl);
 	if ((network_config_forward == 0)
 			&& (status != 0))
 		return (0);
diff --git a/src/nfs.c b/src/nfs.c
index 77c7f48..367e714 100644
--- a/src/nfs.c
+++ b/src/nfs.c
@@ -192,6 +192,7 @@ static void nfs_procedures_submit (const char *plugin_instance,
 	strcpy (vl.plugin, "nfs");
 	strncpy (vl.plugin_instance, plugin_instance,
 		       	sizeof (vl.plugin_instance));
+	strcpy (vl.type, "nfs_procedure");
 
 	for (i = 0; i < len; i++)
 	{
@@ -201,7 +202,7 @@ static void nfs_procedures_submit (const char *plugin_instance,
 		DEBUG ("%s-%s/nfs_procedure-%s = %llu",
 				vl.plugin, vl.plugin_instance,
 				vl.type_instance, val[i]);
-		plugin_dispatch_values ("nfs_procedure", &vl);
+		plugin_dispatch_values (&vl);
 	}
 } /* void nfs_procedures_submit */
 
diff --git a/src/nginx.c b/src/nginx.c
index 3b107fb..a95362b 100644
--- a/src/nginx.c
+++ b/src/nginx.c
@@ -180,6 +180,7 @@ static void submit (char *type, char *inst, long long value)
   strcpy (vl.host, hostname_g);
   strcpy (vl.plugin, "nginx");
   strcpy (vl.plugin_instance, "");
+  strncpy (vl.type, type, sizeof (vl.type));
 
   if (inst != NULL)
   {
@@ -187,7 +188,7 @@ static void submit (char *type, char *inst, long long value)
     vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
   }
 
-  plugin_dispatch_values (type, &vl);
+  plugin_dispatch_values (&vl);
 } /* void submit */
 
 static int nginx_read (void)
diff --git a/src/ntpd.c b/src/ntpd.c
index 90fdfd7..81b74ef 100644
--- a/src/ntpd.c
+++ b/src/ntpd.c
@@ -305,9 +305,10 @@ static void ntpd_submit (char *type, char *type_inst, double value)
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "ntpd");
 	strcpy (vl.plugin_instance, "");
+	strncpy (vl.type, type, sizeof (vl.type));
 	strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 }
 
 /* returns `tv0 - tv1' in milliseconds or 0 if `tv1 > tv0' */
diff --git a/src/nut.c b/src/nut.c
index f7f026a..bcb0ae9 100644
--- a/src/nut.c
+++ b/src/nut.c
@@ -131,13 +131,14 @@ static void nut_submit (nut_ups_t *ups, const char *type,
       sizeof (vl.host));
   strcpy (vl.plugin, "nut");
   strncpy (vl.plugin_instance, ups->upsname, sizeof (vl.plugin_instance));
+  strncpy (vl.type, type, sizeof (vl.type));
   strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
   vl.host[sizeof (vl.host) - 1] = '\0';
   vl.plugin_instance[sizeof (vl.plugin_instance) - 1] = '\0';
   vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
-  plugin_dispatch_values (type, &vl);
+  plugin_dispatch_values (&vl);
 } /* void nut_submit */
 
 static int nut_read_one (nut_ups_t *ups)
diff --git a/src/perl.c b/src/perl.c
index 96e8562..0f7d114 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -367,6 +367,10 @@ static int value_list2hv (pTHX_ value_list_t *vl, data_set_t *ds, HV *hash)
 				newSVpv (vl->plugin_instance, 0), 0))
 			return -1;
 
+	if ('\0' != vl->type[0])
+		if (NULL == hv_store (hash, "type", 4, newSVpv (vl->type, 0), 0))
+			return -1;
+
 	if ('\0' != vl->type_instance[0])
 		if (NULL == hv_store (hash, "type_instance", 13,
 				newSVpv (vl->type_instance, 0), 0))
@@ -505,7 +509,7 @@ static int pplugin_unregister_data_set (char *name)
  *   type_instance   => $tinstance,
  * }
  */
-static int pplugin_dispatch_values (pTHX_ char *name, HV *values)
+static int pplugin_dispatch_values (pTHX_ HV *values)
 {
 	value_list_t list = VALUE_LIST_INIT;
 	value_t      *val = NULL;
@@ -514,8 +518,16 @@ static int pplugin_dispatch_values (pTHX_ char *name, HV *values)
 
 	int ret = 0;
 
-	if ((NULL == name) || (NULL == values))
+	if (NULL == values)
+		return -1;
+
+	if (NULL == (tmp = hv_fetch (values, "type", 4, 0))) {
+		log_err ("pplugin_dispatch_values: No type given.");
 		return -1;
+	}
+
+	strncpy (list.type, SvPV_nolen (*tmp), sizeof (list.type));
+	list.type[DATA_MAX_NAME_LEN - 1] = '\0';
 
 	if ((NULL == (tmp = hv_fetch (values, "values", 6, 0)))
 			|| (! (SvROK (*tmp) && (SVt_PVAV == SvTYPE (SvRV (*tmp)))))) {
@@ -532,7 +544,8 @@ static int pplugin_dispatch_values (pTHX_ char *name, HV *values)
 
 		val = (value_t *)smalloc (len * sizeof (value_t));
 
-		list.values_len = av2value (aTHX_ name, (AV *)SvRV (*tmp), val, len);
+		list.values_len = av2value (aTHX_ list.type, (AV *)SvRV (*tmp),
+				val, len);
 		list.values = val;
 
 		if (-1 == list.values_len) {
@@ -571,7 +584,7 @@ static int pplugin_dispatch_values (pTHX_ char *name, HV *values)
 		list.type_instance[DATA_MAX_NAME_LEN - 1] = '\0';
 	}
 
-	ret = plugin_dispatch_values (name, &list);
+	ret = plugin_dispatch_values (&list);
 
 	sfree (val);
 	return ret;
@@ -687,6 +700,7 @@ static int pplugin_call_all (pTHX_ int type, ...)
 		 *   time   => $time,
 		 *   host   => $hostname,
 		 *   plugin => $plugin,
+		 *   type   => $type,
 		 *   plugin_instance => $instance,
 		 *   type_instance   => $type_instance
 		 * };
@@ -856,33 +870,43 @@ static XS (Collectd_plugin_unregister_ds)
  */
 static XS (Collectd_plugin_dispatch_values)
 {
-	SV *values = NULL;
+	SV *values     = NULL;
+	int values_idx = 0;
 
 	int ret = 0;
 
 	dXSARGS;
 
-	if (2 != items) {
-		log_err ("Usage: Collectd::plugin_dispatch_values(name, values)");
+	if (2 == items) {
+		log_warn ("Collectd::plugin_dispatch_values with two arguments "
+				"is deprecated - pass the type through values->{type}.");
+		values_idx = 1;
+	}
+	else if (1 != items) {
+		log_err ("Usage: Collectd::plugin_dispatch_values(values)");
 		XSRETURN_EMPTY;
 	}
 
-	log_debug ("Collectd::plugin_dispatch_values: "
-			"name = \"%s\", values=\"%s\"",
-			SvPV_nolen (ST (0)), SvPV_nolen (ST (1)));
+	log_debug ("Collectd::plugin_dispatch_values: values=\"%s\"",
+			SvPV_nolen (ST (values_idx)));
 
-	values = ST (1);
+	values = ST (values_idx);
 
 	if (! (SvROK (values) && (SVt_PVHV == SvTYPE (SvRV (values))))) {
 		log_err ("Collectd::plugin_dispatch_values: Invalid values.");
 		XSRETURN_EMPTY;
 	}
 
-	if ((NULL == ST (0)) || (NULL == values))
+	if (((2 == items) && (NULL == ST (0))) || (NULL == values))
 		XSRETURN_EMPTY;
 
-	ret = pplugin_dispatch_values (aTHX_ SvPV_nolen (ST (0)),
-			(HV *)SvRV (values));
+	if ((2 == items) && (NULL == hv_store ((HV *)SvRV (values), "type", 4,
+			newSVsv (ST (0)), 0))) {
+		log_err ("Collectd::plugin_dispatch_values: Could not store type.");
+		XSRETURN_EMPTY;
+	}
+
+	ret = pplugin_dispatch_values (aTHX_ (HV *)SvRV (values));
 
 	if (0 == ret)
 		XSRETURN_YES;
diff --git a/src/ping.c b/src/ping.c
index 2f7c064..f298785 100644
--- a/src/ping.c
+++ b/src/ping.c
@@ -189,9 +189,10 @@ static void ping_submit (char *host, double latency)
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "ping");
 	strcpy (vl.plugin_instance, "");
+	strcpy (vl.type, "ping");
 	strncpy (vl.type_instance, host, sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("ping", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int ping_read (void)
diff --git a/src/plugin.c b/src/plugin.c
index 1aad97c..f590580 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -717,12 +717,17 @@ void plugin_shutdown_all (void)
 	}
 } /* void plugin_shutdown_all */
 
-int plugin_dispatch_values (const char *name, value_list_t *vl)
+int plugin_dispatch_values (value_list_t *vl)
 {
 	int (*callback) (const data_set_t *, const value_list_t *);
 	data_set_t *ds;
 	llentry_t *le;
 
+	if ((vl == NULL) || (*vl->type == '\0')) {
+		ERROR ("plugin_dispatch_values: Invalid value list.");
+		return (-1);
+	}
+
 	if (list_write == NULL)
 	{
 		ERROR ("plugin_dispatch_values: No write callback has been "
@@ -739,9 +744,9 @@ int plugin_dispatch_values (const char *name, value_list_t *vl)
 		return (-1);
 	}
 
-	if (c_avl_get (data_sets, name, (void *) &ds) != 0)
+	if (c_avl_get (data_sets, vl->type, (void *) &ds) != 0)
 	{
-		INFO ("plugin_dispatch_values: Dataset not found: %s", name);
+		INFO ("plugin_dispatch_values: Dataset not found: %s", vl->type);
 		return (-1);
 	}
 
@@ -752,7 +757,15 @@ int plugin_dispatch_values (const char *name, value_list_t *vl)
 			(unsigned int) vl->time, vl->interval,
 			vl->host,
 			vl->plugin, vl->plugin_instance,
-			ds->type, vl->type_instance);
+			vl->type, vl->type_instance);
+
+#if COLLECT_DEBUG
+	assert (0 == strcmp (ds->type, vl->type));
+#else
+	if (0 != strcmp (ds->type, vl->type))
+		WARN ("plugin_dispatch_values: (ds->type = %s) != (vl->type = %s)",
+				ds->type, vl->type);
+#endif
 
 #if COLLECT_DEBUG
 	assert (ds->ds_num == vl->values_len);
@@ -770,6 +783,7 @@ int plugin_dispatch_values (const char *name, value_list_t *vl)
 	escape_slashes (vl->host, sizeof (vl->host));
 	escape_slashes (vl->plugin, sizeof (vl->plugin));
 	escape_slashes (vl->plugin_instance, sizeof (vl->plugin_instance));
+	escape_slashes (vl->type, sizeof (vl->type));
 	escape_slashes (vl->type_instance, sizeof (vl->type_instance));
 
 	/* Update the value cache */
diff --git a/src/plugin.h b/src/plugin.h
index 7b59930..488e041 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -74,12 +74,13 @@ struct value_list_s
 	char     host[DATA_MAX_NAME_LEN];
 	char     plugin[DATA_MAX_NAME_LEN];
 	char     plugin_instance[DATA_MAX_NAME_LEN];
+	char     type[DATA_MAX_NAME_LEN];
 	char     type_instance[DATA_MAX_NAME_LEN];
 };
 typedef struct value_list_s value_list_t;
 
-#define VALUE_LIST_INIT { NULL, 0, 0, interval_g, "localhost", "", "", "" }
-#define VALUE_LIST_STATIC { NULL, 0, 0, 0, "localhost", "", "", "" }
+#define VALUE_LIST_INIT { NULL, 0, 0, interval_g, "localhost", "", "", "", "" }
+#define VALUE_LIST_STATIC { NULL, 0, 0, 0, "localhost", "", "", "", "" }
 
 struct data_source_s
 {
@@ -204,11 +205,10 @@ int plugin_unregister_notification (const char *name);
  *  write-functions.
  *
  * ARGUMENTS
- *  `name'      Name/type of the data-set that describe the values in `vl'.
  *  `vl'        Value list of the values that have been read by a `read'
  *              function.
  */
-int plugin_dispatch_values (const char *name, value_list_t *vl);
+int plugin_dispatch_values (value_list_t *vl);
 
 int plugin_dispatch_notification (const notification_t *notif);
 
diff --git a/src/powerdns.c b/src/powerdns.c
index 9caa770..c82d407 100644
--- a/src/powerdns.c
+++ b/src/powerdns.c
@@ -264,11 +264,12 @@ static void submit (const char *plugin_instance, /* {{{ */
   vl.time = time (NULL);
   sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "powerdns", sizeof (vl.plugin));
+  sstrncpy (vl.type, type, sizeof (vl.type));
   if (type_instance != NULL)
     sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
   sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
 
-  plugin_dispatch_values (type, &vl);
+  plugin_dispatch_values (&vl);
 } /* }}} static void submit */
 
 static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */
diff --git a/src/processes.c b/src/processes.c
index 22d369d..1b41372 100644
--- a/src/processes.c
+++ b/src/processes.c
@@ -412,9 +412,10 @@ static void ps_submit_state (const char *state, double value)
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "processes");
 	strcpy (vl.plugin_instance, "");
+	strcpy (vl.type, "ps_state");
 	strncpy (vl.type_instance, state, sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("ps_state", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static void ps_submit_proc_list (procstat_t *ps)
@@ -429,24 +430,28 @@ static void ps_submit_proc_list (procstat_t *ps)
 	strcpy (vl.plugin, "processes");
 	strncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance));
 
+	strcpy (vl.type, "ps_rss");
 	vl.values[0].gauge = ps->vmem_rss;
 	vl.values_len = 1;
-	plugin_dispatch_values ("ps_rss", &vl);
+	plugin_dispatch_values (&vl);
 
+	strcpy (vl.type, "ps_cputime");
 	vl.values[0].counter = ps->cpu_user_counter;
 	vl.values[1].counter = ps->cpu_system_counter;
 	vl.values_len = 2;
-	plugin_dispatch_values ("ps_cputime", &vl);
+	plugin_dispatch_values (&vl);
 
+	strcpy (vl.type, "ps_count");
 	vl.values[0].gauge = ps->num_proc;
 	vl.values[1].gauge = ps->num_lwp;
 	vl.values_len = 2;
-	plugin_dispatch_values ("ps_count", &vl);
+	plugin_dispatch_values (&vl);
 
+	strcpy (vl.type, "ps_pagefaults");
 	vl.values[0].counter = ps->vmem_minflt_counter;
 	vl.values[1].counter = ps->vmem_majflt_counter;
 	vl.values_len = 2;
-	plugin_dispatch_values ("ps_pagefaults", &vl);
+	plugin_dispatch_values (&vl);
 
 	DEBUG ("name = %s; num_proc = %lu; num_lwp = %lu; vmem_rss = %lu; "
 			"vmem_minflt_counter = %lu; vmem_majflt_counter = %lu; "
diff --git a/src/rrdtool.c b/src/rrdtool.c
index 93c9d7a..fad1e4b 100644
--- a/src/rrdtool.c
+++ b/src/rrdtool.c
@@ -591,10 +591,10 @@ static int value_list_to_filename (char *buffer, int buffer_len,
 
 	if (strlen (vl->type_instance) > 0)
 		status = snprintf (buffer + offset, buffer_len - offset,
-				"%s-%s.rrd", ds->type, vl->type_instance);
+				"%s-%s.rrd", vl->type, vl->type_instance);
 	else
 		status = snprintf (buffer + offset, buffer_len - offset,
-				"%s.rrd", ds->type);
+				"%s.rrd", vl->type);
 	if ((status < 1) || (status >= buffer_len - offset))
 		return (-1);
 	offset += status;
@@ -913,6 +913,11 @@ static int rrd_write (const data_set_t *ds, const value_list_t *vl)
 	char         values[512];
 	int          status;
 
+	if (0 != strcmp (ds->type, vl->type)) {
+		ERROR ("rrdtool plugin: DS type does not match value list type");
+		return -1;
+	}
+
 	if (value_list_to_filename (filename, sizeof (filename), ds, vl) != 0)
 		return (-1);
 
diff --git a/src/sensors.c b/src/sensors.c
index 6086319..e69389c 100644
--- a/src/sensors.c
+++ b/src/sensors.c
@@ -506,10 +506,12 @@ static void sensors_submit (const char *plugin_instance,
 	strncpy (vl.plugin_instance, plugin_instance,
 			sizeof (vl.plugin_instance));
 	vl.plugin_instance[sizeof (vl.plugin_instance) - 1] = '\0';
+	strncpy (vl.type, type, sizeof (vl.type));
+	vl.type[sizeof (vl.type) - 1] = '\0';
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 	vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void sensors_submit */
 
 static int sensors_read (void)
diff --git a/src/serial.c b/src/serial.c
index 9cfe1dd..fb30fc4 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -43,10 +43,11 @@ static void serial_submit (const char *type_instance,
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "serial");
+	strcpy (vl.type, "serial_octets");
 	strncpy (vl.type_instance, type_instance,
 			sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("serial_octets", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static int serial_read (void)
diff --git a/src/snmp.c b/src/snmp.c
index 4311ff1..77cc557 100644
--- a/src/snmp.c
+++ b/src/snmp.c
@@ -972,6 +972,8 @@ static int csnmp_dispatch_table (host_definition_t *host, data_definition_t *dat
 	|| (instance_list_ptr->subid == value_table_ptr[0]->subid));
 #endif
 
+    strncpy (vl.type, data->type, sizeof (vl.type));
+
     {
       char temp[DATA_MAX_NAME_LEN];
 
@@ -995,7 +997,7 @@ static int csnmp_dispatch_table (host_definition_t *host, data_definition_t *dat
       vl.values[i] = value_table_ptr[i]->value;
 
     /* If we get here `vl.type_instance' and all `vl.values' have been set */
-    plugin_dispatch_values (data->type, &vl);
+    plugin_dispatch_values (&vl);
 
     subid++;
   } /* while (have_more != 0) */
@@ -1302,6 +1304,8 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
   strncpy (vl.host, host->name, sizeof (vl.host));
   vl.host[sizeof (vl.host) - 1] = '\0';
   strcpy (vl.plugin, "snmp");
+  strncpy (vl.type, data->type, sizeof (vl.type));
+  vl.type[sizeof (vl.type) - 1] = '\0';
   strncpy (vl.type_instance, data->instance.string, sizeof (vl.type_instance));
   vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
@@ -1361,8 +1365,8 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
     snmp_free_pdu (res);
   res = NULL;
 
-  DEBUG ("snmp plugin: -> plugin_dispatch_values (%s, &vl);", data->type);
-  plugin_dispatch_values (data->type, &vl);
+  DEBUG ("snmp plugin: -> plugin_dispatch_values (&vl);");
+  plugin_dispatch_values (&vl);
   sfree (vl.values);
 
   return (0);
diff --git a/src/swap.c b/src/swap.c
index 1cf7077..632d372 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -122,9 +122,10 @@ static void swap_submit (const char *type_instance, double value)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "swap");
+	strcpy (vl.type, "swap");
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("swap", &vl);
+	plugin_dispatch_values (&vl);
 } /* void swap_submit */
 
 static int swap_read (void)
diff --git a/src/tape.c b/src/tape.c
index 465688e..c374d59 100644
--- a/src/tape.c
+++ b/src/tape.c
@@ -73,8 +73,9 @@ static void tape_submit (const char *plugin_instance,
 	strcpy (vl.plugin, "tape");
 	strncpy (vl.plugin_instance, plugin_instance,
 			sizeof (vl.plugin_instance));
+	strncpy (vl.type, type, sizeof (vl.type));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void tape_submit */
 
 static int tape_read (void)
diff --git a/src/tcpconns.c b/src/tcpconns.c
index fdf7ec1..8c7beea 100644
--- a/src/tcpconns.c
+++ b/src/tcpconns.c
@@ -137,6 +137,7 @@ static void conn_submit_port_entry (port_entry_t *pe)
   vl.time = time (NULL);
   strcpy (vl.host, hostname_g);
   strcpy (vl.plugin, "tcpconns");
+  strcpy (vl.type, "tcp_connections");
 
   if (((port_collect_listening != 0) && (pe->flags & PORT_IS_LISTENING))
       || (pe->flags & PORT_COLLECT_LOCAL))
@@ -152,7 +153,7 @@ static void conn_submit_port_entry (port_entry_t *pe)
       strncpy (vl.type_instance, tcp_state[i], sizeof (vl.type_instance));
       vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
-      plugin_dispatch_values ("tcp_connections", &vl);
+      plugin_dispatch_values (&vl);
     }
   }
 
@@ -169,7 +170,7 @@ static void conn_submit_port_entry (port_entry_t *pe)
       strncpy (vl.type_instance, tcp_state[i], sizeof (vl.type_instance));
       vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
 
-      plugin_dispatch_values ("tcp_connections", &vl);
+      plugin_dispatch_values (&vl);
     }
   }
 } /* void conn_submit */
diff --git a/src/teamspeak2.c b/src/teamspeak2.c
index aa10742..f966b11 100644
--- a/src/teamspeak2.c
+++ b/src/teamspeak2.c
@@ -136,12 +136,14 @@ static void tss2_submit_gauge (const char *plugin_instance,
 	if (plugin_instance != NULL)
 		sstrncpy (vl.plugin_instance, plugin_instance,
 				sizeof (vl.plugin_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 (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void tss2_submit_gauge */
 
 static void tss2_submit_io (const char *plugin_instance, const char *type,
@@ -165,8 +167,10 @@ static void tss2_submit_io (const char *plugin_instance, const char *type,
 	if (plugin_instance != NULL)
 		sstrncpy (vl.plugin_instance, plugin_instance,
 				sizeof (vl.plugin_instance));
-	
-	plugin_dispatch_values (type, &vl);
+
+	sstrncpy (vl.type, type, sizeof (vl.type));
+
+	plugin_dispatch_values (&vl);
 } /* void tss2_submit_gauge */
 
 static void tss2_close_socket (void)
diff --git a/src/users.c b/src/users.c
index afe26e1..bec908c 100644
--- a/src/users.c
+++ b/src/users.c
@@ -47,8 +47,9 @@ static void users_submit (gauge_t value)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "users");
+	strcpy (vl.type, "users");
 
-	plugin_dispatch_values ("users", &vl);
+	plugin_dispatch_values (&vl);
 } /* void users_submit */
 
 static int users_read (void)
diff --git a/src/utils_cmd_putval.c b/src/utils_cmd_putval.c
index 98b5043..023e4a7 100644
--- a/src/utils_cmd_putval.c
+++ b/src/utils_cmd_putval.c
@@ -24,7 +24,6 @@
 #include "plugin.h"
 
 static int parse_value (const data_set_t *ds, value_list_t *vl,
-		const char *type,
 	       	FILE *fh, char *buffer)
 {
 	char *dummy;
@@ -82,7 +81,7 @@ static int parse_value (const data_set_t *ds, value_list_t *vl,
 		return (-1);
 	}
 
-	plugin_dispatch_values (type, vl);
+	plugin_dispatch_values (vl);
 	return (0);
 } /* int parse_value */
 
@@ -170,6 +169,7 @@ int handle_putval (FILE *fh, char **fields, int fields_num)
 	strcpy (vl.plugin, plugin);
 	if (plugin_instance != NULL)
 		strcpy (vl.plugin_instance, plugin_instance);
+	strcpy (vl.type, type);
 	if (type_instance != NULL)
 		strcpy (vl.type_instance, type_instance);
 
@@ -197,7 +197,7 @@ int handle_putval (FILE *fh, char **fields, int fields_num)
 			/* It's parse_value's job to write an error to `fh'.
 			 * This is not the case with `parse_option below.
 			 * Neither will write an success message. */
-			if (parse_value (ds, &vl, type, fh, fields[i]) != 0)
+			if (parse_value (ds, &vl, fh, fields[i]) != 0)
 				break;
 		}
 		else if (strchr (fields[i], '=') != NULL)
diff --git a/src/utils_tail_match.c b/src/utils_tail_match.c
index 34fe2dc..f518b1c 100644
--- a/src/utils_tail_match.c
+++ b/src/utils_tail_match.c
@@ -85,10 +85,11 @@ static int simple_submit_match (cu_match_t *match, void *user_data)
   sstrncpy (vl.plugin, data->plugin, sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, data->plugin_instance,
       sizeof (vl.plugin_instance));
+  sstrncpy (vl.type, data->type, sizeof (vl.type));
   sstrncpy (vl.type_instance, data->type_instance,
       sizeof (vl.type_instance));
 
-  plugin_dispatch_values (data->type, &vl);
+  plugin_dispatch_values (&vl);
 
   if (match_value->ds_type & UTILS_MATCH_DS_TYPE_GAUGE)
   {
diff --git a/src/utils_threshold.c b/src/utils_threshold.c
index 6c131ba..f65a1d8 100644
--- a/src/utils_threshold.c
+++ b/src/utils_threshold.c
@@ -501,46 +501,45 @@ int ut_config (const oconfig_item_t *ci)
  */
 /* }}} */
 
-static threshold_t *threshold_search (const data_set_t *ds,
-    const value_list_t *vl)
+static threshold_t *threshold_search (const value_list_t *vl)
 {
   threshold_t *th;
 
   if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance,
-	  ds->type, vl->type_instance)) != NULL)
+	  vl->type, vl->type_instance)) != NULL)
     return (th);
   else if ((th = threshold_get (vl->host, vl->plugin, vl->plugin_instance,
-	  ds->type, NULL)) != NULL)
+	  vl->type, NULL)) != NULL)
     return (th);
   else if ((th = threshold_get (vl->host, vl->plugin, NULL,
-	  ds->type, vl->type_instance)) != NULL)
+	  vl->type, vl->type_instance)) != NULL)
     return (th);
   else if ((th = threshold_get (vl->host, vl->plugin, NULL,
-	  ds->type, NULL)) != NULL)
+	  vl->type, NULL)) != NULL)
     return (th);
   else if ((th = threshold_get (vl->host, "", NULL,
-	  ds->type, vl->type_instance)) != NULL)
+	  vl->type, vl->type_instance)) != NULL)
     return (th);
   else if ((th = threshold_get (vl->host, "", NULL,
-	  ds->type, NULL)) != NULL)
+	  vl->type, NULL)) != NULL)
     return (th);
   else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance,
-	  ds->type, vl->type_instance)) != NULL)
+	  vl->type, vl->type_instance)) != NULL)
     return (th);
   else if ((th = threshold_get ("", vl->plugin, vl->plugin_instance,
-	  ds->type, NULL)) != NULL)
+	  vl->type, NULL)) != NULL)
     return (th);
   else if ((th = threshold_get ("", vl->plugin, NULL,
-	  ds->type, vl->type_instance)) != NULL)
+	  vl->type, vl->type_instance)) != NULL)
     return (th);
   else if ((th = threshold_get ("", vl->plugin, NULL,
-	  ds->type, NULL)) != NULL)
+	  vl->type, NULL)) != NULL)
     return (th);
   else if ((th = threshold_get ("", "", NULL,
-	  ds->type, vl->type_instance)) != NULL)
+	  vl->type, vl->type_instance)) != NULL)
     return (th);
   else if ((th = threshold_get ("", "", NULL,
-	  ds->type, NULL)) != NULL)
+	  vl->type, NULL)) != NULL)
     return (th);
 
   return (NULL);
@@ -610,7 +609,7 @@ static int ut_report_state (const data_set_t *ds,
     bufsize -= status;
   }
 
-  status = snprintf (buf, bufsize, " type %s", ds->type);
+  status = snprintf (buf, bufsize, " type %s", vl->type);
   buf += status;
   bufsize -= status;
 
@@ -783,7 +782,7 @@ int ut_check_threshold (const data_set_t *ds, const value_list_t *vl)
   /* Is this lock really necessary? So far, thresholds are only inserted at
    * startup. -octo */
   pthread_mutex_lock (&threshold_lock);
-  th = threshold_search (ds, vl);
+  th = threshold_search (vl);
   pthread_mutex_unlock (&threshold_lock);
   if (th == NULL)
     return (0);
@@ -876,6 +875,8 @@ int ut_check_interesting (const char *name)
   }
   strncpy (ds.type, type, sizeof (ds.type));
   ds.type[sizeof (ds.type) - 1] = '\0';
+  strncpy (vl.type, type, sizeof (vl.type));
+  vl.type[sizeof (vl.type) - 1] = '\0';
   if (type_instance != NULL)
   {
     strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
@@ -885,7 +886,7 @@ int ut_check_interesting (const char *name)
   sfree (name_copy);
   host = plugin = plugin_instance = type = type_instance = NULL;
 
-  th = threshold_search (&ds, &vl);
+  th = threshold_search (&vl);
   if (th == NULL)
     return (0);
   if ((th->flags & UT_FLAG_PERSIST) == 0)
diff --git a/src/vmem.c b/src/vmem.c
index e0f76e7..1e826a1 100644
--- a/src/vmem.c
+++ b/src/vmem.c
@@ -50,10 +50,11 @@ static void submit (const char *plugin_instance, const char *type,
   strcpy (vl.plugin, "vmem");
   if (plugin_instance != NULL)
     sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_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 (type, &vl);
+  plugin_dispatch_values (&vl);
 } /* void vmem_submit */
 
 static void submit_two (const char *plugin_instance, const char *type,
diff --git a/src/vserver.c b/src/vserver.c
index 7b83c61..a222403 100644
--- a/src/vserver.c
+++ b/src/vserver.c
@@ -60,9 +60,10 @@ static void traffic_submit (const char *plugin_instance,
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "vserver");
 	strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+	strcpy (vl.type, "if_octets");
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values ("if_octets", &vl);
+	plugin_dispatch_values (&vl);
 } /* void traffic_submit */
 
 static void load_submit (const char *plugin_instance,
@@ -81,8 +82,9 @@ static void load_submit (const char *plugin_instance,
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "vserver");
 	strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+	strcpy (vl.type, "load");
 
-	plugin_dispatch_values ("load", &vl);
+	plugin_dispatch_values (&vl);
 }
 
 static void submit_gauge (const char *plugin_instance, const char *type,
@@ -100,9 +102,10 @@ static void submit_gauge (const char *plugin_instance, const char *type,
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "vserver");
 	strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+	strncpy (vl.type, type, sizeof (vl.type));
 	strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void submit_gauge */
 
 static inline long long __get_sock_bytes(const char *s)
diff --git a/src/wireless.c b/src/wireless.c
index 285fb74..cc622e1 100644
--- a/src/wireless.c
+++ b/src/wireless.c
@@ -60,8 +60,9 @@ static void wireless_submit (const char *plugin_instance, const char *type,
 	strcpy (vl.plugin, "wireless");
 	strncpy (vl.plugin_instance, plugin_instance,
 			sizeof (vl.plugin_instance));
+	strncpy (vl.type, type, sizeof (vl.type));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void wireless_submit */
 
 #define POWER_MIN -90.0
diff --git a/src/xmms.c b/src/xmms.c
index 1e646d2..d6c1abc 100644
--- a/src/xmms.c
+++ b/src/xmms.c
@@ -39,8 +39,9 @@ static void cxmms_submit (const char *type, gauge_t value)
 	vl.time = time (NULL);
 	strcpy (vl.host, hostname_g);
 	strcpy (vl.plugin, "xmms");
+	strncpy (vl.type, type, sizeof (vl.type));
 
-	plugin_dispatch_values (type, &vl);
+	plugin_dispatch_values (&vl);
 } /* void cxmms_submit */
 
 int cxmms_read (void)
-- 
1.5.5.29.g7134

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080420/e5a033cf/attachment-0001.pgp 


More information about the collectd mailing list