Enhancement to Top Users Display V2.1

Paul Vixie vix at ubvax.UB.Com
Fri Mar 18 09:04:49 AEST 1988


Now that I routinely use 60-line windows on the Sun here, Top's ability to
automatically use the whole screen was a little bit of overkill -- I just
don't want to look at all those idle csh and getty processes.  I thought of
using the command line option to Top that would make it display a specific
number of processes (instead of the default behaviour of filling your screen
with as many processes as will fit); this was not a very flexible approach.
If there were 50 (as an example) busy processes on this machine, I wanted
to see all of them.  If there were 10, I wanted to see those 10 but not all
the idle gettys, etc.  You get the idea?

What I came up with is the '-I' flag, which says "completely ignore processes
whose p_pctcpu field is zero".  Since this field takes about 15 minutes to
decay to absolute zero, processes will hang around on the display that appear
to have "0.00%" CPU utilization, but that's a feature in my opinion.  Processes
which have 0.004% utilization are still marginally "interesting" to me.

Anyway, here's the diff.  I'll look for the author's address and send it to
him, but for those of you already using my non-standard Symmetric version,
you aren't waiting for author-approved patches anyway.  Except for line
numbers, this patch will apply to straight V2.1 or to my SCS version equally.

*** top.c.orig	Thu Mar 17 14:36:52 1988
--- top.c	Thu Mar 17 14:48:07 1988
***************
*** 222,225 ****
--- 222,226 ----
      char interactive = Maybe;
      char show_sysprocs = No;
+     char show_idleprocs = Yes;
      char topn_specified = No;
      char warnings = 0;
***************
*** 242,246 ****
  
      /* process options */
!     while ((i = getopt(argc, argv, "Sbinus:d:")) != EOF)
      {
  	switch(i)
--- 243,247 ----
  
      /* process options */
!     while ((i = getopt(argc, argv, "SIbinus:d:")) != EOF)
      {
  	switch(i)
***************
*** 256,259 ****
--- 257,264 ----
  		break;
  
+ 	    case 'I':			/* don't show idle processes */
+ 		show_idleprocs = No;
+ 		break;
+ 
  	    case 'i':			/* go interactive regardless */
  		interactive = Yes;
***************
*** 292,296 ****
  	    default:
  		fprintf(stderr,
! 		    "Usage: %s [-Sbinu] [-d x] [-s x] [number]\n",
  		    myname);
  		exit(1);
--- 297,301 ----
  	    default:
  		fprintf(stderr,
! 		    "Usage: %s [-SIbinu] [-d x] [-s x] [number]\n",
  		    myname);
  		exit(1);
***************
*** 520,524 ****
  		total_procs++;
  		proc_brkdn[pp->p_stat]++;
! 		if (pp->p_stat != SZOMB)
  		{
  		    *prefp++ = pp;
--- 525,531 ----
  		total_procs++;
  		proc_brkdn[pp->p_stat]++;
! 		if ( (pp->p_stat != SZOMB)
! 		  && (show_idleprocs || pp->p_pctcpu)
! 		   )
  		{
  		    *prefp++ = pp;
-- 
Paul Vixie
Consultant        Work: 408-562-7798    vix at ub.com    vix%ubvax at uunet.uu.net
Ungermann-Bass    Home: 415-647-7023    {amdahl,ptsfa,pyramid,uunet}!ubvax!vix
Santa Clara, CA              <<I do not speak for Ungermann-Bass>>



More information about the Comp.sources.bugs mailing list