Zsh Mailing List Archive
Messages sorted by:
displaying top cpu using process
- X-seq: zsh-users 3809
- From: Dominik Vogt <dominik.vogt@xxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: displaying top cpu using process
- Date: Sat, 7 Apr 2001 16:33:48 +0200
- Mail-followup-to: zsh-users@xxxxxxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Reply-to: dominik.vogt@xxxxxx
I want to have a button in the button bar of my window manager
(fvwm with FvwmButtons) that displays the process that currently
uses most CPU. The information I want to display is the process
id, used CPU and the command line of the process, e.g.
12345 99.0% netscape
The part dealing with X and the window manager is not the problen,
althoug it is not easy to do. The problem is that it is
surprisingly difficult to get said information (SuSE 7.1 Linux
with 2.4.0 kernel)
I tried out about a dozen different programs that display load or
process information, and the only candidates I came across are ps
ps gives me complete control over the output format, but I can't
make it give me the CPU percentage. Although the 'C' output
modifier is documented as
"use raw CPU time for %CPU instead of decaying average"
I always get the decaying average. Because of this, most of the
time I see that X uses most CPU.
Top provides all the output I need, but it is *very* cumbersome
to parse. Okay, I have an (inefficient) shell script that
extracts the information:
top -b -n 1 | sed '<script>'
But then, this only works if the terminal window from which top
was started has enough lines. If its too short, top generates
only the header or no lines at all. This is certainly a strange
notion of a batch mode (b option). To get the full output I
have to detach top from the terminal. In other words, I need
one process that generates the data and one that writes it into
the terminal window. There are several ways to do this, but
the best solution seems to be a coprocess (because the coprocess
is killed if the terminal window that runs the script is
Of course this all wastes a lot of cpu and memory and is very
ugly to write.
Can anybody think of a better solution (that does not include
writing any C code)?
Dominik ^_^ ^_^
Dominik Vogt, dominik.vogt@xxxxxx
Messages sorted by: