From 1c3972d59caec71455c45758e53703d1f2af71aa Mon Sep 17 00:00:00 2001 From: seb Date: Tue, 25 Sep 2012 15:13:18 +0200 Subject: [PATCH] New field added to mpstat: %gnice. This is the time spent by the CPU running a niced guest. mpstat manual page updated. --- CHANGES | 6 +++--- man/mpstat.1 | 8 +++++++- mpstat.c | 36 ++++++++++++++++++++++++------------ mpstat.h | 2 +- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index 76832af..05f57a0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,12 +1,12 @@ Changes: xxxx/xx/xx: Version 10.1.2 - Sebastien Godard (sysstat orange.fr) - * New field added to sar -u: %gnice (time spent running a niced - guest). + * New field added to sar -u and mpstat: %gnice (time spent + running a niced guest). * [Peter Schiffer]: systemd support added. * [Peter Schiffer]: Sysstat init script updated to make it more conforming to LSB. - * sar and sadf manual pages updated. + * sar, sadf and mpstat manual pages updated. * DTD and XSD documents updated. * Cosmetic change in sadf -H output. diff --git a/man/mpstat.1 b/man/mpstat.1 index 253d67d..38a85b5 100644 --- a/man/mpstat.1 +++ b/man/mpstat.1 @@ -1,4 +1,4 @@ -.TH MPSTAT 1 "JULY 2012" Linux "Linux User's Manual" -*- nroff -*- +.TH MPSTAT 1 "SEPTEMBER 2012" Linux "Linux User's Manual" -*- nroff -*- .SH NAME mpstat \- Report processors related statistics. .SH SYNOPSIS @@ -159,6 +159,12 @@ Show the percentage of time spent by the CPU or CPUs to run a virtual processor. .RE +.B %gnice +.RS +Show the percentage of time spent by the CPU or CPUs to run a niced +guest. +.RE + .B %idle .RS Show the percentage of time that the CPU or CPUs were idle and the system diff --git a/mpstat.c b/mpstat.c index 42fc733..3fca3b5 100644 --- a/mpstat.c +++ b/mpstat.c @@ -354,7 +354,7 @@ void write_stats_core(int prev, int curr, int dis, if (DISPLAY_CPU(actflags)) { if (dis) { printf("\n%-11s CPU %%usr %%nice %%sys %%iowait %%irq " - "%%soft %%steal %%guest %%idle\n", + "%%soft %%steal %%guest %%gnice %%idle\n", prev_string); } @@ -363,15 +363,18 @@ void write_stats_core(int prev, int curr, int dis, printf("%-11s all", curr_string); - printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f\n", + printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f\n", (st_cpu[curr]->cpu_user - st_cpu[curr]->cpu_guest) < (st_cpu[prev]->cpu_user - st_cpu[prev]->cpu_guest) ? 0.0 : ll_sp_value(st_cpu[prev]->cpu_user - st_cpu[prev]->cpu_guest, st_cpu[curr]->cpu_user - st_cpu[curr]->cpu_guest, g_itv), - ll_sp_value(st_cpu[prev]->cpu_nice, - st_cpu[curr]->cpu_nice, + (st_cpu[curr]->cpu_nice - st_cpu[curr]->cpu_guest_nice) < + (st_cpu[prev]->cpu_nice - st_cpu[prev]->cpu_guest_nice) ? + 0.0 : + ll_sp_value(st_cpu[prev]->cpu_nice - st_cpu[prev]->cpu_guest_nice, + st_cpu[curr]->cpu_nice - st_cpu[curr]->cpu_guest_nice, g_itv), ll_sp_value(st_cpu[prev]->cpu_sys, st_cpu[curr]->cpu_sys, @@ -391,6 +394,9 @@ void write_stats_core(int prev, int curr, int dis, ll_sp_value(st_cpu[prev]->cpu_guest, st_cpu[curr]->cpu_guest, g_itv), + ll_sp_value(st_cpu[prev]->cpu_guest_nice, + st_cpu[curr]->cpu_guest_nice, + g_itv), (st_cpu[curr]->cpu_idle < st_cpu[prev]->cpu_idle) ? 0.0 : ll_sp_value(st_cpu[prev]->cpu_idle, @@ -410,7 +416,8 @@ void write_stats_core(int prev, int curr, int dis, /* * If the CPU is offline then it is omited from /proc/stat * and the sum of all values is zero. - * (Remember that guest time is already included in user mode.) + * (Remember that guest/guest_nice times are already included in + * user/nice modes.) */ if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys + scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal + @@ -419,9 +426,9 @@ void write_stats_core(int prev, int curr, int dis, if (!DISPLAY_ONLINE_CPU(flags)) { printf("%-11s %4d" " %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f" - " %6.2f %6.2f %6.2f\n", + " %6.2f %6.2f %6.2f %6.2f\n", curr_string, cpu - 1, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } continue; } @@ -437,20 +444,22 @@ void write_stats_core(int prev, int curr, int dis, * but the sum of values is not zero. */ printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f" - " %6.2f %6.2f %6.2f\n", - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0); + " %6.2f %6.2f %6.2f %6.2f\n", + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0); } else { printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f" - " %6.2f %6.2f %6.2f\n", + " %6.2f %6.2f %6.2f %6.2f\n", (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ? 0.0 : ll_sp_value(scp->cpu_user - scp->cpu_guest, scc->cpu_user - scc->cpu_guest, pc_itv), - ll_sp_value(scp->cpu_nice, - scc->cpu_nice, + (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ? + 0.0 : + ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice, + scc->cpu_nice - scc->cpu_guest_nice, pc_itv), ll_sp_value(scp->cpu_sys, scc->cpu_sys, @@ -470,6 +479,9 @@ void write_stats_core(int prev, int curr, int dis, ll_sp_value(scp->cpu_guest, scc->cpu_guest, pc_itv), + ll_sp_value(scp->cpu_guest_nice, + scc->cpu_guest_nice, + pc_itv), (scc->cpu_idle < scp->cpu_idle) ? 0.0 : ll_sp_value(scp->cpu_idle, diff --git a/mpstat.h b/mpstat.h index 13c0bdd..299a003 100644 --- a/mpstat.h +++ b/mpstat.h @@ -1,6 +1,6 @@ /* * mpstat: per-processor statistics - * (C) 2000-2011 by Sebastien Godard (sysstat orange.fr) + * (C) 2000-2012 by Sebastien Godard (sysstat orange.fr) */ #ifndef _MPSTAT_H -- 2.40.0