zsh-users
 help / color / mirror / code / Atom feed
* displaying top cpu using process
@ 2001-04-07 14:33 Dominik Vogt
  2001-04-07 18:26 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Dominik Vogt @ 2001-04-07 14:33 UTC (permalink / raw)
  To: zsh-users

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
and top.

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:

  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
  closed).

  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)?

Bye

Dominik ^_^  ^_^

--
Dominik Vogt, dominik.vogt@gmx.de
Reply-To: dominik.vogt@gmx.de


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-04-08 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-07 14:33 displaying top cpu using process Dominik Vogt
2001-04-07 18:26 ` Bart Schaefer
2001-04-08 12:49   ` Dominik Vogt
2001-04-08 17:04     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).