From: Matthias Bethke Date: Tue, 22 Nov 2016 16:53:30 +0000 (+0700) Subject: recognize seconds with and without fractional part X-Git-Tag: collectd-5.7.0~28^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=eeff4955c4db2d18193b6335274afd0023b765e2;p=collectd.git recognize seconds with and without fractional part --- 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;