Page 1 of 1
CPU Usage in Linux RMA
Posted: Fri Apr 01, 2005 5:47 pm
by Malevo
Hi, I Installed the RMA for linux 1.0 and I'm getting 254% cpu usage ? is this correct ? is this a bug ?
How can I get a number from 0 to 100 % ? does this include the system CPU or just the User CPU ?
Thanks, Pablo
Posted: Fri Apr 01, 2005 6:55 pm
by KS-Soft
CPU Usage on UNIX systems are checked by simple shell script "cpu.sh" that is located in RMA's directory.
This script was tested on Linux Mandrake 8 and 9, Solaris 9, FreeBSD 4.5 and 5.2 But it may not work correctly on some other versions.
cpu.sh script uses standard vmstat utility to retrieve necessary information. Please check manual for vmstat utility that is installed on your system and modify script accordingly
Regards
Alex
Posted: Mon Feb 26, 2007 8:01 am
by RicochetPeter
Hi,
sorry for *bumping* this rather old thread. I'm having an issue with checking CPU load on a linux machine.
The check currently shows up in the HostMon console with a value of >14, whereas when I run the vmstat code in cpu.sh manually on the machine, it returns something like 2 or 3.
The disk space checks run OK, so do you have any ideas, why the return of this check is b0rked?
Posted: Mon Feb 26, 2007 8:19 am
by KS-Soft Europe
RicochetPeter wrote:The check currently shows up in the HostMon console with a value of >14, whereas when I run the vmstat code in cpu.sh manually on the machine, it returns something like 2 or 3.
What exact linux do you use? What output do you get using 'uname' utility?
Have you tried to refresh "SPU usage test"? If you have installed mpstat utility on your system, you may try to change linux related string in cpu.sh with the following string:
Code: Select all
Linux) mpstat -P ALL | tail -1 | awk '{print 100-$(NF-1)}';;
Regards,
Max
Posted: Mon Feb 26, 2007 8:28 am
by RicochetPeter
KS-Soft Europe wrote:What exact linux do you use?
Ubuntu 6.06 x86 here
What output do you get using 'uname' utility?
Code: Select all
root@leia:/usr/local/hostmon# uname -a
Linux leia 2.6.15-26-server #1 SMP Fri Sep 8 21:00:37 UTC 2006 i686 GNU/Linux
Have you tried to refresh "SPU usage test"?
Yes, I manually refreshed the test, too.
If you have installed mpstat utility on your system, you may try to change linux related string in cpu.sh with the following string:
Code: Select all
Linux) mpstat -P ALL | tail -1 | awk '{print 100-$(NF-1)}';;
Did that, same effect: running the script on the agent machine returns "1.56", f.e., but hostmon shows 9, or 10.
Posted: Mon Feb 26, 2007 8:31 am
by RicochetPeter
by the way, using
Code: Select all
Linux) mpstat -P ALL | grep all | awk '{print 100-$(NF-1)}';;
instead of
Code: Select all
Linux) mpstat -P ALL | tail -1 | awk '{print 100-$(NF-1)}';;
makes more sense, if you ask me...
Posted: Mon Feb 26, 2007 10:20 am
by KS-Soft Europe
RicochetPeter wrote:Did that, same effect: running the script on the agent machine returns "1.56", f.e., but hostmon shows 9, or 10.
Sorry, I cannot see any reason why it shows such difference. Probably, you have to recompile the agent on your system. Please send request to support@ks-soft.net and we will send you the source codes.
RicochetPeter wrote:Linux) mpstat -P ALL | grep all | awk '{print 100-$(NF-1)}';;
Linux) mpstat -P ALL | tail -1 | awk '{print 100-$(NF-1)}';;
Actually, both these commands are equivalent and correct. You may use both of them.
Regards,
Max
Posted: Mon Feb 26, 2007 10:36 am
by RicochetPeter
KS-Soft Europe wrote:RicochetPeter wrote:Did that, same effect: running the script on the agent machine returns "1.56", f.e., but hostmon shows 9, or 10.
Sorry, I cannot see any reason why it shows such difference. Probably, you have to recompile the agent on your system. Please send request to support@ks-soft.net and we will send you the source codes.
Thanks.
RicochetPeter wrote:Linux) mpstat -P ALL | grep all | awk '{print 100-$(NF-1)}';;
Linux) mpstat -P ALL | tail -1 | awk '{print 100-$(NF-1)}';;
Actually, both these commands are equivalent and correct. You may use both of them.
Regards,
Max
I don't think so. In a multi-CPU machine, the version with "grep" shows the mpstat summary for all CPUs, the version with "tail" shows the last CPU...
Posted: Mon Feb 26, 2007 10:50 am
by KS-Soft Europe
RicochetPeter wrote: I don't think so. In a multi-CPU machine, the version with "grep" shows the mpstat summary for all CPUs, the version with "tail" shows the last CPU...
In general, the syntax you offered is more correct. However, I have the following output on the multi-proc system:
Code: Select all
mpstat -P ALL
Linux XXXXX. (xxx.xxx.xxxx) 02/26/2007
22:05:51 CPU %user %nice %system %iowait %irq %soft %idle intr/s
22:05:51 all 12,08 0,00 1,46 4,57 0,20 0,08 81,61 825,25
22:05:51 0 12,19 0,00 1,56 4,84 0,05 0,24 81,12 314,30
22:05:51 1 12,75 0,00 1,46 4,30 1,37 0,06 80,06 381,88
.....
22:05:51 7 11,86 0,00 1,41 4,44 0,00 0,06 82,22 12,64
And the following output on the single proc machine:
Code: Select all
mpstat -P ALL
Linux XXXXXX (XXXX.XXXX.XXXX) 02/26/2007
06:49:05 PM CPU %user %nice %system %iowait %irq %soft %idle intr/s
06:49:05 PM all 11.92 0.00 6.85 16.08 0.16 0.03 64.97 1034.89
06:49:05 PM 0 11.92 0.00 6.85 16.08 0.16 0.03 64.97 1034.82
In both cases, mpstat -P ALL | tail -1 gets the correct line. Another thing is that "grep all" will not work on localized systems, where second string does not contain "all" word, but contains some localized characters.
Regards,
Max
Posted: Mon Feb 26, 2007 11:01 am
by RicochetPeter
KS-Soft Europe wrote:
In both cases, mpstat -P ALL | tail -1 gets the correct line.
Sorry, it will only get the value for the last CPU, as far as I understand the "tail" programme. If that's intended, like in a single CPU machine, it's OK, but surely not in a multi-CPU machine.
Another thing is that "grep all" will not work on localized systems, where second string does not contain "all" word, but contains some localized characters.
Argh, that's correct, I haven't thought of that.
Posted: Mon Feb 26, 2007 11:22 am
by KS-Soft Europe
RicochetPeter wrote:Sorry, it will only get the value for the last CPU, as far as I understand the "tail" programme. If that's intended, like in a single CPU machine, it's OK, but surely not in a multi-CPU machine.
Sorry, my fault. It really shows the last CPU on multi-CPU machine. You are right. So, you may use "grep all".
Regards,
Max
Posted: Thu Mar 22, 2007 6:11 pm
by invisik
Hi!
Having similar issues on SUSE Linux Enterprise Desktop 10 32-bit.
First, the sysstat package must be installed as it provides mpstat.
HostMonitor reports like 95% utilization on a mostly idle system.
I ran:
mpstat -P ALL | grep ALL | awk '{print 100-$(NF-1)}';
and the result is always 49.07, which also seems odd.
Here's some sample output:
mattj@linux-n1e2:~> mpstat -P ALL
Linux 2.6.16.27-0.9-smp (linux-n1e2) 03/22/2007
07:08:29 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
07:08:29 PM all 20.44 0.01 27.28 0.50 0.45 0.36 0.00 50.97 470.35
07:08:29 PM 0 16.42 0.01 17.63 0.90 0.90 0.72 0.00 63.42 470.34
07:08:29 PM 1 24.46 0.00 36.93 0.10 0.00 0.00 0.00 38.52 0.00
My machine is a Pentium D, so is a dual-core and it shows as 2 processors.
Any suggestions, please let me know! Will also test on SUSE Linux Enterprise Server 9 and 10 soon. Will be happy to share the results with the rest of the class.
Thanks.
-m
Posted: Fri Mar 23, 2007 2:19 am
by KS-Soft Europe
invisik wrote:First, the sysstat package must be installed as it provides mpstat.
Correct
invisik wrote:HostMonitor reports like 95% utilization on a mostly idle system.
Have you made changes in cpu.sh file? You should replace Linux related string using the following (please note: grep all in lowercase!):
Code: Select all
Linux) mpstat -P ALL | grep all | awk '{print 100-$(NF-1)}';;
invisik wrote:I ran:
mpstat -P ALL | grep ALL | awk '{print 100-$(NF-1)}';
and the result is always 49.07, which also seems odd.
According to the output of mpstat utility you mentioned, average Idle time on your machine is 50.97 So, utilized time calculated as 100-50.97 = 49.03
Looks like correct.
Regards,
Max