From 4e8eff69ce83002dd58c8125597e3975f9526ba0 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 4 Sep 2013 16:38:34 +0200 Subject: 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 Signed-off-by: Tobias Klauser --- ifpps.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ifpps.c') diff --git a/ifpps.c b/ifpps.c index 60cd3b3..a0e3d13 100644 --- a/ifpps.c +++ b/ifpps.c @@ -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) { @@ -1055,6 +1069,9 @@ static void screen_update(WINDOW *screen, const char *ifname, const struct ifsta voff++; screen_net_dev_rel(screen, rel, &voff); + voff++; + screen_net_dev_percentage(screen, rel, &voff, rate); + voff++; screen_net_dev_abs(screen, abs, &voff); -- cgit v1.2.3-54-g00ecf