diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2013-09-04 16:38:34 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2013-09-04 16:38:34 +0200 |
commit | 4e8eff69ce83002dd58c8125597e3975f9526ba0 (patch) | |
tree | 78e521544b1cd8aaa0bc59a86a0c93fd37adae4d /ifpps.c | |
parent | e4e41ae1cad3fadf384564c860b4c93e8fb895da (diff) |
ifpps: show percentage of theoretical line-rate
Also show the percentage of the (theoretical) line rate, not just the
current rate.
Suggested-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ifpps.c')
-rw-r--r-- | ifpps.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -746,6 +746,20 @@ static void screen_net_dev_rel(WINDOW *screen, const struct ifstat *rel, attroff(A_REVERSE); } +static void screen_net_dev_percentage(WINDOW *screen, const struct ifstat *rel, + int *voff, u32 rate) +{ + mvwprintw(screen, (*voff)++, 0, + " rx: %15.2llf%% of line rate " + " ", + rate ? ((((long double) rel->rx_bytes) / (1LLU << 20)) / rate) * 100.0 : 0.0); + + mvwprintw(screen, (*voff)++, 0, + " tx: %15.2llf%% of line rate " + " ", + rate ? ((((long double) rel->tx_bytes) / (1LLU << 20)) / rate) * 100.0 : 0.0); +} + static void screen_net_dev_abs(WINDOW *screen, const struct ifstat *abs, int *voff) { @@ -1056,6 +1070,9 @@ static void screen_update(WINDOW *screen, const char *ifname, const struct ifsta screen_net_dev_rel(screen, rel, &voff); voff++; + screen_net_dev_percentage(screen, rel, &voff, rate); + + voff++; screen_net_dev_abs(screen, abs, &voff); voff++; |