From: Sebastian Harl Date: Sat, 14 Feb 2009 15:45:55 +0000 (+0100) Subject: perl plugin: Don't ignore the 'interval' member when converting value lists. X-Git-Tag: collectd-4.6.0~14 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1e8c3602556660056f20221a6c8b704c701ada62;p=collectd.git perl plugin: Don't ignore the 'interval' member when converting value lists. --- 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;