Skip to content

Commit

Permalink
sum is not needed in the histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
toralf committed Jul 11, 2024
1 parent 4b6a730 commit 5da0ff1
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions metrics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ function _histogram() {
BEGIN {
@arr = (0) x 24; # 0-23 hour
$inf = 0; # anything above
$sum = 0;
}
{
chomp();
my $hour = int(($F[2]-1)/3600);
if ($hour <= 23) {
$arr[$hour]++;
my $hour = int( ($F[2] - 1) / 3600);
if ($hour <= 23) {
$arr[$hour]++
} else {
$inf++;
}
$sum += $hour;
}
END {
Expand All @@ -49,7 +46,6 @@ function _histogram() {
my $count = $N + $inf;
print "'${var}'_bucket{ipver=\"'${v:-4}'\",nickname=\"'$nickname'\",mode=\"'$mode'\",le=\"+Inf\"} $count\n";
print "'${var}'_count{ipver=\"'${v:-4}'\",nickname=\"'$nickname'\",mode=\"'$mode'\"} $count\n";
print "'${var}'_sum{ipver=\"'${v:-4}'\",nickname=\"'$nickname'\",mode=\"'$mode'\"} $sum\n";
}'
}

Expand Down

0 comments on commit 5da0ff1

Please sign in to comment.