]> granicus.if.org Git - sysstat/commitdiff
New field added to mpstat: %gnice.
authorseb <seb@kluane.home>
Tue, 25 Sep 2012 13:13:18 +0000 (15:13 +0200)
committerseb <seb@kluane.home>
Tue, 25 Sep 2012 13:13:18 +0000 (15:13 +0200)
This is the time spent by the CPU running a niced guest.
mpstat manual page updated.

CHANGES
man/mpstat.1
mpstat.c
mpstat.h

diff --git a/CHANGES b/CHANGES
index 76832af9dbfd652d5d8051b8fdbe4e60aa9b6629..05f57a06fd50609fbd865559844c93ef34873aaa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,12 +1,12 @@
 Changes:
 
 xxxx/xx/xx: Version 10.1.2 - Sebastien Godard (sysstat <at> 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.
 
index 253d67dc4bc8a242797b605af7ab20a306db241f..38a85b5ff7dbc46f7dc53a88cf942c94d3820843 100644 (file)
@@ -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
index 42fc733394a93c340a7a14baeda8bc0a681366cf..3fca3b5c9c672eaab35633f5dc9e983fafd8886e 100644 (file)
--- 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,
index 13c0bdddb8e804d6b5bf8aeec0e14571f0c630f4..299a003ee67257cc30f7803b6637ed95c34048b6 100644 (file)
--- a/mpstat.h
+++ b/mpstat.h
@@ -1,6 +1,6 @@
 /*
  * mpstat: per-processor statistics
- * (C) 2000-2011 by Sebastien Godard (sysstat <at> orange.fr)
+ * (C) 2000-2012 by Sebastien Godard (sysstat <at> orange.fr)
  */
 
 #ifndef _MPSTAT_H