1833762 Members
2166 Online
110063 Solutions
New Discussion

Monitoring

 
SOLVED
Go to solution
Jonathan Caplette
Regular Advisor

Monitoring

Hi guys....

I've a little probleme here, I want to monitor the processes that are running on my HP-UX 10.20 box...

I try to use "top" but when I put it in a logfile, I can't see it normaly, it seems that it displays the screen caracters.... I try to do a script with the command "ps" but it some kind of tricky when it come with the grep and everything...

I was wondering if there's an utility that I can use to do it, or if some body have a command line to do the job...

thanx...
Jonathan
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Monitoring

Hi Jonathan:

You can do a top -f myfile which outputs to myfile and exits. There are no terminal sequences in this output.

Clay
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: Monitoring

Hi Jonathan:

'top' has a little known, largely undocumented option to do exactly what you want. To capture, for instance, one screen view into a file, use the '-f' option like this:

# top -d 1 -f /tmp/top.out

Regards!

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

Re: Monitoring

Hi

The output of ps -ef has 13 columns:-

ps -ef | awk '{print $X,$Y,$z }' > output file

Change the X,Y and Z to the columns that you want.

if you wish to get ps output for certain users then:-

ps -e | grep | awk '{print '{$X,$y,$z}' > output file

HTH

Paula
If you can spell SysAdmin then you is one - anon
linuxfan
Honored Contributor

Re: Monitoring

Hi Jonathan,

what are you trying to monitor exactly?

Anyway you could use top -d 1 -f /tmp/top.out
which would print 1 display of the top output.

Also you could use ps (with the XPG4 environments)

eg:
To sort the top processes based on the cpu usage
UNIX95= ps -e -o pcpu -o ruser,args |sort -rn |grep -v %CPU

To monitor the process based on the memory sizes
UNIX95= ps -e -o vsz=Kbytes -o ruser,pid,ppid,args |sort -rnk2

you could put this as aliases in your .kshrc
eg:
pscpu="UNIX95= ps -e -o pcpu -o ruser,args |sort -rn |grep -v %CPU"
psmem="UNIX95= ps -e -o vsz=Kbytes -o ruser,pid,ppid,args |sort -rnk2"

Look at the man pages of ps for more information.

-Ramesh
They think they know but don't. At least I know I don't know - Socrates
Jonathan Caplette
Regular Advisor

Re: Monitoring

thanks a lot guys... top work perfectly with the -f untold option!! :)

regards
jonathan