Operating System - HP-UX
1833968 Members
1722 Online
110063 Solutions
New Discussion

I am looking for a script to run the top command

 
SOLVED
Go to solution
John Jimenez
Super Advisor

I am looking for a script to run the top command

I looked through the favorite sysadmin scripts and found this one. but this does not seem to be showing be the right info. I am not even really sure what it is telling me? Do anyone know of one that will give me something more similar to the to the top command? I took this command and modified it to run every 20 minutes.

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



Hustle Makes things happen
5 REPLIES 5
Sridhar Bhaskarla
Honored Contributor
Solution

Re: I am looking for a script to run the top command

Hi John,

I didn't get your requirement. If your idea is to capture the top output into a file, then you can use -f option of top to dump it into file. For ex.,

top -s 5 -d 10 -f top.out

will print 10 top sessions at the interval of 5 seconds.

You may want to consider looking at Glance|gpm. It will give you an extensive output with excellent online help.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
John Jimenez
Super Advisor

Re: I am looking for a script to run the top command

Yes I want to echo it to a report. Especially things running at night. Thanks I will try this.
Hustle Makes things happen
James R. Ferguson
Acclaimed Contributor

Re: I am looking for a script to run the top command

Hi:

The script reports the "top-10" processes in terms of memory (core) consumption. The output is sorted in descending size -- largest first.

The option 'UNIX95' is set *only* for the command line -- the 'ps' command. This option is also known as 'XPG4' behavior. The various 'ps' options (e.g. vsz, pcpu, etc) are explained in the 'ps' man pages. The beauty of using the '-o' option is that *you* can choose how you want your output to look and what it should contain.

As Sri already noted, 'top' has a '-f file' option to direct its output into a file that can be parsed.

Regards!

...JRF...
Paula J Frazer-Campbell
Honored Contributor

Re: I am looking for a script to run the top command

Hi

Have a look at sar - man sar - also search the for on sar.


Paula
If you can spell SysAdmin then you is one - anon
Steven E. Protter
Exalted Contributor

Re: I am looking for a script to run the top command

Attaching a series of sar scripts that collect information for a period of time determined by you.

This follows on Paula's suggestion.

I will be updating/improving this package in the next few weeks, but it works pretty well now.

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