|
View previous topic :: View next topic |
Author |
Message |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Fri Jan 05, 2007 1:08 pm Post subject: |
|
|
RedHat should offer mpstat utility as well. Do you have it?
Regards
Alex |
|
Back to top |
|
|
scott.carroll@brulant.com
Joined: 29 Dec 2006 Posts: 29
|
Posted: Fri Jan 05, 2007 2:58 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Fri Jan 05, 2007 2:59 pm Post subject: |
|
|
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: | #!/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 |
|
Back to top |
|
|
scott.carroll@brulant.com
Joined: 29 Dec 2006 Posts: 29
|
Posted: Fri Jan 05, 2007 3:07 pm Post subject: |
|
|
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! |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Fri Jan 05, 2007 3:10 pm Post subject: |
|
|
scott.carroll@brulant.com wrote: | Thanks for all your help! |
You are welcome.
Regards,
Max |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|