[scripts] AggCheck: -n prints total nb of packets

This commit is contained in:
Matteo Cypriani 2013-08-02 08:36:14 -04:00
parent 89cf84403c
commit 935b77e114
1 changed files with 14 additions and 3 deletions

View File

@ -44,7 +44,8 @@ Print signal strength distribution in CSV format.
=item B<-n> =item B<-n>
Print per-request statistics in CSV format. Print per-request statistics in CSV format, as well as the total number of
packets received by each capture point.
=item B<-v> =item B<-v>
@ -251,6 +252,9 @@ while (<>) {
## Print statistics ## ## Print statistics ##
if ($print_stats) { if ($print_stats) {
# Will contain the total number of packets received by each CP
my %total_nb_pkts;
# Print the header line # Print the header line
my @cps_names = sort keys %global_present_cps; my @cps_names = sort keys %global_present_cps;
print "Timestamp"; print "Timestamp";
@ -261,12 +265,19 @@ if ($print_stats) {
foreach my $timestamp (sort keys %global_stats) { foreach my $timestamp (sort keys %global_stats) {
print "$timestamp"; print "$timestamp";
my $present_cps = $global_stats{$timestamp}; my $present_cps = $global_stats{$timestamp};
# Print the CPs in the same order as in the header # Print the CPs in the same order as in the header and count the totals
foreach my $mac (@cps_names) { foreach my $mac (@cps_names) {
print ";", ($present_cps->{$mac} or 0); my $nb_pkts = ($present_cps->{$mac} or 0);
print ";", $nb_pkts;
$total_nb_pkts{$mac} += $nb_pkts;
} }
print "\n"; print "\n";
} }
# Print the totals
print "Total";
print ";$total_nb_pkts{$_}" foreach (@cps_names);
print "\n";
} }