Added support for nice guest mode to sar.
authorseb <seb@kluane.home>
Tue, 25 Sep 2012 12:40:18 +0000 (14:40 +0200)
committerseb <seb@kluane.home>
Tue, 25 Sep 2012 13:11:12 +0000 (15:11 +0200)
New field added to sar -u: %gnice (time spent
running a niced guest).
sar manual page updated.
DTD and XSD documents updated.
sadf various output (XML, CSV, etc.) updated.

15 files changed:
CHANGES
activity.c
common.c
iostat.c
json_stats.c
man/sar.in
pr_stats.c
rd_stats.c
rd_stats.h
rndr_stats.c
sadf.h
xml/sysstat.dtd
xml/sysstat.xsd
xml_stats.c
xml_stats.h

diff --git a/CHANGES b/CHANGES
index 2ac0bc07603bfb75c85bbdadb943d4a14bc2f22a..76832af9dbfd652d5d8051b8fdbe4e60aa9b6629 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,10 +1,13 @@
 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).
        * [Peter Schiffer]: systemd support added.
        * [Peter Schiffer]: Sysstat init script updated to make it
          more conforming to LSB.
        * sar and sadf manual pages updated.
+       * DTD and XSD documents updated.
        * Cosmetic change in sadf -H output.
 
 2012/07/29: Version 10.1.1 - Sebastien Godard (sysstat <at> orange.fr)
index c73bca35dbbccd14941820cdfc3c0d2475ee7e43..65770d7e91f5e76dd71e4377db8fbc735997b036 100644 (file)
@@ -86,7 +86,7 @@ struct activity cpu_act = {
        .f_xml_print    = xml_print_cpu_stats,
        .f_json_print   = json_print_cpu_stats,
        .hdr_line       = "CPU;%user;%nice;%system;%iowait;%steal;%idle|"
-                         "CPU;%usr;%nice;%sys;%iowait;%steal;%irq;%soft;%guest;%idle",
+                         "CPU;%usr;%nice;%sys;%iowait;%steal;%irq;%soft;%guest;%gnice;%idle",
        .name           = "A_CPU",
 #endif
        .nr             = -1,
index 3b1dbbddab3b6be906921caa834157cff2c392a5..0a72ee103840ecdcd00cc24acf7e6a67054ebe43 100644 (file)
--- a/common.c
+++ b/common.c
@@ -585,15 +585,25 @@ unsigned long long get_per_cpu_interval(struct stats_cpu *scc,
        
        if ((scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest)) {
                /*
-               * Sometimes the nr of jiffies spent in guest mode given by the guest
-               * counter in /proc/stat is slightly higher than that included in
-               * the user counter. Update the interval value accordingly.
-               */
-               ishift = (scp->cpu_user - scp->cpu_guest) -
-                        (scc->cpu_user - scc->cpu_guest);
+                * Sometimes the nr of jiffies spent in guest mode given by the guest
+                * counter in /proc/stat is slightly higher than that included in
+                * the user counter. Update the interval value accordingly.
+                */
+               ishift += (scp->cpu_user - scp->cpu_guest) -
+                         (scc->cpu_user - scc->cpu_guest);
+       }
+       if ((scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice)) {
+               /*
+                * Idem for nr of jiffies spent in guest_nice mode.
+                */
+               ishift += (scp->cpu_nice - scp->cpu_guest_nice) -
+                         (scc->cpu_nice - scc->cpu_guest_nice);
        }
        
-       /* Don't take cpu_guest into account because cpu_user already includes it */
+       /*
+        * Don't take cpu_guest and cpu_guest_nice into account
+        * because cpu_user and cpu_nice already include them.
+        */
        return ((scc->cpu_user    + scc->cpu_nice   +
                 scc->cpu_sys     + scc->cpu_iowait +
                 scc->cpu_idle    + scc->cpu_steal  +
index deefa170e6faef22eb0fdd36222e55c52b564e24..d9d281262e07140d6294b29cdb087be2aba11811 100644 (file)
--- a/iostat.c
+++ b/iostat.c
@@ -1084,7 +1084,8 @@ void write_stats(int curr, struct tm *rectime)
                        /* Debug output */
                        fprintf(stderr, "itv=%llu st_cpu[curr]{ cpu_user=%llu cpu_nice=%llu "
                                        "cpu_sys=%llu cpu_idle=%llu cpu_iowait=%llu cpu_steal=%llu "
-                                       "cpu_hardirq=%llu cpu_softirq=%llu cpu_guest=%llu }\n",
+                                       "cpu_hardirq=%llu cpu_softirq=%llu cpu_guest=%llu "
+                                       "cpu_guest_nice=%llu }\n",
                                itv,
                                st_cpu[curr]->cpu_user,
                                st_cpu[curr]->cpu_nice,
@@ -1094,8 +1095,8 @@ void write_stats(int curr, struct tm *rectime)
                                st_cpu[curr]->cpu_steal,
                                st_cpu[curr]->cpu_hardirq,
                                st_cpu[curr]->cpu_softirq,
-                               st_cpu[curr]->cpu_guest
-                               );
+                               st_cpu[curr]->cpu_guest,
+                               st_cpu[curr]->cpu_guest_nice);
                }
 #endif
 
index 6fa031476b1caa5c9d01d07e186b7dfa97822bec..47360e6cc8ae70fecd21ffc428aa67cc0d092241 100644 (file)
@@ -147,7 +147,8 @@ __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
                                /*
                                 * If the CPU is offline then it is omited from /proc/stat:
                                 * All the fields couldn't have been read and the sum of them 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 +
@@ -194,9 +195,10 @@ __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
                                                         "\"irq\": %.2f, "
                                                         "\"soft\": %.2f, "
                                                         "\"guest\": %.2f, "
+                                                        "\"gnice\": %.2f, "
                                                         "\"idle\": %.2f}",
                                                         i - 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,
                                                         cpu_offline ? 0.0 : 100.0);
                                        }
                                        continue;
@@ -212,16 +214,16 @@ __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
                                         "\"steal\": %.2f, "
                                         "\"idle\": %.2f}",
                                         cpuno,
-                                        ll_sp_value(scp->cpu_user,   scc->cpu_user,   g_itv),
-                                        ll_sp_value(scp->cpu_nice,   scc->cpu_nice,   g_itv),
+                                        ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
+                                        ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
                                         ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
                                                     scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
                                                     g_itv),
                                         ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
-                                        ll_sp_value(scp->cpu_steal,  scc->cpu_steal,  g_itv),
+                                        ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
                                         scc->cpu_idle < scp->cpu_idle ?
                                         0.0 :
-                                        ll_sp_value(scp->cpu_idle,   scc->cpu_idle,   g_itv));
+                                        ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
                        }
                        else if (DISPLAY_CPU_ALL(a->opt_flags)) {
                                xprintf0(tab, "{\"cpu\": \"%s\", "
@@ -233,22 +235,27 @@ __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
                                         "\"irq\": %.2f, "
                                         "\"soft\": %.2f, "
                                         "\"guest\": %.2f, "
+                                        "\"gnice\": %.2f, "
                                         "\"idle\": %.2f}",
                                         cpuno,
                                         (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,     g_itv),
-                                        ll_sp_value(scp->cpu_nice,    scc->cpu_nice,    g_itv),
-                                        ll_sp_value(scp->cpu_sys,     scc->cpu_sys,     g_itv),
-                                        ll_sp_value(scp->cpu_iowait,  scc->cpu_iowait,  g_itv),
-                                        ll_sp_value(scp->cpu_steal,   scc->cpu_steal,   g_itv),
+                                                    scc->cpu_user - scc->cpu_guest, g_itv),
+                                        (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, g_itv),
+                                        ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
+                                        ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
+                                        ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
                                         ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
                                         ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
-                                        ll_sp_value(scp->cpu_guest,   scc->cpu_guest,   g_itv),
+                                        ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
+                                        ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
                                         scc->cpu_idle < scp->cpu_idle ?
                                         0.0 :
-                                        ll_sp_value(scp->cpu_idle,   scc->cpu_idle,   g_itv));
+                                        ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
                        }
                }
        }
index 0639ff9465bf52ab263c34e70a8bed7237965378..81a4dd7bf70dbd98f936403c13b985ad26353a33 100644 (file)
@@ -1,4 +1,4 @@
-.TH SAR 1 "JULY 2012" Linux "Linux User's Manual" -*- nroff -*-
+.TH SAR 1 "SEPTEMBER 2012" Linux "Linux User's Manual" -*- nroff -*-
 .SH NAME
 sar \- Collect, report, or save system activity information.
 .SH SYNOPSIS
@@ -1902,6 +1902,11 @@ Percentage of time spent by the CPU or CPUs to service software interrupts.
 Percentage of time spent by the CPU or CPUs to run a virtual processor.
 .RE
 
+.B %gnice
+.RS
+Percentage of time spent by the CPU or CPUs to run a niced guest.
+.RE
+
 .B %idle
 .RS
 Percentage of time that the CPU or CPUs were idle and the system
index b3415e623f9c404964b9871fa736267bbeb9c6b1..02a3b7d984c8362c7e16cb0b24489e04b25eff64 100644 (file)
@@ -69,7 +69,7 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                else if (DISPLAY_CPU_ALL(a->opt_flags)) {
                        printf("\n%-11s     CPU      %%usr     %%nice      %%sys"
                               "   %%iowait    %%steal      %%irq     %%soft"
-                              "    %%guest     %%idle\n",
+                              "    %%guest    %%gnice     %%idle\n",
                               timestamp[!curr]);
                }
        }
@@ -109,7 +109,8 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                                /*
                                 * If the CPU is offline then it is omited from /proc/stat:
                                 * All the fields couldn't have been read and the sum of them 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 +
@@ -121,13 +122,18 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                                         */
                                        *scc = *scp;
                                        
+                                       /* %user, %nice, %system, %iowait, %steal, ..., %idle */
                                        printf("    %6.2f    %6.2f    %6.2f"
                                               "    %6.2f    %6.2f    %6.2f",
                                               0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                                        
                                        if (DISPLAY_CPU_ALL(a->opt_flags)) {
-                                               printf("    %6.2f    %6.2f    %6.2f",
-                                                      0.0, 0.0, 0.0);
+                                               /*
+                                                * Four additional fields to display:
+                                                * %irq, %soft, %guest, %gnice.
+                                                */
+                                               printf("    %6.2f    %6.2f    %6.2f    %6.2f",
+                                                      0.0, 0.0, 0.0, 0.0);
                                        }
                                        printf("\n");
                                        continue;
@@ -140,6 +146,7 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                                        /*
                                         * If the CPU is tickless then there is no change in CPU values
                                         * but the sum of values is not zero.
+                                        * %user, %nice, %system, %iowait, %steal, ..., %idle
                                         */
                                        printf("    %6.2f    %6.2f    %6.2f"
                                               "    %6.2f    %6.2f",
@@ -148,6 +155,10 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                                        if (DISPLAY_CPU_DEF(a->opt_flags)) {
                                                printf("    %6.2f\n", 100.0);
                                        }
+                                       /*
+                                        * Four additional fields to display:
+                                        * %irq, %soft, %guest, %gnice.
+                                        */
                                        else if (DISPLAY_CPU_ALL(a->opt_flags)) {
                                                printf("    %6.2f    %6.2f    %6.2f    %6.2f\n",
                                                       0.0, 0.0, 0.0, 100.0);
@@ -158,34 +169,38 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                        
                        if (DISPLAY_CPU_DEF(a->opt_flags)) {
                                printf("    %6.2f    %6.2f    %6.2f    %6.2f    %6.2f    %6.2f\n",
-                                      ll_sp_value(scp->cpu_user,   scc->cpu_user,   g_itv),
-                                      ll_sp_value(scp->cpu_nice,   scc->cpu_nice,   g_itv),
+                                      ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
+                                      ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
                                       ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
                                                   scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
                                                   g_itv),
                                       ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
-                                      ll_sp_value(scp->cpu_steal,  scc->cpu_steal,  g_itv),
+                                      ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
                                       scc->cpu_idle < scp->cpu_idle ?
                                       0.0 :
-                                      ll_sp_value(scp->cpu_idle,   scc->cpu_idle,   g_itv));
+                                      ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
                        }
                        else if (DISPLAY_CPU_ALL(a->opt_flags)) {
                                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,     g_itv),
-                                      ll_sp_value(scp->cpu_nice,    scc->cpu_nice,    g_itv),
-                                      ll_sp_value(scp->cpu_sys,     scc->cpu_sys,     g_itv),
-                                      ll_sp_value(scp->cpu_iowait,  scc->cpu_iowait,  g_itv),
-                                      ll_sp_value(scp->cpu_steal,   scc->cpu_steal,   g_itv),
+                                                  scc->cpu_user - scc->cpu_guest, g_itv),
+                                      (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, g_itv),
+                                      ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
+                                      ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
+                                      ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
                                       ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
                                       ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
-                                      ll_sp_value(scp->cpu_guest,   scc->cpu_guest,   g_itv),
+                                      ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
+                                      ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
                                       scc->cpu_idle < scp->cpu_idle ?
                                       0.0 :
-                                      ll_sp_value(scp->cpu_idle,    scc->cpu_idle,    g_itv));
+                                      ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
                        }
                }
        }
index 1a07d7c58e290770bf75d1b0b0231c12ba8fa9c0..d43688d9bf4eb9c0bd89bfec7348dde4d4f2a361 100644 (file)
@@ -84,7 +84,7 @@ void read_stat_cpu(struct stats_cpu *st_cpu, int nbr,
                         * (user, nice, etc.) among all proc. CPU usage is not reduced
                         * to one processor to avoid rounding problems.
                         */
-                       sscanf(line + 5, "%llu %llu %llu %llu %llu %llu %llu %llu %llu",
+                       sscanf(line + 5, "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
                               &st_cpu->cpu_user,
                               &st_cpu->cpu_nice,
                               &st_cpu->cpu_sys,
@@ -93,14 +93,16 @@ void read_stat_cpu(struct stats_cpu *st_cpu, int nbr,
                               &st_cpu->cpu_hardirq,
                               &st_cpu->cpu_softirq,
                               &st_cpu->cpu_steal,
-                              &st_cpu->cpu_guest);
+                              &st_cpu->cpu_guest,
+                              &st_cpu->cpu_guest_nice);
 
                        /*
                         * Compute the uptime of the system in jiffies (1/100ths of a second
                         * if HZ=100).
                         * Machine uptime is multiplied by the number of processors here.
                         *
-                        * NB: Don't add cpu_guest because cpu_user already includes it.
+                        * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
+                        * already include them.
                         */
                        *uptime = st_cpu->cpu_user + st_cpu->cpu_nice    +
                                st_cpu->cpu_sys    + st_cpu->cpu_idle    +
@@ -117,7 +119,7 @@ void read_stat_cpu(struct stats_cpu *st_cpu, int nbr,
                                 * (user, nice, etc) for current proc.
                                 * This is done only on SMP machines.
                                 */
-                               sscanf(line + 3, "%d %llu %llu %llu %llu %llu %llu %llu %llu %llu",
+                               sscanf(line + 3, "%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
                                       &proc_nb,
                                       &sc.cpu_user,
                                       &sc.cpu_nice,
@@ -127,7 +129,8 @@ void read_stat_cpu(struct stats_cpu *st_cpu, int nbr,
                                       &sc.cpu_hardirq,
                                       &sc.cpu_softirq,
                                       &sc.cpu_steal,
-                                      &sc.cpu_guest);
+                                      &sc.cpu_guest,
+                                      &sc.cpu_guest_nice);
 
                                if (proc_nb < (nbr - 1)) {
                                        st_cpu_i = st_cpu + proc_nb + 1;
@@ -143,8 +146,8 @@ void read_stat_cpu(struct stats_cpu *st_cpu, int nbr,
                                         * Compute uptime reduced to one proc using proc#0.
                                         * Done if /proc/uptime was unavailable.
                                         *
-                                        * NB: Don't add cpu_guest because cpu_user already
-                                        * includes it.
+                                        * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
+                                        * already include them.
                                         */
                                        *uptime0 = sc.cpu_user + sc.cpu_nice  +
                                                sc.cpu_sys     + sc.cpu_idle  +
index defe91ca92dd8b6193fe331d754b36e849cb3ef4..13c9078325df6be962f6db20a668eedd1233b0b5 100644 (file)
  * Following structures are for each individual CPU (0, 1, etc.)
  */
 struct stats_cpu {
-       unsigned long long cpu_user     __attribute__ ((aligned (16)));
-       unsigned long long cpu_nice     __attribute__ ((aligned (16)));
-       unsigned long long cpu_sys      __attribute__ ((aligned (16)));
-       unsigned long long cpu_idle     __attribute__ ((aligned (16)));
-       unsigned long long cpu_iowait   __attribute__ ((aligned (16)));
-       unsigned long long cpu_steal    __attribute__ ((aligned (16)));
-       unsigned long long cpu_hardirq  __attribute__ ((aligned (16)));
-       unsigned long long cpu_softirq  __attribute__ ((aligned (16)));
-       unsigned long long cpu_guest    __attribute__ ((aligned (16)));
+       unsigned long long cpu_user             __attribute__ ((aligned (16)));
+       unsigned long long cpu_nice             __attribute__ ((aligned (16)));
+       unsigned long long cpu_sys              __attribute__ ((aligned (16)));
+       unsigned long long cpu_idle             __attribute__ ((aligned (16)));
+       unsigned long long cpu_iowait           __attribute__ ((aligned (16)));
+       unsigned long long cpu_steal            __attribute__ ((aligned (16)));
+       unsigned long long cpu_hardirq          __attribute__ ((aligned (16)));
+       unsigned long long cpu_softirq          __attribute__ ((aligned (16)));
+       unsigned long long cpu_guest            __attribute__ ((aligned (16)));
+       unsigned long long cpu_guest_nice       __attribute__ ((aligned (16)));
 };
 
 #define STATS_CPU_SIZE (sizeof(struct stats_cpu))
index a8865527e6d4c201984be89e265734bea5983fbe..46ba97f4dc3470c9afa128007e26ede050feb7e1 100644 (file)
@@ -204,11 +204,24 @@ __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
                                               NULL);
                                }
                                
-                               render(isdb, pre, PT_NOFLAG,
-                                      "all\t%%nice", NULL, NULL,
-                                      NOVAL,
-                                      ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
-                                      NULL);
+                               if (DISPLAY_CPU_DEF(a->opt_flags)) {
+                                       render(isdb, pre, PT_NOFLAG,
+                                              "all\t%%nice", NULL, NULL,
+                                              NOVAL,
+                                              ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
+                                              NULL);
+                               }
+                               else if (DISPLAY_CPU_ALL(a->opt_flags)) {
+                                       render(isdb, pre, PT_NOFLAG,
+                                              "all\t%%nice", NULL, NULL,
+                                              NOVAL,
+                                              (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,
+                                                          g_itv),
+                                              NULL);
+                               }                               
 
                                if (DISPLAY_CPU_DEF(a->opt_flags)) {
                                        render(isdb, pre, PT_NOFLAG,
@@ -257,6 +270,12 @@ __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
                                               NOVAL,
                                               ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
                                               NULL);
+
+                                       render(isdb, pre, PT_NOFLAG,
+                                              "all\t%%gnice", NULL, NULL,
+                                              NOVAL,
+                                              ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
+                                              NULL);
                                }
 
                                render(isdb, pre, pt_newlin,
@@ -271,7 +290,8 @@ __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
                                /*
                                 * If the CPU is offline then it is omited from /proc/stat:
                                 * All the fields couldn't have been read and the sum of them 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 +
@@ -318,13 +338,26 @@ __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
                                               NULL);
                                }
                                
-                               render(isdb, pre, PT_NOFLAG,
-                                      "cpu%d\t%%nice", NULL, cons(iv, i - 1, NOVAL),
-                                      NOVAL,
-                                      !g_itv ?
-                                      0.0 :
-                                      ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
-                                      NULL);
+                               if (DISPLAY_CPU_DEF(a->opt_flags)) {
+                                       render(isdb, pre, PT_NOFLAG,
+                                              "cpu%d\t%%nice", NULL, cons(iv, i - 1, NOVAL),
+                                              NOVAL,
+                                              !g_itv ?
+                                              0.0 :
+                                              ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
+                                              NULL);
+                               }
+                               else if (DISPLAY_CPU_ALL(a->opt_flags)) {
+                                       render(isdb, pre, PT_NOFLAG,
+                                              "cpu%d\t%%nice", NULL, cons(iv, i - 1, NOVAL),
+                                              NOVAL,
+                                              (!g_itv ||
+                                              ((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, g_itv),
+                                              NULL);
+                               }
 
                                if (DISPLAY_CPU_DEF(a->opt_flags)) {
                                        render(isdb, pre, PT_NOFLAG,
@@ -387,6 +420,14 @@ __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
                                               0.0 :
                                               ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
                                               NULL);
+
+                                       render(isdb, pre, PT_NOFLAG,
+                                              "cpu%d\t%%gnice", NULL, cons(iv, i - 1, NOVAL),
+                                              NOVAL,
+                                              !g_itv ?
+                                              0.0 :
+                                              ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
+                                              NULL);
                                }
                                
                                if (!g_itv) {
diff --git a/sadf.h b/sadf.h
index c25a1467ff04f305b3422ec651ab804084bceee2..451a96ee8e0f83fe04ced9b6eb1711d95763b42c 100644 (file)
--- a/sadf.h
+++ b/sadf.h
@@ -9,7 +9,7 @@
 #include "sa.h"
 
 /* DTD version for XML output */
-#define XML_DTD_VERSION        "2.13"
+#define XML_DTD_VERSION        "2.14"
 
 /* Possible actions for functions used to display reports */
 #define F_BEGIN        0x01
index 05182d6922549c3fbb6ea17b25e07cce9a57c045..8215451e1466eaaccac94e2f601a915417712186 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--DTD v2.13 for sysstat. See sadf.h -->
+<!--DTD v2.14 for sysstat. See sadf.h -->
 
 <!ELEMENT sysstat (sysdata-version, host)>
 
@@ -78,6 +78,7 @@
        irq CDATA #REQUIRED
        soft CDATA #REQUIRED
        guest CDATA #REQUIRED
+       gnice CDATA #REQUIRED
        idle CDATA #REQUIRED
 >
 
index f885e51f2c93685fa073c84356740e785d4b84d5..c6edd7f6031c01ffc74e29b23763a99b36bce529 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://pagesperso-orange.fr/sebastien.godard/sysstat" targetNamespace="http://pagesperso-orange.fr/sebastien.godard/sysstat" elementFormDefault="qualified">
 <xs:annotation>
-       <xs:appinfo>-- XML Schema v2.13 for sysstat. See sadf.h --</xs:appinfo>
+       <xs:appinfo>-- XML Schema v2.14 for sysstat. See sadf.h --</xs:appinfo>
 </xs:annotation>
 
 <xs:element name="sysstat" type="sysstat-type"></xs:element>
        <xs:attribute name="irq" type="hundredth-type"></xs:attribute>
        <xs:attribute name="soft" type="hundredth-type"></xs:attribute>
        <xs:attribute name="guest" type="hundredth-type"></xs:attribute>
+       <xs:attribute name="gnice" type="hundredth-type"></xs:attribute>
        <xs:attribute name="idle" type="hundredth-type"></xs:attribute>
 </xs:complexType>
 
index 92e06a3e250f386906ed0ac582db194849fd1da6..b8fb2ab91fbcfff30d42e3fad8f077a02434e026 100644 (file)
@@ -138,10 +138,11 @@ __print_funct_t xml_print_cpu_stats(struct activity *a, int curr, int tab,
                                /*
                                 * If the CPU is offline then it is omited from /proc/stat:
                                 * All the fields couldn't have been read and the sum of them 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 +
+                               if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
+                                    scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
                                     scc->cpu_hardirq + scc->cpu_softirq) == 0) {
                                        /*
                                         * Set current struct fields (which have been set to zero)
@@ -185,9 +186,10 @@ __print_funct_t xml_print_cpu_stats(struct activity *a, int curr, int tab,
                                                        "irq=\"%.2f\" "
                                                        "soft=\"%.2f\" "
                                                        "guest=\"%.2f\" "
+                                                       "gnice=\"%.2f\" "
                                                        "idle=\"%.2f\"/>",
                                                        i - 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,
                                                        cpu_offline ? 0.0 : 100.0);
                                        }
                                        continue;
@@ -224,22 +226,27 @@ __print_funct_t xml_print_cpu_stats(struct activity *a, int curr, int tab,
                                        "irq=\"%.2f\" "
                                        "soft=\"%.2f\" "
                                        "guest=\"%.2f\" "
+                                       "gnice=\"%.2f\" "
                                        "idle=\"%.2f\"/>",
                                        cpuno,
                                        (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,     g_itv),
-                                       ll_sp_value(scp->cpu_nice,    scc->cpu_nice,    g_itv),
-                                       ll_sp_value(scp->cpu_sys,     scc->cpu_sys,     g_itv),
-                                       ll_sp_value(scp->cpu_iowait,  scc->cpu_iowait,  g_itv),
-                                       ll_sp_value(scp->cpu_steal,   scc->cpu_steal,   g_itv),
+                                                   scc->cpu_user - scc->cpu_guest, g_itv),
+                                       (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, g_itv),
+                                       ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
+                                       ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
+                                       ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
                                        ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
                                        ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
-                                       ll_sp_value(scp->cpu_guest,   scc->cpu_guest,   g_itv),
+                                       ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
+                                       ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
                                        scc->cpu_idle < scp->cpu_idle ?
                                        0.0 :
-                                       ll_sp_value(scp->cpu_idle,   scc->cpu_idle,   g_itv));
+                                       ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
                        }
                }
        }
index aa435aebe1c5eea07a31aa5a27726ef0b2f8f945..30098608f6f70e421f3106e7b18b9447b4715b5b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * xml_stats.h: Include file used to display system statistics in XML.
- * (C) 1999-2011 by Sebastien Godard (sysstat <at> orange.fr)
+ * (C) 1999-2012 by Sebastien Godard (sysstat <at> orange.fr)
  */
 
 #ifndef _XML_STATS_H