From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6804 invoked from network); 7 Apr 2001 14:34:21 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 7 Apr 2001 14:34:21 -0000 Received: (qmail 11153 invoked by alias); 7 Apr 2001 14:34:03 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3809 Received: (qmail 11141 invoked from network); 7 Apr 2001 14:34:02 -0000 X-Authentication-Warning: DarkSun.local: luthien set sender to dominik.vogt@gmx.de using -f Date: Sat, 7 Apr 2001 16:33:48 +0200 From: Dominik Vogt To: zsh-users@sunsite.auc.dk Subject: displaying top cpu using process Message-ID: <20010407163348.A619@gmx.de> Reply-To: dominik.vogt@gmx.de Mail-Followup-To: zsh-users@sunsite.auc.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.12i X-Sender: 510058704406-0001@t-dialin.net 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 '