Denis Cerkvin - 2013-04-15

Hi All,

Nigel, thank you very much for the great tool - NMon is really great, concise and effective tool. I loved it!

On Linux (3.8.6-203 kernel) with multiple cpus /cores, second number in /proc/uptime depends on the number of cpu units.

This causes nmon to show negative idle time and Average CPU use, when using "k" option.

This small patch fixes the issue.

=================================================
Sincerely,
Denis Cerkvin

The Bible for command line people.
http://www.read-and-think.org/kjv.html
=================================================

$ cat avg.cpu.use.correct.patch
-- lmon14g.c 2013-04-15 08:54:09.000000000 +1000
+++ lmon.c 2013-04-15 14:40:13.020624687 +1000
@@ -1535,7 +1535,8 @@
p->cpu_total.uptime=atof(proc.line);
for(i=0;i<strlen(proc.line);i++) {
if(proc.line_ == ' ') {
- p->cpu_total.idletime=atof(&proc.line);
+// Used to be p->cpu_total.idletime=atof(&proc.line);
+ p->cpu_total.idletime=atof(&proc.line)/cpus;
break;
}
}
@@ -4854,13 +4855,15 @@
(float)p->cpu_total.mins5,
updays, uphours, upmins);

- mvwprintw(padker,4, 1, "Interrupts     %8.1f   15 mins %5.2f    Average CPU use=%6.2f%%",
+ mvwprintw(padker,4, 1, "Interrupts     %8.1f   15 mins %5.2f    Average CPU use=%6.2f%% (%d CPUs)",
(float)(p->cpu_total.intr - q->cpu_total.intr)/elapsed,
(float)p->cpu_total.mins15,
(float)(
(p->cpu_total.uptime -
p->cpu_total.idletime)/
- p->cpu_total.uptime *100.0));
+ p->cpu_total.uptime *100.0),
+ cpus
+ );
DISPLAY(padker,5);
} else {
if(proc_first_time) {
$ _