diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-07-11 19:10:43 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-07-11 19:10:43 +0200 |
commit | 3163b713c4dbb0f92be80c57a8c720692e71df7f (patch) | |
tree | 43243435b8fcb86d0d9891d9cc7bc30d45592f41 | |
parent | 6511978b4b367e078e9a205e1109f7bd75d01ec5 (diff) |
ifpps: align avg on systems with >8 CPUs
When running ifpps on systems with 16, 32 or more CPUs, 'avg:...'
field is not being padded with witespaces as the rest of the CPU
lines. This patch does that.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r-- | ifpps.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -804,6 +804,7 @@ static void screen_percpu_states(WINDOW *screen, const struct ifstat *rel, { int i; int cpus = get_number_cpus(); + int max_padd = padding_from_num(cpus); uint64_t all; if (top_cpus == 0) @@ -825,10 +826,10 @@ static void screen_percpu_states(WINDOW *screen, const struct ifstat *rel, all = avg->cpu_user + avg->cpu_sys + avg->cpu_nice + avg->cpu_idle + avg->cpu_iow; mvwprintw(screen, (*voff)++, 2, - "avg: %14.1lf%% " + "avg:%*s%14.1lf%% " "%9.1lf%% " "%10.1lf%% " - "%11.1lf%%", + "%11.1lf%%", max_padd, "", 100.0 * (avg->cpu_user + avg->cpu_nice) / all, 100.0 * avg->cpu_sys / all, 100.0 * avg->cpu_idle /all, @@ -856,6 +857,7 @@ static void screen_percpu_irqs_rel(WINDOW *screen, const struct ifstat *rel, { int i; int cpus = get_number_cpus(); + int max_padd = padding_from_num(cpus); screen_percpu_irqs_rel_one(screen, rel, voff, cpu_hits[0].idx, "+"); @@ -869,9 +871,9 @@ static void screen_percpu_irqs_rel(WINDOW *screen, const struct ifstat *rel, screen_percpu_irqs_rel_one(screen, rel, voff, cpu_hits[cpus - 1].idx, "-"); mvwprintw(screen, (*voff)++, 2, - "avg: %17.1Lf " + "avg:%*s%17.1Lf " "%17.1Lf " - "%17.1Lf", + "%17.1Lf", max_padd, "", avg->irqs_rel, avg->irqs_srx_rel, avg->irqs_stx_rel); } @@ -891,6 +893,7 @@ static void screen_percpu_irqs_abs(WINDOW *screen, const struct ifstat *abs, { int i; int cpus = get_number_cpus(); + int max_padd = padding_from_num(cpus); screen_percpu_irqs_abs_one(screen, abs, voff, cpu_hits[0].idx, "+"); @@ -904,7 +907,7 @@ static void screen_percpu_irqs_abs(WINDOW *screen, const struct ifstat *abs, screen_percpu_irqs_abs_one(screen, abs, voff, cpu_hits[cpus - 1].idx, "-"); mvwprintw(screen, (*voff)++, 2, - "avg: %17.1Lf", avg->irqs_abs); + "avg:%*s%17.1Lf", max_padd, "", avg->irqs_abs); } static void screen_wireless(WINDOW *screen, const struct ifstat *rel, |