System Monitoring Program (MON)
Dave Johnson
ddj at brunix.UUCP
Wed Dec 12 19:05:25 AEST 1984
I've made some changes to mon in addition to those
posted by Jonathan Biggar in article <1533 at sdcrdcf.UUCP>,
and by Guy Harris in article <290 at rlgvax.UUCP>.
1) Added code to report the number of forks and vforks
during each interval (this number is usually small enough
to get rounded to zero if you convert into a per-second
rate, so I made it a raw number).
2) Removed three redundant kmem lseek/read calls. dk_mspw
doesn't change after the system is booted (nor does dk_bps
on the sun), so reading it in mon.c should suffice.
Also dk_xfer isn't used in vm.c, it's read in io.c already.
Finally, hz doesn't change while the program is running either.
3) Added a test for no disks at all before printing the
total disk activity -- makes it just a tad prettier on
a diskless sun.
4) Fixed the disk statistics code to work on either VAXen
or Suns. Sun's disk drivers maintain a byte/second figure
for each drive rather than Berkeley's millisecond/word.
5) Fixed the load average code for Suns -- they keep the
value as scaled integers rather than as doubles.
6) Fixed the interrupt/second code for Suns -- they don't
count clock interrupts, Berkeley does.
Dave Johnson
Brown University CS Dept.
{ihnp4,decvax,allegra}!brunix!ddj
ddj%brown.CSNET at csnet-relay.ARPA
------------------
diff -c org/display.c sun/display.c
*** org/display.c Tue Dec 11 23:17:24 1984
--- sun/display.c Tue Dec 11 23:42:01 1984
***************
*** 37,42
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");
mvprintw(NETIFY,LEFT,"Name Ipkts Ierrs Opkts Oerrs Collis Oqueue");
/* add the disk drive names to the screen */
--- 37,43 -----
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");
+ mvprintw(FORKY,FORKX,"Forks: fork vfork");
mvprintw(NETIFY,LEFT,"Name Ipkts Ierrs Opkts Oerrs Collis Oqueue");
/* add the disk drive names to the screen */
diff -c org/io.c sun/io.c
*** org/io.c Tue Dec 11 23:22:10 1984
--- sun/io.c Tue Dec 11 23:42:29 1984
***************
*** 37,46
read(kmem, &s.tk_nout, sizeof s.tk_nout);
lseek(kmem, (long)namelist[X_DK_SEEK].n_value, 0);
read(kmem, s.dk_seek, sizeof s.dk_seek);
- lseek(kmem, (long)namelist[X_DK_MSPW].n_value, 0);
- read(kmem, s.dk_mspw, sizeof s.dk_mspw);
- lseek(kmem, (long)namelist[X_HZ].n_value, 0);
- read(kmem, &hz, sizeof hz);
for (i = 0; i < DK_NDRIVE; i++) {
#define X(fld) t = s.fld[i]; s.fld[i] -= s1.fld[i]; s1.fld[i] = t
X(dk_xfer); X(dk_seek); X(dk_wds); X(dk_time);
--- 37,42 -----
read(kmem, &s.tk_nout, sizeof s.tk_nout);
lseek(kmem, (long)namelist[X_DK_SEEK].n_value, 0);
read(kmem, s.dk_seek, sizeof s.dk_seek);
for (i = 0; i < DK_NDRIVE; i++) {
#define X(fld) t = s.fld[i]; s.fld[i] -= s1.fld[i]; s1.fld[i] = t
X(dk_xfer); X(dk_seek); X(dk_wds); X(dk_time);
***************
*** 60,66
}
}
/* Display Totals */
! mvprintw(lasty+2, DISKX+DISKOFF, "%4.0f%4.0f", tkbps, ttps);
}
/*
--- 58,65 -----
}
}
/* Display Totals */
! if (lasty != 0)
! mvprintw(lasty+2, DISKX+DISKOFF, "%4.0f%4.0f", tkbps, ttps);
}
/*
***************
*** 83,89
return(0);
lasty = y;
! if (s.dk_mspw[dn] == 0.0) {
mvprintw(y,DISKX+DISKOFF,"%4.0f%4.0f%5.1f", 0.0, 0.0, 0.0);
return(0);
}
--- 82,88 -----
return(0);
lasty = y;
! if (s.dk_xfer[dn] == 0) {
mvprintw(y,DISKX+DISKOFF,"%4.0f%4.0f%5.1f", 0.0, 0.0, 0.0);
return(0);
}
***************
*** 90,96
atime = s.dk_time[dn];
atime /= (float) hz;
words = s.dk_wds[dn]*32.0; /* number of 16 bit words transferred */
! xtime = s.dk_mspw[dn]*words; /* transfer time */
itime = atime - xtime; /* time not transferring (seek time) */
if (xtime < 0)
--- 89,99 -----
atime = s.dk_time[dn];
atime /= (float) hz;
words = s.dk_wds[dn]*32.0; /* number of 16 bit words transferred */
! #ifdef sun
! xtime = words*2/s.dk_bps[dn];
! #else sun
! xtime = s.dk_mspw[dn]*words; /* transfer time */
! #endif sun
itime = atime - xtime; /* time not transferring (seek time) */
if (xtime < 0)
diff -c org/mon.c sun/mon.c
*** org/mon.c Tue Dec 11 23:24:20 1984
--- sun/mon.c Tue Dec 11 23:47:47 1984
***************
*** 19,25
*/
struct nlist namelist[] = {
{ "_dk_busy" },
{ "_dk_mspw" },
{ "_hz" },
{ "_cp_time" },
{ "_rate" },
--- 19,29 -----
*/
struct nlist namelist[] = {
{ "_dk_busy" },
! #ifdef sun
! { "_dk_bps" },
! #else sun
! { "_dk_mspw" },
! #endif sun
{ "_hz" },
{ "_cp_time" },
{ "_rate" },
***************
*** 35,40
{ "_tk_nin" },
{ "_tk_nout" },
{ "_avenrun" },
#ifdef DUALCPU
{ "_cp2_time" }, /* 2nd CPU stats */
{ "_slavestart" }, /* Used to detect 2nd CPU */
--- 39,45 -----
{ "_tk_nin" },
{ "_tk_nout" },
{ "_avenrun" },
+ { "_forkstat" },
#ifdef DUALCPU
{ "_cp2_time" }, /* 2nd CPU stats */
{ "_slavestart" }, /* Used to detect 2nd CPU */
***************
*** 70,77
/*
* do all things that need to be done only once
*/
! lseek(kmem, (long)namelist[X_DK_MSPW].n_value, 0);
! read(kmem, s.dk_mspw, sizeof s.dk_mspw);
lseek(kmem, (long)namelist[X_HZ].n_value, 0);
read(kmem, &hz, sizeof hz);
read_names();
--- 75,90 -----
/*
* do all things that need to be done only once
*/
! #ifdef sun
! lseek(kmem, (long)namelist[X_DK_BPS].n_value, 0);
! read(kmem, s.dk_bps, sizeof s.dk_bps);
! #else sun
! lseek(kmem, (long)namelist[X_DK_MSPW].n_value, 0);
! read(kmem, s.dk_mspw, sizeof s.dk_mspw);
! #endif sun
! /* prime the fork counters so we don't see forks since boot */
! lseek(kmem, (long)namelist[X_FORKSTAT].n_value, 0);
! read(kmem, &s1.forkstat, sizeof s1.forkstat);
lseek(kmem, (long)namelist[X_HZ].n_value, 0);
read(kmem, &hz, sizeof hz);
read_names();
***************
*** 113,119
/* get load average */
lseek(kmem, (long)namelist[LOADAV].n_value, 0);
read(kmem, &loadavg[0], sizeof loadavg);
! mvprintw(0,13,"%4.2f %4.2f %4.2f %4.2f", loadavg[3], loadavg[0], loadavg[1], loadavg[2]);
time(&clock);
mvprintw(0,40,ctime(&clock));
dispupdate();
--- 123,135 -----
/* get load average */
lseek(kmem, (long)namelist[LOADAV].n_value, 0);
read(kmem, &loadavg[0], sizeof loadavg);
! #ifdef sun
! mvprintw(0,13,"%4.2f %4.2f %4.2f",
! loadavg[0]/256., loadavg[1]/256., loadavg[2]/256.);
! #else sun
! mvprintw(0,13,"%4.2f %4.2f %4.2f %4.2f",
! loadavg[3], loadavg[0], loadavg[1], loadavg[2]);
! #endif sun
time(&clock);
mvprintw(0,40,ctime(&clock));
dispupdate();
diff -c org/mon.h sun/mon.h
*** org/mon.h Tue Dec 11 23:38:35 1984
--- sun/mon.h Tue Dec 11 23:51:25 1984
***************
*** 16,22
* definition of namelist in main.
*/
#define X_DK_BUSY 0
! #define X_DK_MSPW 1
#define X_HZ 2
#define X_CP_TIME 3
#define X_RATE 4
--- 16,26 -----
* definition of namelist in main.
*/
#define X_DK_BUSY 0
! #ifdef sun
! #define X_DK_BPS 1
! #else sun
! #define X_DK_MSPW 1
! #endif sun
#define X_HZ 2
#define X_CP_TIME 3
#define X_RATE 4
***************
*** 32,37
#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 */
--- 36,42 -----
#define X_TK_NIN 14
#define X_TK_NOUT 15
#define LOADAV 16
+ #define X_FORKSTAT 17
#ifdef DUALCPU
#define X_CP_TIME2 18 /* 2nd CPU stats */
#define X_SLAVESTART 19 /* 2nd cpu existance test */
***************
*** 33,40
#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
extern struct nlist namelist[];
--- 38,45 -----
#define LOADAV 16
#define X_FORKSTAT 17
#ifdef DUALCPU
! #define X_CP_TIME2 18 /* 2nd CPU stats */
! #define X_SLAVESTART 19 /* 2nd cpu existance test */
#endif DUALCPU
extern struct nlist namelist[];
***************
*** 46,52
int kmem, hz;
int deficit;
double etime;
! double loadavg[4];
/* drive names and numbers */
char dr_name[DK_NDRIVE][10];
--- 51,61 -----
int kmem, hz;
int deficit;
double etime;
! #ifdef sun
! long loadavg[3];
! #else sun
! double loadavg[4];
! #endif sun
/* drive names and numbers */
char dr_name[DK_NDRIVE][10];
***************
*** 88,94
long dk_wds[DK_NDRIVE];
long dk_seek[DK_NDRIVE];
long dk_xfer[DK_NDRIVE];
! float dk_mspw[DK_NDRIVE];
long tk_nin;
long tk_nout;
struct vmmeter Rate;
--- 97,107 -----
long dk_wds[DK_NDRIVE];
long dk_seek[DK_NDRIVE];
long dk_xfer[DK_NDRIVE];
! #ifdef sun
! long dk_bps[DK_NDRIVE];
! #else sun
! float dk_mspw[DK_NDRIVE];
! #endif sun
long tk_nin;
long tk_nout;
struct vmmeter Rate;
***************
*** 93,98
long tk_nout;
struct vmmeter Rate;
struct vmtotal Total;
} s, s1;
#define rate s.Rate
--- 106,112 -----
long tk_nout;
struct vmmeter Rate;
struct vmtotal Total;
+ struct forkstat forkstat;
} s, s1;
#define rate s.Rate
***************
*** 109,113
#define CHARY 5
#define CHARX 37
#define NETIFY 17
! #define DISKY 2
#define DISKX 55
--- 123,129 -----
#define CHARY 5
#define CHARX 37
#define NETIFY 17
! #define DISKY 5
#define DISKX 55
#define FORKY 2
#define FORKX 55
***************
*** 111,113
#define NETIFY 17
#define DISKY 2
#define DISKX 55
--- 125,129 -----
#define NETIFY 17
#define DISKY 5
#define DISKX 55
+ #define FORKY 2
+ #define FORKX 55
diff -c org/readnames.c sun/readnames.c
*** org/readnames.c Tue Dec 11 23:05:00 1984
--- sun/readnames.c Tue Dec 11 22:52:53 1984
***************
*** 6,13
*/
#include "mon.h"
#include <sys/buf.h> /* needed by following two includes */
! #include <vaxuba/ubavar.h> /* unibus adapters */
! #include <vaxmba/mbavar.h> /* massbus adapters */
#define steal(where, var) lseek(kmem, where, 0); read(kmem, &var, sizeof var);
--- 6,18 -----
*/
#include "mon.h"
#include <sys/buf.h> /* needed by following two includes */
! #ifdef vax
! #include <vaxuba/ubavar.h> /* unibus adapters */
! #include <vaxmba/mbavar.h> /* massbus adapters */
! #endif vax
! #ifdef sun
! #include <sundev/mbvar.h> /* multibus */
! #endif sun
#define steal(where, var) lseek(kmem, where, 0); read(kmem, &var, sizeof var);
***************
*** 13,18
read_names()
{
struct mba_device mdev;
register struct mba_device *mp;
struct mba_driver mdrv;
--- 18,24 -----
read_names()
{
+ #ifdef vax
struct mba_device mdev;
register struct mba_device *mp;
struct mba_driver mdrv;
***************
*** 16,21
struct mba_device mdev;
register struct mba_device *mp;
struct mba_driver mdrv;
short two_char;
char *cp = (char *) &two_char;
struct uba_device udev, *up;
--- 22,33 -----
struct mba_device mdev;
register struct mba_device *mp;
struct mba_driver mdrv;
+ #endif vax
+ #ifdef sun
+ struct mb_device mdev;
+ register struct mb_device *mp;
+ struct mb_driver mdrv;
+ #endif sun
short two_char;
char *cp = (char *) &two_char;
#ifdef vax
***************
*** 18,23
struct mba_driver mdrv;
short two_char;
char *cp = (char *) &two_char;
struct uba_device udev, *up;
struct uba_driver udrv;
--- 30,36 -----
#endif sun
short two_char;
char *cp = (char *) &two_char;
+ #ifdef vax
struct uba_device udev, *up;
struct uba_driver udrv;
***************
*** 45,48
sprintf(dr_name[udev.ui_dk], "%c%c%d", cp[0], cp[1], udev.ui_unit);
dr_unit[udev.ui_dk] = udev.ui_unit;
}
}
--- 58,76 -----
sprintf(dr_name[udev.ui_dk], "%c%c%d", cp[0], cp[1], udev.ui_unit);
dr_unit[udev.ui_dk] = udev.ui_unit;
}
+ #endif vax
+ #ifdef sun
+ mp = (struct mb_device *) namelist[X_MBDINIT].n_value;
+ if (mp) for (;;) {
+ steal(mp++, mdev);
+ if (mdev.md_driver == 0)
+ break;
+ if (mdev.md_dk < 0 || mdev.md_alive == 0)
+ continue;
+ steal(mdev.md_driver, mdrv);
+ steal(mdrv.mdr_dname, two_char);
+ sprintf(dr_name[mdev.md_dk], "%c%c%d", cp[0], cp[1], mdev.md_unit);
+ dr_unit[mdev.md_dk] = mdev.md_unit;
+ }
+ #endif sun
}
diff -c org/vm.c sun/vm.c
*** org/vm.c Tue Dec 11 23:33:33 1984
--- sun/vm.c Tue Dec 11 23:43:37 1984
***************
*** 27,34
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);
read(kmem, &rate, sizeof rate);
lseek(kmem, (long)namelist[X_TOTAL].n_value, 0);
--- 27,32 -----
read(kmem, s.cp_time2, sizeof s.cp_time2);
}
#endif DUALCPU
lseek(kmem, (long)namelist[X_RATE].n_value, 0);
read(kmem, &rate, sizeof rate);
lseek(kmem, (long)namelist[X_TOTAL].n_value, 0);
***************
*** 35,40
read(kmem, &total, sizeof total);
lseek(kmem, (long)namelist[X_DEFICIT].n_value, 0);
read(kmem, &deficit, sizeof deficit);
etime = 0;
for (i=0; i < CPUSTATES; i++) {
t = s.cp_time[i];
--- 33,40 -----
read(kmem, &total, sizeof total);
lseek(kmem, (long)namelist[X_DEFICIT].n_value, 0);
read(kmem, &deficit, sizeof deficit);
+ lseek(kmem, (long)namelist[X_FORKSTAT].n_value, 0);
+ read(kmem, &s.forkstat, sizeof s.forkstat);
etime = 0;
for (i=0; i < CPUSTATES; i++) {
t = s.cp_time[i];
***************
*** 73,79
, pgtok(deficit), rate.v_scan);
/* Display CPU info */
! mvprintw(CPUY+1,5,"%4d %4d", (rate.v_intr) - hz, rate.v_syscall);
mvprintw(CPUY+1,17,"%4d", rate.v_swtch);
#ifdef DUALCPU
if (dualcpu)
--- 73,83 -----
, pgtok(deficit), rate.v_scan);
/* Display CPU info */
! #ifdef sun
! mvprintw(CPUY+1,5,"%4d %4d", rate.v_intr, rate.v_syscall);
! #else
! mvprintw(CPUY+1,5,"%4d %4d", (rate.v_intr) - hz, rate.v_syscall);
! #endif sun
mvprintw(CPUY+1,17,"%4d", rate.v_swtch);
#ifdef DUALCPU
if (dualcpu)
***************
*** 80,85
mvprintw(CPUY+1,30,"%4d", rate.v_swtch2);
#endif DUALCPU
cputime();
/* Display additional stuff */
mvprintw(PAGEY+4,6,"%4d%4d %4d%4d %4d%4d %4d %4d%4d",
--- 84,98 -----
mvprintw(CPUY+1,30,"%4d", rate.v_swtch2);
#endif DUALCPU
cputime();
+ /* Display FORK info */
+ t = s.forkstat.cntfork;
+ s.forkstat.cntfork -= s1.forkstat.cntfork;
+ s1.forkstat.cntfork = t;
+ t = s.forkstat.cntvfork;
+ s.forkstat.cntvfork -= s1.forkstat.cntvfork;
+ s1.forkstat.cntvfork = t;
+ mvprintw(FORKY+1,FORKX+6,"%5d %5d",
+ s.forkstat.cntfork, s.forkstat.cntvfork);
/* Display additional stuff */
mvprintw(PAGEY+4,6,"%4d%4d %4d%4d %4d%4d %4d %4d%4d",
More information about the Comp.sources.bugs
mailing list