summaryrefslogtreecommitdiff
path: root/ifpps.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2013-09-04 16:38:34 +0200
committerTobias Klauser <tklauser@distanz.ch>2013-09-04 16:38:34 +0200
commit4e8eff69ce83002dd58c8125597e3975f9526ba0 (patch)
tree78e521544b1cd8aaa0bc59a86a0c93fd37adae4d /ifpps.c
parente4e41ae1cad3fadf384564c860b4c93e8fb895da (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.c17
1 files changed, 17 insertions, 0 deletions
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)
{
@@ -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++;