modifications to mon

Kim Korner korner at ut-sally.UUCP
Fri Mar 8 09:33:30 AEST 1985


	In porting mon to our Sun machines two modules were changed
(readnames.c and vm.c). Of general interest is the rewrite of readnames.c
which reads the names of disks from /etc/mtab instead of wandering through
kernel space. A listing for the rewritten readnames.c and a diff -c listing
of vm.c follows ...

/*
 *      R E A D N A M E S
 * 
 * purpose: Reads the names of the disks from /etc/mtab
 *
 */
#include "mon.h"
#include <fstab.h>
#include <mtab.h>

read_names()
{
int	mtab_fd, i, j;
struct mtab buf;

        mtab_fd = open("/etc/mtab", 0);
        if(mtab_fd < 0) {
                printf("cannot open /etc/mtab\n");
                exit(1);
        }
	for (i = 0; i < DK_NDRIVE	/* for each device in mtab */
		    && (j = read (mtab_fd,
				  &buf, sizeof (struct mtab))) > 0; ) {
					/* don't consider the network dsk */
		if (! strcmp (buf.m_dname, "ndp0")) continue;
		for (j=0; j < i; j++)	/* weed out duplicate devices */
			if (! strncmp (dr_name[j], buf.m_dname, 3)) break;
		if (i != j) continue;	/* if duplicate */
		strncpy (dr_name[i], buf.m_dname, 3);	/* copy the unique */
                dr_unit[i++] = buf.m_dname[2] - '0';	/* guess the dev # */
	}
}


*** vm.c	Thu Mar  7 08:37:14 1985
--- vm.new	Thu Feb 14 14:08:56 1985
***************
*** 13,24
  #include "mon.h"
  #include <machine/param.h>	/* defines bytes/page */
  
- /* Temporary defines */
- #define	PROCS	2
- #define	CPUY	5
- #define	TIMEY	8
- #define	PAGE	11
- 
  vm()
  {
          register i,j;

--- 13,18 -----
  #include "mon.h"
  #include <machine/param.h>	/* defines bytes/page */
  
  vm()
  {
          register i,j;
***************
*** 27,32
          lseek(kmem, (long)namelist[X_CP_TIME].n_value, 0);
          read(kmem, s.cp_time, sizeof s.cp_time);
  	/* Check for 2nd CPU stats */
  	if (dualcpu) {
  	        lseek(kmem, (long)namelist[X_CP_TIME2].n_value, 0);
  	        read(kmem, s.cp_time2, sizeof s.cp_time2);

--- 21,27 -----
          lseek(kmem, (long)namelist[X_CP_TIME].n_value, 0);
          read(kmem, s.cp_time, sizeof s.cp_time);
  	/* Check for 2nd CPU stats */
+ #ifdef DUALCPU
  	if (dualcpu) {
  	        lseek(kmem, (long)namelist[X_CP_TIME2].n_value, 0);
  	        read(kmem, s.cp_time2, sizeof s.cp_time2);
***************
*** 31,36
  	        lseek(kmem, (long)namelist[X_CP_TIME2].n_value, 0);
  	        read(kmem, s.cp_time2, sizeof s.cp_time2);
  	}
          lseek(kmem, (long)namelist[X_DK_XFER].n_value, 0);
          read(kmem, s.dk_xfer, sizeof s.dk_xfer);
          lseek(kmem, (long)namelist[X_RATE].n_value, 0);

--- 26,32 -----
  	        lseek(kmem, (long)namelist[X_CP_TIME2].n_value, 0);
  	        read(kmem, s.cp_time2, sizeof s.cp_time2);
  	}
+ #endif DUALCPU
          lseek(kmem, (long)namelist[X_DK_XFER].n_value, 0);
          read(kmem, s.dk_xfer, sizeof s.dk_xfer);
          lseek(kmem, (long)namelist[X_RATE].n_value, 0);
***************
*** 44,49
                  t = s.cp_time[i];
                  s.cp_time[i] -= s1.cp_time[i];
                  s1.cp_time[i] = t;
          	if (dualcpu) {
  	                t = s.cp_time2[i];
          	        s.cp_time2[i] -= s1.cp_time2[i];

--- 40,46 -----
                  t = s.cp_time[i];
                  s.cp_time[i] -= s1.cp_time[i];
                  s1.cp_time[i] = t;
+ #ifdef DUALCPU
          	if (dualcpu) {
  	                t = s.cp_time2[i];
          	        s.cp_time2[i] -= s1.cp_time2[i];
***************
*** 49,54
          	        s.cp_time2[i] -= s1.cp_time2[i];
                  	s1.cp_time2[i] = t;
          	}
                  etime += s.cp_time[i];	/* interval must count 1 CPU only */
          }
          if(etime == 0.)

--- 46,52 -----
          	        s.cp_time2[i] -= s1.cp_time2[i];
                  	s1.cp_time2[i] = t;
          	}
+ #endif DUALCPU
                  etime += s.cp_time[i];	/* interval must count 1 CPU only */
          }
          if(etime == 0.)
***************
*** 56,62
          etime /= (float) hz;
  
  	/* Display the procs line */
!         mvprintw(PROCS+1,6,"%2d%2d%2d%2d %2d", total.t_rq, total.t_dw, total.t_pw, total.t_sw, total.t_sl);
  #define pgtok(a) ((a)*NBPG/1024)
          mvprintw(PROCS+1,23,"%5d %5d", pgtok(total.t_rm), pgtok(total.t_arm) );
          mvprintw(PROCS+1,34,"%6d %5d", pgtok(total.t_vm), pgtok(total.t_avm) );

--- 54,60 -----
          etime /= (float) hz;
  
  	/* Display the procs line */
!         mvprintw(PROCY+1,6,"%2d%2d%2d%2d %2d", total.t_rq, total.t_dw, total.t_pw, total.t_sw, total.t_sl);
  #define pgtok(a) ((a)*NBPG/1024)
          mvprintw(PROCY+1,23,"%5d %5d", pgtok(total.t_rm), pgtok(total.t_arm) );
          mvprintw(PROCY+1,34,"%6d %5d", pgtok(total.t_vm), pgtok(total.t_avm) );
***************
*** 58,66
  	/* Display the procs line */
          mvprintw(PROCS+1,6,"%2d%2d%2d%2d %2d", total.t_rq, total.t_dw, total.t_pw, total.t_sw, total.t_sl);
  #define pgtok(a) ((a)*NBPG/1024)
!         mvprintw(PROCS+1,23,"%5d %5d", pgtok(total.t_rm), pgtok(total.t_arm) );
!         mvprintw(PROCS+1,34,"%6d %5d", pgtok(total.t_vm), pgtok(total.t_avm) );
!         mvprintw(PROCS+1,47,"%5d", pgtok(total.t_free));
  
  	/* Display paging info */
          mvprintw(PAGE+1,6,"%4d %3d",

--- 56,64 -----
  	/* Display the procs line */
          mvprintw(PROCY+1,6,"%2d%2d%2d%2d %2d", total.t_rq, total.t_dw, total.t_pw, total.t_sw, total.t_sl);
  #define pgtok(a) ((a)*NBPG/1024)
!         mvprintw(PROCY+1,23,"%5d %5d", pgtok(total.t_rm), pgtok(total.t_arm) );
!         mvprintw(PROCY+1,34,"%6d %5d", pgtok(total.t_vm), pgtok(total.t_avm) );
!         mvprintw(PROCY+1,47,"%5d", pgtok(total.t_free));
  
  	/* Display paging info */
          mvprintw(PAGEY+1,6,"%4d %3d",
***************
*** 63,69
          mvprintw(PROCS+1,47,"%5d", pgtok(total.t_free));
  
  	/* Display paging info */
!         mvprintw(PAGE+1,6,"%4d %3d",
                  (rate.v_pgrec - (rate.v_xsfrec+rate.v_xifrec)),
                  (rate.v_xsfrec+rate.v_xifrec));
          mvprintw(PAGE+1,14,"%4d %4d", pgtok(rate.v_pgpgin),

--- 61,67 -----
          mvprintw(PROCY+1,47,"%5d", pgtok(total.t_free));
  
  	/* Display paging info */
!         mvprintw(PAGEY+1,6,"%4d %3d",
                  (rate.v_pgrec - (rate.v_xsfrec+rate.v_xifrec)),
                  (rate.v_xsfrec+rate.v_xifrec));
          mvprintw(PAGEY+1,14,"%4d %4d", pgtok(rate.v_pgpgin),
***************
*** 66,72
          mvprintw(PAGE+1,6,"%4d %3d",
                  (rate.v_pgrec - (rate.v_xsfrec+rate.v_xifrec)),
                  (rate.v_xsfrec+rate.v_xifrec));
!         mvprintw(PAGE+1,14,"%4d %4d", pgtok(rate.v_pgpgin),
                  pgtok(rate.v_pgpgout));
  	/* operations per time is (pgin + pgout)  */
          mvprintw(PAGE+1,24,"%4d", (pgtok(rate.v_pgin)+

--- 64,70 -----
          mvprintw(PAGEY+1,6,"%4d %3d",
                  (rate.v_pgrec - (rate.v_xsfrec+rate.v_xifrec)),
                  (rate.v_xsfrec+rate.v_xifrec));
!         mvprintw(PAGEY+1,14,"%4d %4d", pgtok(rate.v_pgpgin),
                  pgtok(rate.v_pgpgout));
  	/* operations per time is (pgin + pgout)  */
          mvprintw(PAGEY+1,25,"%4d", (pgtok(rate.v_pgin)+
***************
*** 69,75
          mvprintw(PAGE+1,14,"%4d %4d", pgtok(rate.v_pgpgin),
                  pgtok(rate.v_pgpgout));
  	/* operations per time is (pgin + pgout)  */
!         mvprintw(PAGE+1,24,"%4d", (pgtok(rate.v_pgin)+
                  pgtok(rate.v_pgout)));
          mvprintw(PAGE+1,29,"%4d %4d %4d", pgtok(rate.v_dfree)
                  , pgtok(deficit), rate.v_scan);

--- 67,73 -----
          mvprintw(PAGEY+1,14,"%4d %4d", pgtok(rate.v_pgpgin),
                  pgtok(rate.v_pgpgout));
  	/* operations per time is (pgin + pgout)  */
!         mvprintw(PAGEY+1,25,"%4d", (pgtok(rate.v_pgin)+
                  pgtok(rate.v_pgout)));
          mvprintw(PAGEY+1,29,"%4d %4d %4d", pgtok(rate.v_dfree)
                  , pgtok(deficit), rate.v_scan);
***************
*** 71,77
  	/* operations per time is (pgin + pgout)  */
          mvprintw(PAGE+1,24,"%4d", (pgtok(rate.v_pgin)+
                  pgtok(rate.v_pgout)));
!         mvprintw(PAGE+1,29,"%4d %4d %4d", pgtok(rate.v_dfree)
                  , pgtok(deficit), rate.v_scan);
  
  	/* Display CPU info */

--- 69,75 -----
  	/* operations per time is (pgin + pgout)  */
          mvprintw(PAGEY+1,25,"%4d", (pgtok(rate.v_pgin)+
                  pgtok(rate.v_pgout)));
!         mvprintw(PAGEY+1,29,"%4d %4d %4d", pgtok(rate.v_dfree)
                  , pgtok(deficit), rate.v_scan);
  
  	/* Display CPU info */
***************
*** 75,81
                  , pgtok(deficit), rate.v_scan);
  
  	/* Display CPU info */
!         mvprintw(CPUY+1,4,"%4d  %4d", (rate.v_intr) - hz, rate.v_syscall);
          mvprintw(CPUY+1,17,"%4d", rate.v_swtch);
  	if (dualcpu)
  	        mvprintw(CPUY+1,30,"%4d", rate.v_swtch2);

--- 73,83 -----
                  , pgtok(deficit), rate.v_scan);
  
  	/* Display CPU info */
! #ifndef sun
!         mvprintw(CPUY+1,5,"%4d   %4d", (rate.v_intr) - hz, rate.v_syscall);
! #else
!         mvprintw(CPUY+1,5,"%4d   %4d", rate.v_intr, rate.v_syscall);
! #endif
          mvprintw(CPUY+1,17,"%4d", rate.v_swtch);
  #ifdef DUALCPU
  	if (dualcpu)
***************
*** 77,82
  	/* Display CPU info */
          mvprintw(CPUY+1,4,"%4d  %4d", (rate.v_intr) - hz, rate.v_syscall);
          mvprintw(CPUY+1,17,"%4d", rate.v_swtch);
  	if (dualcpu)
  	        mvprintw(CPUY+1,30,"%4d", rate.v_swtch2);
          cputime();

--- 79,85 -----
          mvprintw(CPUY+1,5,"%4d   %4d", rate.v_intr, rate.v_syscall);
  #endif
          mvprintw(CPUY+1,17,"%4d", rate.v_swtch);
+ #ifdef DUALCPU
  	if (dualcpu)
  	        mvprintw(CPUY+1,30,"%4d", rate.v_swtch2);
  #endif DUALCPU
***************
*** 79,84
          mvprintw(CPUY+1,17,"%4d", rate.v_swtch);
  	if (dualcpu)
  	        mvprintw(CPUY+1,30,"%4d", rate.v_swtch2);
          cputime();
  
  	/* Display additional stuff */

--- 82,88 -----
  #ifdef DUALCPU
  	if (dualcpu)
  	        mvprintw(CPUY+1,30,"%4d", rate.v_swtch2);
+ #endif DUALCPU
          cputime();
  
  	/* Display additional stuff */
***************
*** 82,88
          cputime();
  
  	/* Display additional stuff */
! 	mvprintw(PAGE+4,6,"%4d%4d %4d%4d %4d%4d %4d %4d%4d",
  		rate.v_nexfod, rate.v_exfod,
  		rate.v_nzfod, rate.v_zfod,
  		rate.v_nvrfod, rate.v_vrfod,

--- 86,92 -----
          cputime();
  
  	/* Display additional stuff */
! 	mvprintw(PAGEY+4,6,"%4d%4d %4d%4d %4d%4d %4d %4d%4d",
  		rate.v_nexfod, rate.v_exfod,
  		rate.v_nzfod, rate.v_zfod,
  		rate.v_nvrfod, rate.v_vrfod,
***************
*** 109,115
  		t = 1.;
  	if (t2 == 0.)
  		t2 = 1.;
!         x = 6;
          for(i=0; i<CPUSTATES; i++){
                  mvprintw(TIMEY+1,x,"%3.0f", 100 * s.cp_time[i]/t);
          	if (dualcpu)

--- 113,119 -----
  		t = 1.;
  	if (t2 == 0.)
  		t2 = 1.;
!         x = 7;
          for(i=0; i<CPUSTATES; i++){
                  mvprintw(TIMEY+1,x,"%3.0f", 100 * s.cp_time[i]/t);
  #ifdef DUALCPU
***************
*** 112,117
          x = 6;
          for(i=0; i<CPUSTATES; i++){
                  mvprintw(TIMEY+1,x,"%3.0f", 100 * s.cp_time[i]/t);
          	if (dualcpu)
  	                mvprintw(TIMEY+1,x+27,"%3.0f", 100 * s.cp_time2[i]/t2);
                  x += 5;

--- 116,122 -----
          x = 7;
          for(i=0; i<CPUSTATES; i++){
                  mvprintw(TIMEY+1,x,"%3.0f", 100 * s.cp_time[i]/t);
+ #ifdef DUALCPU
          	if (dualcpu)
  	                mvprintw(TIMEY+1,x+27,"%3.0f", 100 * s.cp_time2[i]/t2);
  #endif DUALCPU
***************
*** 114,119
                  mvprintw(TIMEY+1,x,"%3.0f", 100 * s.cp_time[i]/t);
          	if (dualcpu)
  	                mvprintw(TIMEY+1,x+27,"%3.0f", 100 * s.cp_time2[i]/t2);
                  x += 5;
          }
  }

--- 119,125 -----
  #ifdef DUALCPU
          	if (dualcpu)
  	                mvprintw(TIMEY+1,x+27,"%3.0f", 100 * s.cp_time2[i]/t2);
+ #endif DUALCPU
                  x += 5;
          }
  }



More information about the Comp.sources.bugs mailing list