Operating System - HP-UX
1753776 Members
7143 Online
108799 Solutions
New Discussion юеВ

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

 
SOLVED
Go to solution
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.?