From eeff4955c4db2d18193b6335274afd0023b765e2 Mon Sep 17 00:00:00 2001 From: Matthias Bethke Date: Tue, 22 Nov 2016 23:53:30 +0700 Subject: [PATCH] recognize seconds with and without fractional part --- bindings/perl/lib/Collectd/MockDaemon.pm | 3 ++- bindings/perl/lib/Collectd/Unixsock.pm | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bindings/perl/lib/Collectd/MockDaemon.pm b/bindings/perl/lib/Collectd/MockDaemon.pm index abf058f6..9d784b7c 100644 --- a/bindings/perl/lib/Collectd/MockDaemon.pm +++ b/bindings/perl/lib/Collectd/MockDaemon.pm @@ -56,8 +56,9 @@ sub daemon { sub listval { my $trunc_now = substr(time, 0, -1); + my $toggle; return print_nvalues(scalar @metrics) . - join('', map { sprintf("%s%d.%d %s\n", $trunc_now, rand(10), rand(1000), $_) } @metrics); + join('', map { $trunc_now . int(rand(10)) . ($toggle=!$toggle ? ".".int(rand(1000)) : '') . " $_\n" } @metrics); } sub getval { diff --git a/bindings/perl/lib/Collectd/Unixsock.pm b/bindings/perl/lib/Collectd/Unixsock.pm index 96287eb4..f9db922c 100644 --- a/bindings/perl/lib/Collectd/Unixsock.pm +++ b/bindings/perl/lib/Collectd/Unixsock.pm @@ -383,7 +383,7 @@ sub listval_filter (exists $args{plugin_instance} ? "-$args{plugin_instance}" : '(?:-[^/]+)?') . (exists $args{type} ? "/$args{type}" : '/[^/-]+') . (exists $args{type_instance} ? "-$args{type_instance}" : '(?:-[^/]+)?'); - $pattern = qr/^\d+\.\d+ $pattern$/; + $pattern = qr/^\d+(?:\.\d+)? $pattern$/; my $msg = $self->_socket_command('LISTVAL') or return; ($nresults, $msg) = split / /, $msg, 2; -- 2.30.2