System Monitoring Program (MON)
Jonathan Biggar
jonab at sdcrdcf.UUCP
Thu Dec 6 05:34:59 AEST 1984
There are a few problems with the distributed version of the MON
program. I have made fixes to these problems.
1) the dualcpu stuff for a dual 780 configuration will not compile
on a system without the dualcpu hacks. I have added a DUALCPU
#ifdef around all portions of the code dealing with dualcpu.
2) An ioctl to set the terminal into CBREAK mode was done directly,
instead of using the curses crmode() call. This causes the
sgttyb structure for the terminal to get clobbered when MON finishes;
including messing up the XTABS setting. I changed it to use
crmode().
3) When MON exited normally, it exited with status 1. I changed this to
0.
Following are context diffs for 4 files: display.c mon.c mon.h and vm.c.
Feed these through Larry Wall's patch program, or install them by hand.
*** /tmp/,RCSt1020354 Wed Dec 5 11:16:54 1984
--- display.c Wed Dec 5 10:29:15 1984
***************
*** 37,42
mvprintw(PROCY,LEFT,"Procs: r d p s sl Mem: real ract virt vact free");
mvprintw(DISKY,DISKX,"Disks: Kbps tps msps");
mvprintw(CPUY,LEFT,"Cpu: ints scall csw");
if (dualcpu)
mvprintw(CPUY,LEFT+25,"Cpu2: csw");
mvprintw(TIMEY,LEFT,"Time: user nice sys idle");
--- 37,43 -----
mvprintw(PROCY,LEFT,"Procs: r d p s sl Mem: real ract virt vact free");
mvprintw(DISKY,DISKX,"Disks: Kbps tps msps");
mvprintw(CPUY,LEFT,"Cpu: ints scall csw");
+ #ifdef DUALCPU
if (dualcpu)
mvprintw(CPUY,LEFT+25,"Cpu2: csw");
#endif DUALCPU
***************
*** 39,44
mvprintw(CPUY,LEFT,"Cpu: ints scall csw");
if (dualcpu)
mvprintw(CPUY,LEFT+25,"Cpu2: csw");
mvprintw(TIMEY,LEFT,"Time: user nice sys idle");
if (dualcpu)
mvprintw(TIMEY,LEFT+26,"Time2: user nice sys idle");
--- 40,46 -----
#ifdef DUALCPU
if (dualcpu)
mvprintw(CPUY,LEFT+25,"Cpu2: csw");
+ #endif DUALCPU
mvprintw(TIMEY,LEFT,"Time: user nice sys idle");
#ifdef DUALCPU
if (dualcpu)
***************
*** 40,45
if (dualcpu)
mvprintw(CPUY,LEFT+25,"Cpu2: csw");
mvprintw(TIMEY,LEFT,"Time: user nice sys idle");
if (dualcpu)
mvprintw(TIMEY,LEFT+26,"Time2: user nice sys idle");
mvprintw(PAGEY,LEFT,"Paging: re at pin pout oprs fr def sr");
--- 42,48 -----
mvprintw(CPUY,LEFT+25,"Cpu2: csw");
#endif DUALCPU
mvprintw(TIMEY,LEFT,"Time: user nice sys idle");
+ #ifdef DUALCPU
if (dualcpu)
mvprintw(TIMEY,LEFT+26,"Time2: user nice sys idle");
#endif DUALCPU
***************
*** 42,47
mvprintw(TIMEY,LEFT,"Time: user nice sys idle");
if (dualcpu)
mvprintw(TIMEY,LEFT+26,"Time2: user nice sys idle");
mvprintw(PAGEY,LEFT,"Paging: re at pin pout oprs fr def sr");
mvprintw(PAGEY+3,LEFT," nxf xf nzf zf nrf rf prf swi swo");
mvprintw(CHARY,CHARX,"Char: in out");
--- 45,51 -----
#ifdef DUALCPU
if (dualcpu)
mvprintw(TIMEY,LEFT+26,"Time2: user nice sys idle");
+ #endif DUALCPU
mvprintw(PAGEY,LEFT,"Paging: re at pin pout oprs fr def sr");
mvprintw(PAGEY+3,LEFT," nxf xf nzf zf nrf rf prf swi swo");
mvprintw(CHARY,CHARX,"Char: in out");
*** /tmp/,RCSt1020366 Wed Dec 5 11:17:05 1984
--- mon.c Wed Dec 5 11:07:39 1984
***************
*** 36,41
{ "_tk_nin" },
{ "_tk_nout" },
{ "_avenrun" },
{ "_cp2_time" }, /* 2nd CPU stats */
{ "_slavestart" }, /* Used to detect 2nd CPU */
{ 0 }
--- 36,42 -----
{ "_tk_nin" },
{ "_tk_nout" },
{ "_avenrun" },
+ #ifdef DUALCPU
{ "_cp2_time" }, /* 2nd CPU stats */
{ "_slavestart" }, /* Used to detect 2nd CPU */
#endif DUALCPU
***************
*** 38,43
{ "_avenrun" },
{ "_cp2_time" }, /* 2nd CPU stats */
{ "_slavestart" }, /* Used to detect 2nd CPU */
{ 0 }
};
--- 39,45 -----
#ifdef DUALCPU
{ "_cp2_time" }, /* 2nd CPU stats */
{ "_slavestart" }, /* Used to detect 2nd CPU */
+ #endif DUALCPU
{ 0 }
};
***************
*** 74,79
lseek(kmem, (long)namelist[X_HZ].n_value, 0);
read(kmem, &hz, sizeof hz);
read_names();
dualcpu = 0;
if (namelist[X_SLAVESTART].n_type)
dualcpu++;
--- 76,82 -----
lseek(kmem, (long)namelist[X_HZ].n_value, 0);
read(kmem, &hz, sizeof hz);
read_names();
+ #ifdef DUALCPU
dualcpu = 0;
if (namelist[X_SLAVESTART].n_type)
dualcpu++;
***************
*** 77,82
dualcpu = 0;
if (namelist[X_SLAVESTART].n_type)
dualcpu++;
/*
* monitor parameters forever
*/
--- 80,86 -----
dualcpu = 0;
if (namelist[X_SLAVESTART].n_type)
dualcpu++;
+ #endif DUALCPU
/*
* monitor parameters forever
*/
***************
*** 96,108
signal(SIGINT, done);
signal(SIGQUIT, done);
- /* set CBREAK mode with no buffering on stdin */
- setbuf(stdin, 0);
- setbuf(stdout, obuf);
- ioctl(0, TIOCGETP, &ttyb);
- ttyb.sg_flags |= CBREAK;
- ioctl(fileno(stdin), TIOCSETP, (char *)&ttyb);
-
tintv.tv_sec = intv;
tintv.tv_usec = 0;
initscr(); /* init curses package */
--- 100,105 -----
signal(SIGINT, done);
signal(SIGQUIT, done);
tintv.tv_sec = intv;
tintv.tv_usec = 0;
initscr(); /* init curses package */
***************
*** 106,111
tintv.tv_sec = intv;
tintv.tv_usec = 0;
initscr(); /* init curses package */
nifinit(); /* get initial net interfaces data */
dispinit(); /* initialize display */
for(;;){
--- 103,109 -----
tintv.tv_sec = intv;
tintv.tv_usec = 0;
initscr(); /* init curses package */
+ crmode(); /* set terminal into cbreak mode */
nifinit(); /* get initial net interfaces data */
dispinit(); /* initialize display */
for(;;){
***************
*** 138,147
*/
done()
{
- ioctl(0, TIOCGETP, &ttyb);
- ttyb.sg_flags &= ~CBREAK;
- ioctl(fileno(stdin), TIOCSETP, (char *)&ttyb);
- mvprintw(23,0,"\n");
refresh();
exit(1);
}
--- 136,141 -----
*/
done()
{
refresh();
endwin();
exit(0);
***************
*** 143,147
ioctl(fileno(stdin), TIOCSETP, (char *)&ttyb);
mvprintw(23,0,"\n");
refresh();
! exit(1);
}
--- 137,142 -----
done()
{
refresh();
! endwin();
! exit(0);
}
*** /tmp/,RCSt1020371 Wed Dec 5 11:17:12 1984
--- mon.h Wed Dec 5 10:47:29 1984
***************
*** 32,37
#define X_TK_NIN 14
#define X_TK_NOUT 15
#define LOADAV 16
#define X_CP_TIME2 17 /* 2nd CPU stats */
#define X_SLAVESTART 18 /* 2nd cpu existance test */
--- 32,38 -----
#define X_TK_NIN 14
#define X_TK_NOUT 15
#define LOADAV 16
+ #ifdef DUALCPU
#define X_CP_TIME2 17 /* 2nd CPU stats */
#define X_SLAVESTART 18 /* 2nd cpu existance test */
#endif DUALCPU
***************
*** 34,40
#define LOADAV 16
#define X_CP_TIME2 17 /* 2nd CPU stats */
#define X_SLAVESTART 18 /* 2nd cpu existance test */
!
extern struct nlist namelist[];
int intv; /* interval time */
int numif; /* number of interfaces */
--- 35,41 -----
#ifdef DUALCPU
#define X_CP_TIME2 17 /* 2nd CPU stats */
#define X_SLAVESTART 18 /* 2nd cpu existance test */
! #endif DUALCPU
extern struct nlist namelist[];
int intv; /* interval time */
int numif; /* number of interfaces */
***************
*** 38,43
extern struct nlist namelist[];
int intv; /* interval time */
int numif; /* number of interfaces */
int dualcpu; /* flag to indicate dual CPU */
int kmem, hz;
int deficit;
--- 39,45 -----
extern struct nlist namelist[];
int intv; /* interval time */
int numif; /* number of interfaces */
+ #ifdef DUALCPU
int dualcpu; /* flag to indicate dual CPU */
#endif DUALCPU
int kmem, hz;
***************
*** 39,44
int intv; /* interval time */
int numif; /* number of interfaces */
int dualcpu; /* flag to indicate dual CPU */
int kmem, hz;
int deficit;
double etime;
--- 41,47 -----
int numif; /* number of interfaces */
#ifdef DUALCPU
int dualcpu; /* flag to indicate dual CPU */
+ #endif DUALCPU
int kmem, hz;
int deficit;
double etime;
*** /tmp/,RCSt1020384 Wed Dec 5 11:17:23 1984
--- vm.c Wed Dec 5 10:29:13 1984
***************
*** 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);
--- 27,33 -----
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);
--- 32,38 -----
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];
--- 46,52 -----
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.)
--- 52,58 -----
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.)
***************
*** 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();
--- 81,87 -----
/* Display CPU info */
mvprintw(CPUY+1,4,"%4d %4d", (rate.v_intr) - hz, rate.v_syscall);
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 */
--- 84,90 -----
#ifdef DUALCPU
if (dualcpu)
mvprintw(CPUY+1,30,"%4d", rate.v_swtch2);
+ #endif DUALCPU
cputime();
/* Display additional stuff */
***************
*** 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;
--- 118,124 -----
x = 6;
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;
}
}
--- 121,127 -----
#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