KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Dominant Process check in Linux

 
Post new topic   Reply to topic    KS-Soft Forum Index -> RMA for UNIX
View previous topic :: View next topic  
Author Message
oakyuz



Joined: 08 Feb 2007
Posts: 64

PostPosted: Sun Feb 24, 2013 5:09 am    Post subject: Dominant Process check in Linux Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12326
Location: USA

PostPosted: Mon Feb 25, 2013 12:59 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
oakyuz



Joined: 08 Feb 2007
Posts: 64

PostPosted: Tue Feb 26, 2013 1:16 am    Post subject: Reply with quote

Hi Alex

These scripts meet my need. Thank you very much for quick and problem-solving assistance.

Regards,
Oguzhan
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12326
Location: USA

PostPosted: Tue Feb 26, 2013 8:01 am    Post subject: Reply with quote

You are welcome

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> RMA for UNIX All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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

KS-Soft Forum Index