From e18976f7b15eace357663a2a9a7b20b6b0de2f47 Mon Sep 17 00:00:00 2001 From: seb Date: Tue, 25 Sep 2012 14:40:18 +0200 Subject: [PATCH] Added support for nice guest mode to sar. 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. --- CHANGES | 3 +++ activity.c | 2 +- common.c | 24 ++++++++++++------ iostat.c | 7 +++--- json_stats.c | 33 ++++++++++++++---------- man/sar.in | 7 +++++- pr_stats.c | 47 ++++++++++++++++++++++------------ rd_stats.c | 17 +++++++------ rd_stats.h | 19 +++++++------- rndr_stats.c | 67 +++++++++++++++++++++++++++++++++++++++---------- sadf.h | 2 +- xml/sysstat.dtd | 3 ++- xml/sysstat.xsd | 3 ++- xml_stats.c | 29 +++++++++++++-------- xml_stats.h | 2 +- 15 files changed, 180 insertions(+), 85 deletions(-) diff --git a/CHANGES b/CHANGES index 2ac0bc0..76832af 100644 --- a/CHANGES +++ b/CHANGES @@ -1,10 +1,13 @@ 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). * [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 orange.fr) diff --git a/activity.c b/activity.c index c73bca3..65770d7 100644 --- a/activity.c +++ b/activity.c @@ -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, diff --git a/common.c b/common.c index 3b1dbbd..0a72ee1 100644 --- 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 + diff --git a/iostat.c b/iostat.c index deefa17..d9d2812 100644 --- 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 diff --git a/json_stats.c b/json_stats.c index 6fa0314..47360e6 100644 --- a/json_stats.c +++ b/json_stats.c @@ -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)); } } } diff --git a/man/sar.in b/man/sar.in index 0639ff9..81a4dd7 100644 --- a/man/sar.in +++ b/man/sar.in @@ -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 diff --git a/pr_stats.c b/pr_stats.c index b3415e6..02a3b7d 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -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)); } } } diff --git a/rd_stats.c b/rd_stats.c index 1a07d7c..d43688d 100644 --- a/rd_stats.c +++ b/rd_stats.c @@ -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 + diff --git a/rd_stats.h b/rd_stats.h index defe91c..13c9078 100644 --- a/rd_stats.h +++ b/rd_stats.h @@ -74,15 +74,16 @@ * 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)) diff --git a/rndr_stats.c b/rndr_stats.c index a886552..46ba97f 100644 --- a/rndr_stats.c +++ b/rndr_stats.c @@ -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 c25a146..451a96e 100644 --- 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 diff --git a/xml/sysstat.dtd b/xml/sysstat.dtd index 05182d6..8215451 100644 --- a/xml/sysstat.dtd +++ b/xml/sysstat.dtd @@ -1,5 +1,5 @@ - + @@ -78,6 +78,7 @@ irq CDATA #REQUIRED soft CDATA #REQUIRED guest CDATA #REQUIRED + gnice CDATA #REQUIRED idle CDATA #REQUIRED > diff --git a/xml/sysstat.xsd b/xml/sysstat.xsd index f885e51..c6edd7f 100644 --- a/xml/sysstat.xsd +++ b/xml/sysstat.xsd @@ -1,7 +1,7 @@ - -- XML Schema v2.13 for sysstat. See sadf.h -- + -- XML Schema v2.14 for sysstat. See sadf.h -- @@ -161,6 +161,7 @@ + diff --git a/xml_stats.c b/xml_stats.c index 92e06a3..b8fb2ab 100644 --- a/xml_stats.c +++ b/xml_stats.c @@ -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)); } } } diff --git a/xml_stats.h b/xml_stats.h index aa435ae..3009860 100644 --- a/xml_stats.h +++ b/xml_stats.h @@ -1,6 +1,6 @@ /* * xml_stats.h: Include file used to display system statistics in XML. - * (C) 1999-2011 by Sebastien Godard (sysstat orange.fr) + * (C) 1999-2012 by Sebastien Godard (sysstat orange.fr) */ #ifndef _XML_STATS_H -- 2.40.0