Operating System - HP-UX
1820553 Members
2339 Online
109626 Solutions
New Discussion юеВ

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

 
SOLVED
Go to solution
senthil_kumar_1
Super Advisor

CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi All,

We are uning Linux (Redhat and Suse) and HPUX (11.00 and 11.11).

Adventnet's monitoring tool "opsmanager" is being used to monitor the Linux and HPUX servers.

Actually we are getting lot of alert messages for more CPU and Memory utilization in almost all servers.

But we can find idle CPU - 90% thru "top" command manually.

Is there any command to find the total CPU utilization and Memory utilization for eahc platform Linux and HPUX?

How to find the Top 3 CPU and Memory Utilized process?

24 REPLIES 24
Ganesan R
Honored Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi,

>>Is there any command to find the total CPU utilization and Memory utilization for eahc platform Linux and HPUX?<<

many. top, sar, vmstat, glance, etc..

>>How to find the Top 3 CPU and Memory Utilized process?<<

ofcourse top command will provide the top resource consuming process. Glance is more sphosticated tool.
Best wishes,

Ganesh.
James R. Ferguson
Acclaimed Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi:

> How to find the Top 3 CPU and Memory Utilized process?

Instantly in a single interval or over some period of time?

One of the best tools for performance monitoring in HP-UX is 'glance'. If you don't have it, you should. A 30-day trial version can be obtained from the Application CDRoM.

Regards!

...JRF...
Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Shalom,

I would use this for memory processes:

http://www.hpux.ws/?p=8

I would then re-write it to get the top three cpu processes, which is pretty easy.

You say:
>>
Adventnet's monitoring tool "opsmanager" is being used to monitor the Linux and HPUX servers.
<<

My response is I can do it just as well with a shell script for less money.

Why are we mentioning this tool? I'm confused.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
senthil_kumar_1
Super Advisor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi All,


1) I need detailed notes for understanding the outputs of top, sar, vmstat, glance.


Hi Steven,

Do you have any sample script for total cpu, memory utilization and top 3 or 10 process based on memory and cpu utilization?.

Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Shalom,

You say, my comments inline:
1) I need detailed notes for understanding the outputs of top, sar, vmstat, glance.

top:
http://www.webmasterworld.com/forum40/1205.htm

http://www.teamquest.com/resources/gunther/display/5/

http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2006-08/msg00172.html

http://www.cyberciti.biz/tips/understanding-linux-and-unix-load-average.html

sar is more of an rtfm issue:
http://www.unix.com/hp-ux/42198-sar-output-gives-98-idle-cpu.html

http://www-d0.fnal.gov/computing/archive/unix_sys_diag.html

http://groups.google.com/group/comp.unix.solaris/browse_thread/thread/c9b7c62cc92c5fb8?pli=1

vmstat:
http://www.unix.com/unix-advanced-expert-users/30984-output-vmstat.html

http://www.remote-dba.net/t_tuning_vmstat_utility.htm

http://www.adminschoice.com/docs/iostat_vmstat_netstat.htm

I will skip glance because the man pages are written by HP and are excellent.


Hi Steven,

Do you have any sample script for total cpu, memory utilization and top 3 or 10 process based on memory and cpu utilization?.

This utility accepts command line input. If you tell it 3 or 10 as the first command line parameter that is how many processes it will monitor. It shows the top processes in terms of memory use.
http://www.hpux.ws/?p=8

As I said earlier, I am looking at writing one that does this based on top CPU users.

I'm looking at the code and seeing how easy or hard this is going to be to get done.

SEO
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

I'm not looking for any points here.

Here is the heart of the HP-UX code in the leak detector:

if [ -z "$FILTER" ]
then
CL="ps -ef -o pid,sz,vsz,args | sort -nr -k 2,3| head -$NUM"
else
CL="ps -a -o pid,sz,vsz,args -C $FILTER | sort -nr -k 2,3| head -$NUM"
fi
;;

It merely does a reverse sort largest to smallest on fields two and three.

To modify it to get the top CPU users, I would think we would need to add the right ps fields and sort by them.

It looks simple. I'm suddenly interested in this.

I would set up a new command line argument for the utility to permit a switch to determine the output.

The parameter we would want to use is pcpu

So I would say quick and dirty you can simply modify this utility to get you top cpu users.

I'm looking at posting an update that will make my handy dandy memory leak detector able to do what you wish it to do.

I'm actually starting up my HP-UX system in anticipation of testing this.

SEP

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Shalom again,

this part works:

ps -ef -o pid,sz,vsz,args,pcpu | sort -nr -k 5| head -n 3

The head statement gets you the top 3 after a sort

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
senthil_kumar_1
Super Advisor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi Steven,

I am using HPUX 10.20, 11.00 and 11.11.

that command is throwing error message.

Ex:

root@lgsna:/root > ps -ef -o pid,sz,vsz,args,pcpu | sort -nr -k 5| head -n 3
ps: illegal option -- o
usage: ps [-edaxzflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup] [-Z psetidlist]




Sivakumar MJ._1
Respected Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Senthil,

This link will help u ..

http://research.att.com/~gsf/man/man1/ps.html
Dennis Handly
Acclaimed Contributor
Solution

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

>that command is throwing error message.
> ps -ef -o pid,sz,vsz,args,pcpu

The proper way to use ps(1) is:
UNIX95=EXTENDED_PS ps -ef -o pid,sz,vsz,args,pcpu
Sharma Sanjeev
Respected Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi Senthil

It will help you

# UNIX95= ps -e -o "vsz pcpu ruser pid stime time state args" | sort -rn |head -3

regards
Sanjeev
Everything is Possible as " IMPOSSIBLE" word itself says I M POSSIBLE
James R. Ferguson
Acclaimed Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi Senthil:

Notice very carefully that there is no semicolon on the command line after "UNIX95=".

Writing :

# UNIX95= ps ...

(or as Dennis likes to do:

# UNIX95=EXTENDED_PS ps ...

sets the UNIX95 (XPG4) behavior _only_ for the duration of the commmand line. You do not want to capriciously set UNIX95 in your shell environment. WHen set, the behavior of various commands is subtly altered. With 'ps' the option is required to use a custom output format ( the '-o' arguments ).

Using 'UNIX95' as an lvalue (left of an equal sign) sets it regardless of whether or not anything follows the equal (assignment) sign. Its for this reason that Dennis prefers his notation --- clarity. You could do:

# UNIX95=1 ps ...

OR:

# UNIX95=0 ps ...

OR:

# UNIX95= ps ...

ALL three forms are equivalent so beware.

See the manpages for 'ps(1)' for more about the UNIX95 (XPG4) behavior; the '-o' option and others!

Regards!

...JRF...
Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

No points please.

Yes, my post requires UNIX95 be set, it was pulled from a script that uses UNIX95.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
senthil_kumar_1
Super Advisor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi All,

Thanks a lot.

Why we are using UNIX95.

Pls explain me.
Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Shalom,

The UNIX95 variable needs to be set in order for my ps command to work.

If UNIX95 is not set to 1 you don't get the process information my command requests.

Why? Really I never asked. I just took it for granted and did it. Maybe that says something about me.

http://groups.google.com/group/comp.os.linux/browse_thread/thread/ea49dc5b68670333/f0b5f70e6e7a758c

http://www.springerlink.com/content/h5933m7011504052/

You may have to do some reading.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi (again):

> SEP: The UNIX95 variable needs to be set in order for my ps command to work. If UNIX95 is not set to 1 you don't get the process information my command requests.

Wrong! You can set it to _ANY_ value, even to zero (0). Read again my post above of July 2. What matters is that UNIX95 is an lvalue.

> SEP: Why? Really I never asked. I just took it for granted and did it.

Empirical data is very enlightening. Heuristics help too.

> Senthil: Why we are using UNIX95.

The simple answer is that to use the '-o' format of the 'ps' option you need to set XPG4 (UNIX95) behavior. That's what the manpages would tell you!


...JRF...
Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Okay JRF,

The UNIX95 variable needs to be set in order for my ps command to work.

If its not set to something, the command will not work.

Please tell me if that statement requires parsing?

To summarize my statement. I never knew why I used UNIX95, except if I didn't set it, the utilities on my web site and the successors I'm developing for this thread WOULD NOT WORK.

>>>>
The simple answer is that to use the '-o' format of the 'ps' option you need to set XPG4 (UNIX95) behavior. That's what the manpages would tell you!
<<<

Thanks for the explanation and parsing.

Please do not assign any points to this answer.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Dennis Handly
Acclaimed Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Besides the variable UNIX95, there is also UNIX_STD. This can have some specific values for 11.31.
senthil_kumar_1
Super Advisor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi All,

Now i have found some commands to find the cpu and memory utilization.

1)Linux:

1.1)percentage of total cpu utilization:

# ps -eo user,pid,pcpu,comm | awk '{x += $3} END {print x}'
23.2

1.2)Top 3 CPU utilizing process:

# ps -eo user,pid,pcpu,comm | sort -nrbk3 | head -3
oracle 11730 21.5 oracle
oracle 12732 5.0 oracle
oracle 12670 3.3 oracle

1.3)percentage of total memory utilization:

# ps -eo user,pid,pmem,comm | awk '{x += $3} END {print x}'
2.1

1.4)top 3 memory utilizing process.

emdlagas1105:~ # ps -eo user,pid,pmem,comm | sort -nrbk3 | head -3
eekcpq 10315 1.1 Ice
lsutto 20414 1.0 java
root 31928 0.0 snmpd


2)HP UNIX:

2.1)percentage of total CPU utilization:

root>UNIX95= ps -eo user,pid,pcpu,comm | awk '{x += $3} END {print x}'
35.99


2.2)Top 3 CPU utilized process:

root> UNIX95= ps -eo user,pid,pcpu,comm | sort -nrbk3 | head -3
bpulak 26189 2.47 smbd
oracle9 29795 1.13 oraclemaximolg
root 1038 0.86 syncer


2.3)percentage of total memory utilization:

The below command is not working.

root > UNIX95= ps -eo user,pid,pmem,comm | awk '{x += $3} END {print x}'
ps: pmem is not a valid field name


2.4)Top 3 memory utilized process:

UNIX95= ps -eo user,pid,pmem,comm | sort -nrbk3 | head -3
ps: pmem is not a valid field name


I have follwoing questions:

1) are all 1.1, 1.2, 1,3, 1.4 are correct?
2) are all 1.1, 1.2 are correct?
3) why pmem is not working in HPUX, how to solve this?
4)do you have any other method to find the cpu utilization and memory utilization like above.?



James R. Ferguson
Acclaimed Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi:

> 3) why pmem is not working in HPUX, how to solve this?

Why do YOU think? Did you READ the manpages? Do you believe that all flavors of UNIX and/or LINUX are indentical?

...JRF...
Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Shalom,

Take a look at my code.

One set for HP-UX

One set for Linux

One set for Solaris.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
senthil_kumar_1
Super Advisor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi Steven,

Please attach file.


Hi James,

If pmem is not working, what is the alternative command that we can use for finding the percentage of total memory usage and top 3 memory using process.
Sunny123_1
Esteemed Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Hi

You can use top and glance command for this.


Regards
Sunny
Steven E. Protter
Exalted Contributor

Re: CPU Utilization, Memory Utilization and TOP 3 CPU and Memory Utilized process.

Shalom,

http://www.hpuxconsulting.com/mem.mon

wget http://www.hpuxconsulting.com/mem.mon

That will get you a copy.

I don't want to actually attach the file because I'm working on a revision and when I replace this file, I want links to be good.

Take a look at the code that builds the variable CL

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com