RedHat should offer mpstat utility as well. Do you have it?
Regards
Alex
Multiple CPU Testing
-
- Posts: 29
- Joined: Fri Dec 29, 2006 10:17 am
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.
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.
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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:
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
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)} }'
- 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
-
- Posts: 29
- Joined: Fri Dec 29, 2006 10:17 am
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!
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!
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact: