Multiple CPU Testing

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

RedHat should offer mpstat utility as well. Do you have it?

Regards
Alex
scott.carroll@brulant.com
Posts: 29
Joined: Fri Dec 29, 2006 10:17 am

Post by scott.carroll@brulant.com »

Good point. Sorry, you said that earlier and it wasn't installed so I went with top. I installed mpstat and here is what I came up with:

mpstat -P '1' 1 1 | grep -v Average | grep -v % | grep -v Linux | grep M | awk '{ if ($10>=10) {printf("ScriptRes:Ok:%d \n",100-$10)} else {printf("ScriptRes:Bad:%d \n",100-$10)} }'

The '1' is the passed parameter (CPU #) and it appears to be working, but I just wanta to make sure that I am passing the parameter in properly.

If I enter 0 as the paramter, will the '1' be replaced with 0?

Thanks.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

I would recommend you to install mpstat utility onto your linux server. This utility is included into sysstat package, so you may find appropriate rpm file (e.g sysstat-5.0.5-1.i386.rpm) and install it onto your system.

With mpstat utility installed, you may use following Shell Script:
Params: <ProcessorNumber> <MaxLimit>
Start Cmd: %Script% %Params%
Script:

Code: Select all

#!/bin/sh 

mpstat -P $1 | awk 'BEGIN {idle=0} ($10!="%idle") {idle=$10}
END {if (idle>=100-"'$2'") {printf("ScriptRes:Ok:%d %%\n",100-idle)} else {printf("ScriptRes:Bad:%d %%\n",100-idle)} }'
Please note, script requires to parameters:
- ProcessorNumber - certain processor, you want to monitor: 0, 1, 2, ...
- MaxLimit: script sets "Bad" status when CPU usage by the process is
over specified limit (%)

You may specify these parametes into "Params" input box "Test Properties" window of appropriate test.

Regards,
Max
scott.carroll@brulant.com
Posts: 29
Joined: Fri Dec 29, 2006 10:17 am

Post by scott.carroll@brulant.com »

Thanks! I modified it a little based on what you just posted and have:

Params: <Processor #> <MaxLimit>
Start CMD: %Script% %Params%

Code:

#!/bin/sh

mpstat -P $1 1 1 | grep -v Average | grep -v % | grep -v Linux | grep M | awk '{ if ($10>=100-"'$2'") {printf("ScriptRes:Ok:%d \n",100-$10)} else {printf("ScriptRes:Bad:%d \n",100-$10)} }'

And it is chugging away and looks good!

Thanks for all your help!

P.S. All of the greps get rid of the "junk" (headers and average line before and after the CPU line I needed). Thanks again!
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

scott.carroll@brulant.com wrote:Thanks for all your help!
You are welcome.

Regards,
Max
Post Reply