From: Dobrica Pavlinusic Date: Mon, 12 Dec 2016 06:13:05 +0000 (+0100) Subject: reset date on each hour change in output X-Git-Url: http://git.rot13.org/?p=influxdb-pipes;a=commitdiff_plain;h=e666fa3b7bf5f321c639e48d5c10588f0054b58c reset date on each hour change in output --- diff --git a/ifstat.pl b/ifstat.pl index a43b626..832f24a 100755 --- a/ifstat.pl +++ b/ifstat.pl @@ -46,6 +46,8 @@ my $lines; my $host_tags = $host; $host_tags =~ s/\./,domain=/; +my $last_hour = $hour; + while(<$ifstat>) { chomp; #warn "# [$_]\n"; @@ -61,6 +63,12 @@ while(<$ifstat>) { @direction = map { s/\W+/_/g; s/^K//; $_ } @v; } elsif ( $v[0] =~ m/^(\d\d):(\d\d):(\d\d)/ ) { next unless $first_skipped++; + + if ( $last_hour != $hour ) { + ($sec,$min,$hour,$dd,$mm,$yyyy) = localtime(time); $mm++; + $last_hour = $hour; + } + $hour = $1; $min = $2; $sec = $3; update_time; reopen_curl;