|
View previous topic :: View next topic |
Author |
Message |
oakyuz
Joined: 08 Feb 2007 Posts: 74
|
Posted: Sun Feb 24, 2013 5:09 am Post subject: Dominant Process check in Linux |
|
|
Hi
We are using Host Monitor v9.40 on Windows 2008 R2 (x64).
I would like to define Dominant Process tests for my Linux systems. As you know, this test is implemented for Windows systems currently in HM, probably leaving this kind of things to users who are able to write shell scripts in Linux. Is there anybody who has and can share scripts which can check Dominant Process::CPU and Dominant Process::Memory in Linux systems?
Thanks. |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12806 Location: USA
|
Posted: Mon Feb 25, 2013 12:59 pm Post subject: |
|
|
Dominant Process::CPU
Code: |
#!/bin/sh
if [ $# -ge 2 ]
then
OS=`uname`
case $OS in
AIX) PSLIST='ps -Ao comm,pcpu';;
Linux) PSLIST='ps h -eo ucmd,pcpu';;
FreeBSD) PSLIST='ps -axco command,%cpu';;
NetBSD) PSLIST='ps -axco command,%cpu';;
OpenBSD) PSLIST='ps -axco command,%cpu';;
SunOS) PSLIST='ps -eo fname,pcpu';;
*) echo 'ScriptRes:Unknown:script is not designed for '$OS
exit;;
esac
$PSLIST | awk 'BEGIN { maxusage=0; prog="" } {if ($2>maxusage) {maxusage=$2; prog=$1 }} \
END { if (maxusage<='$1') {printf("ScriptRes:Ok:%2.2f:%s %%\n",maxusage,prog)} else {printf("ScriptRes:Bad:%2.2f:%s %%\n",maxusage,prog)} }'
else
echo "ScriptRes:Unknown:not enough parameters specified"
fi
|
Dominant Process::Memory
Code: |
#!/bin/sh
if [ $# -ge 2 ]
then
OS=`uname`
case $OS in
AIX) PSLIST='ps -Ao comm,pmem';;
Linux) PSLIST='ps h -eo ucmd,pmem';;
FreeBSD) PSLIST='ps -axco command,%mem';;
NetBSD) PSLIST='ps -axco command,%mem';;
OpenBSD) PSLIST='ps -axco command,%mem';;
SunOS) PSLIST='ps -eo fname,pmem';;
*) echo 'ScriptRes:Unknown:script is not designed for '$OS
exit;;
esac
$PSLIST | awk 'BEGIN { maxusage=0; prog="" } {if ($2>maxusage) {maxusage=$2; prog=$1 }} \
END { if (maxusage<='$1') {printf("ScriptRes:Ok:%2.2f:%s %%\n",maxusage,prog)} else {printf("ScriptRes:Bad:%2.2f:%s %%\n",maxusage,prog)} }'
else
echo "ScriptRes:Unknown:not enough parameters specified"
fi
|
Regards
Alex |
|
Back to top |
|
|
oakyuz
Joined: 08 Feb 2007 Posts: 74
|
Posted: Tue Feb 26, 2013 1:16 am Post subject: |
|
|
Hi Alex
These scripts meet my need. Thank you very much for quick and problem-solving assistance.
Regards,
Oguzhan |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12806 Location: USA
|
Posted: Tue Feb 26, 2013 8:01 am Post subject: |
|
|
You are welcome
Regards
Alex |
|
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
|