- fix mpstat tool (when the cpu is switched off)

This commit is contained in:
Ivana Varekova 2010-04-19 09:12:40 +00:00
parent 9c3e1f0595
commit ca9eb93bc6
2 changed files with 39 additions and 10 deletions

View File

@ -1,16 +1,42 @@
diff -up sysstat-9.0.6.1/mpstat.c.pom sysstat-9.0.6.1/mpstat.c diff -up sysstat-9.0.6.1/mpstat.c.tl sysstat-9.0.6.1/mpstat.c
--- sysstat-9.0.6.1/mpstat.c.pom 2009-09-12 20:59:04.000000000 +0200 --- sysstat-9.0.6.1/mpstat.c.tl 2009-09-12 20:59:04.000000000 +0200
+++ sysstat-9.0.6.1/mpstat.c 2010-04-16 14:32:06.000000000 +0200 +++ sysstat-9.0.6.1/mpstat.c 2010-04-19 10:42:01.000000000 +0200
@@ -273,9 +273,10 @@ void write_stats_core(int prev, int curr @@ -272,10 +272,21 @@ void write_stats_core(int prev, int curr
/* Recalculate itv for current proc */
pc_itv = get_per_cpu_interval(scc, scp); pc_itv = get_per_cpu_interval(scc, scp);
if (!pc_itv) { - if (!pc_itv) {
- /* Current CPU is offline */ - /* Current CPU is offline */
+ /* Current CPU is tickless + /* if the CPU is offline it is omited from /proc/stat
+ if the CPU is offline it is omited from /proc/stat */ + so the sum of all values is zero */
+ 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) {
printf(" 0.00 0.00 0.00 0.00 0.00 0.00" printf(" 0.00 0.00 0.00 0.00 0.00 0.00"
- " 0.00 0.00 0.00\n"); " 0.00 0.00 0.00\n");
+ " 0.00 0.00 100.00\n"); + continue;
+ }
+
+ /* if the CPU is tickless then
+ there is no change in CPU values but the sum of values is not null */
+ if (!pc_itv) {
+ printf(" 0.00 0.00 0.00 0.00 0.00 0.00"
+ " 0.00 0.00 100.00\n");
} }
else { else {
printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f" printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f"
@@ -643,6 +654,14 @@ void rw_mpstat_loop(int dis_hdr, int row
scc = st_cpu[curr] + cpu;
scp = st_cpu[!curr] + cpu;
*scc = *scp;
+ scc->cpu_user = 0;
+ scc->cpu_nice = 0;
+ scc->cpu_sys = 0;
+ scc->cpu_iowait = 0;
+ scc->cpu_idle = 0;
+ scc->cpu_steal = 0;
+ scc->cpu_hardirq = 0;
+ scc->cpu_softirq = 0;
}
/* Get time */

View File

@ -1,6 +1,6 @@
Name: sysstat Name: sysstat
Version: 9.0.6.1 Version: 9.0.6.1
Release: 2%{?dist} Release: 3%{?dist}
Summary: The sar and iostat system monitoring commands Summary: The sar and iostat system monitoring commands
License: GPLv2+ License: GPLv2+
Group: Applications/System Group: Applications/System
@ -83,6 +83,9 @@ rm -rf %{buildroot}
%{_localstatedir}/log/sa %{_localstatedir}/log/sa
%changelog %changelog
* Mon Apr 19 2010 Ivana Hutarova Varekova <varekova@redhat.com> - 9.0.6.1-3
- fix mpstat tool (when the cpu is switched off)
* Fri Apr 16 2010 Ivana Hutarova Varekova <varekova@redhat.com> - 9.0.6.1-2 * Fri Apr 16 2010 Ivana Hutarova Varekova <varekova@redhat.com> - 9.0.6.1-2
- fix the mpstat output on tickless kernel - fix the mpstat output on tickless kernel