From 1e8c3602556660056f20221a6c8b704c701ada62 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sat, 14 Feb 2009 16:45:55 +0100 Subject: [PATCH] perl plugin: Don't ignore the 'interval' member when converting value lists. --- src/collectd-perl.pod | 1 + src/perl.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/collectd-perl.pod b/src/collectd-perl.pod index 18dbafdc..1bd87435 100644 --- a/src/collectd-perl.pod +++ b/src/collectd-perl.pod @@ -198,6 +198,7 @@ layout looks like this: { values => [123, 0.5], time => time (), + interval => $interval_g, host => $hostname_g, plugin => 'myplugin', type => 'myplugin', diff --git a/src/perl.c b/src/perl.c index 27abc623..81d78c67 100644 --- a/src/perl.c +++ b/src/perl.c @@ -339,16 +339,16 @@ static int hv2value_list (pTHX_ HV *hash, value_list_t *vl) } } - if (NULL != (tmp = hv_fetch (hash, "time", 4, 0))) { + if (NULL != (tmp = hv_fetch (hash, "time", 4, 0))) vl->time = (time_t)SvIV (*tmp); - } - if (NULL != (tmp = hv_fetch (hash, "host", 4, 0))) { + if (NULL != (tmp = hv_fetch (hash, "interval", 8, 0))) + vl->interval = SvIV (*tmp); + + if (NULL != (tmp = hv_fetch (hash, "host", 4, 0))) sstrncpy (vl->host, SvPV_nolen (*tmp), sizeof (vl->host)); - } - else { + else sstrncpy (vl->host, hostname_g, sizeof (vl->host)); - } if (NULL != (tmp = hv_fetch (hash, "plugin", 6, 0))) sstrncpy (vl->plugin, SvPV_nolen (*tmp), sizeof (vl->plugin)); @@ -535,6 +535,9 @@ static int value_list2hv (pTHX_ value_list_t *vl, data_set_t *ds, HV *hash) if (NULL == hv_store (hash, "time", 4, newSViv (vl->time), 0)) return -1; + if (NULL == hv_store (hash, "interval", 8, newSViv (vl->interval), 0)) + return -1; + if ('\0' != vl->host[0]) if (NULL == hv_store (hash, "host", 4, newSVpv (vl->host, 0), 0)) return -1; -- 2.30.2