From e666fa3b7bf5f321c639e48d5c10588f0054b58c Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 12 Dec 2016 07:13:05 +0100 Subject: [PATCH] reset date on each hour change in output --- ifstat.pl | 8 ++++++++ 1 file changed, 8 insertions(+) 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; -- 2.20.1