Option to display packet counts - Frédéric Perrin <fperrin@brocade.com>
Add a "-u unit" CLI option, as well as a "bandwidth-unit" configuration file option. With "-u packets", traffic is accounted using packets per second; the other options are "-u bits" and "-u bytes". "-B" is still recognized as synonym to "-u bytes". The default is "-u bits", keeping the current behaviour of iftop (everything is in bits/s, except the cumulative totals).
This commit is contained in:
16
tui.c
16
tui.c
@@ -87,7 +87,7 @@ void tui_print() {
|
||||
/* Send rate per connection */
|
||||
printf("%4d %s%s", l, host1, " =>");
|
||||
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
||||
readable_size(screen_line->sent[j], buf0_10, 10, 1024, options.bandwidth_in_bytes);
|
||||
readable_size(screen_line->sent[j], buf0_10, 10, 1024, options.bandwidth_unit);
|
||||
printf(" %10s", buf0_10);
|
||||
}
|
||||
/* Cumulative sent data per connection */
|
||||
@@ -97,7 +97,7 @@ void tui_print() {
|
||||
/* Receive rate per connection */
|
||||
printf(" %s%s", host2, " <=");
|
||||
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
||||
readable_size(screen_line->recv[j], buf0_10, 10, 1024, options.bandwidth_in_bytes);
|
||||
readable_size(screen_line->recv[j], buf0_10, 10, 1024, options.bandwidth_unit);
|
||||
printf(" %10s", buf0_10);
|
||||
}
|
||||
/* Cumulative received data per connection */
|
||||
@@ -115,21 +115,21 @@ void tui_print() {
|
||||
snprintf(labellong, PRINT_WIDTH + 9, "%-*s", PRINT_WIDTH + 9, "Total send rate:");
|
||||
printf("%s ", labellong);
|
||||
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
||||
readable_size((((host_pair_line *)&totals)->sent[j]) , buf0_10, 10, 1024, options.bandwidth_in_bytes);
|
||||
readable_size(((host_pair_line *)&totals)->sent[j], buf0_10, 10, 1024, options.bandwidth_unit);
|
||||
printf("%10s%c", buf0_10, j == HISTORY_DIVISIONS - 1 ? '\n' : ' ');
|
||||
}
|
||||
|
||||
snprintf(labellong, PRINT_WIDTH + 9, "%-*s", PRINT_WIDTH + 9, "Total receive rate:");
|
||||
printf("%s ", labellong);
|
||||
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
||||
readable_size((((host_pair_line *)&totals)->recv[j]) , buf0_10, 10, 1024, options.bandwidth_in_bytes);
|
||||
readable_size(((host_pair_line *)&totals)->recv[j], buf0_10, 10, 1024, options.bandwidth_unit);
|
||||
printf("%10s%c", buf0_10, j == HISTORY_DIVISIONS - 1 ? '\n' : ' ');
|
||||
}
|
||||
|
||||
snprintf(labellong, PRINT_WIDTH + 9, "%-*s", PRINT_WIDTH + 9, "Total send and receive rate:");
|
||||
printf("%s ", labellong);
|
||||
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
||||
readable_size((((host_pair_line *)&totals)->sent[j] + ((host_pair_line *)&totals)->recv[j]) , buf0_10, 10, 1024, options.bandwidth_in_bytes);
|
||||
readable_size(((host_pair_line *)&totals)->sent[j] + ((host_pair_line *)&totals)->recv[j], buf0_10, 10, 1024, options.bandwidth_unit);
|
||||
printf("%10s%c", buf0_10, j == HISTORY_DIVISIONS - 1 ? '\n' : ' ');
|
||||
}
|
||||
|
||||
@@ -141,9 +141,9 @@ void tui_print() {
|
||||
|
||||
/* Peak traffic */
|
||||
snprintf(labellong, PRINT_WIDTH + 9, "%-*s", PRINT_WIDTH + 9, "Peak rate (sent/received/total):");
|
||||
readable_size(peaksent / RESOLUTION, buf0_10, 10, 1024, options.bandwidth_in_bytes);
|
||||
readable_size(peakrecv / RESOLUTION, buf1_10, 10, 1024, options.bandwidth_in_bytes);
|
||||
readable_size(peaktotal / RESOLUTION, buf2_10, 10, 1024, options.bandwidth_in_bytes);
|
||||
readable_size(peaksent / RESOLUTION, buf0_10, 10, 1024, options.bandwidth_unit);
|
||||
readable_size(peakrecv / RESOLUTION, buf1_10, 10, 1024, options.bandwidth_unit);
|
||||
readable_size(peaktotal / RESOLUTION, buf2_10, 10, 1024, options.bandwidth_unit);
|
||||
printf("%s %10s %10s %10s\n", labellong, buf0_10, buf1_10, buf2_10);
|
||||
|
||||
/* Cumulative totals */
|
||||
|
||||
Reference in New Issue
Block a user