summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 409d900)
raw | patch | inline | side by side (parent: 409d900)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 20 Apr 2008 21:19:28 +0000 (23:19 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 23 Apr 2008 13:39:21 +0000 (15:39 +0200) |
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@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
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@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
55 files changed:
diff --git a/src/apache.c b/src/apache.c
index 3cda565074eb0376014946386856b8fba0f05ed8..55d8cd479976481cf03aaf2abdd021491b857f09 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
strcpy (vl.host, hostname_g);
strcpy (vl.plugin, "apache");
strcpy (vl.plugin_instance, "");
+ strncpy (vl.type, type, sizeof (vl.type));
if (type_instance != NULL)
{
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,
strcpy (vl.host, hostname_g);
strcpy (vl.plugin, "apache");
strcpy (vl.plugin_instance, "");
+ strncpy (vl.type, type, sizeof (vl.type));
if (type_instance != NULL)
{
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 5a03764f59f5ea53bc1ac63cd549f183d22e40d1..7f8afd461e4cacd6f2eeadca5e2a282039ba79bd 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
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 2726ad2efdb6fc550e05163814e4c2f9c2d49557..5db6e9c5e1911bb66cded4642013d63c251f662e 100644 (file)
--- a/src/apple_sensors.c
+++ b/src/apple_sensors.c
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 94691d6b08a545e4b72ffad26e09b775a5624db7..e8ac0c2023b3a1002b5dae49973822d83835e146 100644 (file)
--- a/src/ascent.c
+++ b/src/ascent.c
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 345f606e8f3f834b5398fd15b3c91308607fb4a0..0522015237d586897327b916f56d9602b1352223 100644 (file)
--- 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 4a01d1465b90a9e37986416f4a49b88649b0a5e8..5a58d357dd8ff5e7e1f5bc7988f66becfd4bea16 100644 (file)
--- a/src/collectd-perl.pod
+++ b/src/collectd-perl.pod
time => time (),
host => $hostname_g,
plugin => 'myplugin',
+ type => 'myplugin',
plugin_instance => '',
type_instance => ''
}
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 c79c4b66bc4e01b994eb95222189592a413487d6..49d5effce840d6c78ea6a7e7ef24078c188a8891 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
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 42248a98deebf9a8b4a5f6e5d5e7f76c72e0b2e9..5cb1b4e3fdb47ba1a43b1e771df246f66ae34919 100644 (file)
--- a/src/cpufreq.c
+++ b/src/cpufreq.c
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 ff59f91c006e81511b6aeec738000398ed945bdc..b5de302eefd4c21ce8c6e26a4b2d306fcd7889f4 100644 (file)
--- a/src/csv.c
+++ b/src/csv.c
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);
int offset = 0;
int status;
+ assert (0 == strcmp (ds->type, vl->type));
+
if (datadir != NULL)
{
status = snprintf (buffer + offset, buffer_len - offset,
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;
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 0f357d8ded8671e7ced051c4b0b01c17760653cd..f4227435a0cc7e556a3d9294042c9de5838e78b1 100644 (file)
--- a/src/df.c
+++ b/src/df.c
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 5491dcbd625f99124a4abf456a22ac5976aaafea..50beb46096c14cf07c645152e49c97fdfe11e936 100644 (file)
--- a/src/disk.c
+++ b/src/disk.c
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 e9996b996d74409b3a4fbd0a61635dd4ce63b8ca..b61d768df73a0705236fd2f11f83274653588736 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
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)
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 869b7c36aa620cff5f7ae2f2d806d79868084eea..50599c02e052544c4b0e65ebdee008864fe4e8b5 100644 (file)
--- 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 5f9eb530caf33bf95e364199312f310d2e0fe8d8..85d41cfc6d54ef74b9e5c913f74592f8b937b13a 100644 (file)
--- a/src/entropy.c
+++ b/src/entropy.c
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 36ada53c4b2b673375e9a7982f3b62dd7dff383b..b4a50ac77f9ac7790db010dddae2c341ab8fb765 100644 (file)
--- a/src/hddtemp.c
+++ b/src/hddtemp.c
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 741ff764bd576f4ee45f5ea2d5ffb0cea14c8477..6edecc4d62991d8c02a984c74cc40dd4e14ad6cc 100644 (file)
--- a/src/interface.c
+++ b/src/interface.c
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 95e2e7c1023fd140e7012920e548d2ad4c5ed5e6..7a00c887898d7035e63b30ca6601119ced9dbdf9 100644 (file)
--- a/src/ipmi.c
+++ b/src/ipmi.c
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 72b4481cc5148ff500d6ed01076c12378a6c3932..5e9619afc44186e8e3d1ba18c549325af08a9954 100644 (file)
--- a/src/iptables.c
+++ b/src/iptables.c
}
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 68a3d7f3bf9d46a9f47c17492a6acd926458cfbc..c5054a8380b7eecfc715d2fb6996a5442bce4e1c 100644 (file)
--- a/src/ipvs.c
+++ b/src/ipvs.c
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 */
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 9eb1de426b83bea8b7243f0c2e9c993de87fdb1c..a8866b744a18c3ee3f77aed7bd61a1edc9035620 100644 (file)
--- a/src/irq.c
+++ b/src/irq.c
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 327536a1fe15012b40dd55f765b3e321c550258a..bd09abfa0103498c55fd791a17458c415ddadd5f 100644 (file)
--- a/src/libvirt.c
+++ b/src/libvirt.c
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
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
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 c9f130b7864609bf31b68aad4dfc4b4508a7e2e6..e9ce7be0d6e521765b0deb475bff4d906c46dc71 100644 (file)
--- a/src/load.c
+++ b/src/load.c
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 50d7363268840771f6d7ff30d85ae58e252bc7ec..e223b95c4be158b23249efb6b7e06967ac0b821b 100644 (file)
--- a/src/mbmon.c
+++ b/src/mbmon.c
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 a1825780ee1624ab7f4583bdf70295faef48a766..c2c8d27add31524e6ca6879a660ad531751f7124 100644 (file)
--- a/src/memcached.c
+++ b/src/memcached.c
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 */
/* }}} */
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 */
/* }}} */
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);
}
/* }}} */
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 3fbd33fb0c1da1a90cb666e1e6df044a711a2f64..5cb574dc9f18ef3c8dace1d9e90a6e0041c526ac 100644 (file)
--- a/src/memory.c
+++ b/src/memory.c
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 11ca42c1f6fd1dcda1c7dacb57754f7b33f8c8e7..e09d9f989f5092db830b1998258b3a4d703fa516 100644 (file)
--- a/src/multimeter.c
+++ b/src/multimeter.c
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 d4728531027be022e8ad9d6a57994a06711785d8..5994183ba9743dc2257d48adc534eb23df42ea19 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
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,
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,
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)
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 22afdc77f9a1701e8763207efe8bf1391c2c683e..55371c33e421945198945f16ebd8b07a907eec01 100644 (file)
--- a/src/netlink.c
+++ b/src/netlink.c
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,
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 e15036424d880316ec58bcdffd7d9d3cc76ff2ae..4e1504f51f1aabda5c410fbae018f9ed29e81200 100644 (file)
--- a/src/network.c
+++ b/src/network.c
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;
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);
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;
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
{
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)
{
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)
/* 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 77c7f48f92e3aee3be927e4b34be9c1fa89b01d7..367e7142ab2f67c1857634671ee00f991a114d97 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
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++)
{
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 3b107fb72ad209c41d08c22ded54fe349310d305..a95362be4f7fd58a29cf3d2db610b0f4f4e71e48 100644 (file)
--- a/src/nginx.c
+++ b/src/nginx.c
strcpy (vl.host, hostname_g);
strcpy (vl.plugin, "nginx");
strcpy (vl.plugin_instance, "");
+ strncpy (vl.type, type, sizeof (vl.type));
if (inst != NULL)
{
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 90fdfd7c587628fd8f035dd43ae9d28b47f87094..81b74ef8d483555484fb0da1ca9ecddd161efd74 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
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 f7f026a6299adac2a87d2dc1432789880273c1e2..bcb0ae95650404fa69d8ad4bbfe9223ca7c69650 100644 (file)
--- a/src/nut.c
+++ b/src/nut.c
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 96e85622445da09a7b9ad8deae514e215d279e6f..0f7d114167e1950371c89e8855d52664abd2cdf1 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
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))
* 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;
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)))))) {
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) {
list.type_instance[DATA_MAX_NAME_LEN - 1] = '\0';
}
- ret = plugin_dispatch_values (name, &list);
+ ret = plugin_dispatch_values (&list);
sfree (val);
return ret;
* time => $time,
* host => $hostname,
* plugin => $plugin,
+ * type => $type,
* plugin_instance => $instance,
* type_instance => $type_instance
* };
*/
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 2f7c064d1871363f3199a8deb581a2681e9ff51d..f298785adfd97393bcf262a69e5a6f28eb344630 100644 (file)
--- a/src/ping.c
+++ b/src/ping.c
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 1aad97c1d7f073931de749bb9676874de3d2b59c..f590580854bce472480ac48ff96c28ca9cbfa32a 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
}
} /* 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 "
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);
}
(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);
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 7b59930df3f7ae53eea9690f74d7b998846948ed..488e041ed44964de0260ee5ac0d7f1e2b27ae0f3 100644 (file)
--- a/src/plugin.h
+++ b/src/plugin.h
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
{
* 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 9caa77086535de7352dbad1c8368b0967c23d665..c82d4077e319acd34fce80833c207aae78d4db94 100644 (file)
--- a/src/powerdns.c
+++ b/src/powerdns.c
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 22d369df279c73ddccaf4489d586eb7eddd84d08..1b413725d1cfbb0a662eb23ed422d358c7fc7efd 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
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)
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 93c9d7a8ac670897747a3f6231bd5f2f8df34de1..fad1e4b4455d5c6403df9ecc3a09522edade8981 100644 (file)
--- a/src/rrdtool.c
+++ b/src/rrdtool.c
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;
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 60863193d36fe553f3f5c28948ef3a4600fe1c11..e69389c621e0cc7d0bc2b29011a6e2501aa8f6ad 100644 (file)
--- a/src/sensors.c
+++ b/src/sensors.c
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 9cfe1dd471b6ee1e195781617512a4ee16dd5d05..fb30fc4e7e01e2ea9b4408759cd58fa3b2ec9fcf 100644 (file)
--- a/src/serial.c
+++ b/src/serial.c
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 4311ff1670b5f92a6e2927d16420e2c1c5f8a011..77cc557ca87158762b3cf0dd7279dc69665f9577 100644 (file)
--- 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 1cf707797f1057b4fb6124c763a46e057b2753ee..632d372e1bc6e5e48acf5181691f7ddef6cb07e8 100644 (file)
--- a/src/swap.c
+++ b/src/swap.c
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 465688ed5cf2a470df3430fed859c44f2b9f83e6..c374d59820e6dd1d7bc93083d831081594f2dec8 100644 (file)
--- a/src/tape.c
+++ b/src/tape.c
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 fdf7ec1bf1ed867c5f08080c89e0e8a235557330..8c7beea5808fef6e6c29bc752b8e74a2bd45e40d 100644 (file)
--- a/src/tcpconns.c
+++ b/src/tcpconns.c
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))
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);
}
}
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 b7992d808524ded44b81678cd8da890a8970546f..e3f12990450be955df0720d06bf24487d78deecb 100644 (file)
--- a/src/teamspeak2.c
+++ b/src/teamspeak2.c
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,
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 afe26e1e27fc27a3d155b135b56d3571290bcd46..bec908ca7c6fb9dbcfa3718353ab309337effdd0 100644 (file)
--- a/src/users.c
+++ b/src/users.c
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 98b5043f33d1a94156fa509404a840af76dc69bb..023e4a7111efffc14cd1542e1eeae39a263127d5 100644 (file)
--- a/src/utils_cmd_putval.c
+++ b/src/utils_cmd_putval.c
#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;
return (-1);
}
- plugin_dispatch_values (type, vl);
+ plugin_dispatch_values (vl);
return (0);
} /* int parse_value */
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);
/* 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 34fe2dced95c91fc5a493dc71a724248ceec45a1..f518b1cd9172304d0319851b78c862c48a6a2388 100644 (file)
--- a/src/utils_tail_match.c
+++ b/src/utils_tail_match.c
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 6c131ba62644c3c9f99228e53b812a5fb6ade513..f65a1d80eb53c565c7d690c3faa65d7cad83b02f 100644 (file)
--- a/src/utils_threshold.c
+++ b/src/utils_threshold.c
*/
/* }}} */
-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);
bufsize -= status;
}
- status = snprintf (buf, bufsize, " type %s", ds->type);
+ status = snprintf (buf, bufsize, " type %s", vl->type);
buf += status;
bufsize -= status;
/* 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);
}
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));
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 e0f76e765541bdfb5de7421c643e68994c1d5b25..1e826a16b8a701bd5367dd3f1fc5e7a9de76bdc8 100644 (file)
--- a/src/vmem.c
+++ b/src/vmem.c
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 7b83c6174a830a0da933f4bd0c90f1c1180b67a3..a22240303c8c17540372cbcdd3edbd1a859ed76c 100644 (file)
--- a/src/vserver.c
+++ b/src/vserver.c
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,
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,
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 285fb744748c64714aa7eed8948e2f5b73df73c3..cc622e12789dcf7945ce34c1c8dad3cfc218294d 100644 (file)
--- a/src/wireless.c
+++ b/src/wireless.c
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 1e646d21165722b289f6721dd672837e03b5b40c..d6c1abc7668f041ba2360e8b9f42f927f91dbf72 100644 (file)
--- a/src/xmms.c
+++ b/src/xmms.c
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)