System Monitoring Program (MON)
Guy Harris
guy at rlgvax.UUCP
Sun Dec 9 12:02:05 AEST 1984
Here are some fixes and changes to "mon.c"; the context diffs are based on
the changes posted by Jonathan Biggar in article <1533 at sdcrdcf.UUCP>.
Guy Harris
{seismo,ihnp4,allegra}!rlgvax!guy
Working file: display.c
Moved the definitions of the screen positions of various fields into "mon.h".
Moved some column headings around to align them with their columns.
Fixed to limit the number of disks and network interfaces listed to the number
that will fit on all but the last line of the screen.
*** /tmp/,RCSt1a06329 Sat Dec 8 20:54:39 1984
--- display.c Sat Dec 8 20:54:40 1984
***************
*** 8,25
#define HOSTLEN 40 /* Length of hostname */
- /* Screen Positions */
- #define LEFT 0
- #define PROCY 2
- #define CPUY 5
- #define TIMEY 8
- #define PAGEY 11
- #define CHARY 5
- #define CHARX 37
- #define NETIFY 17
- #define DISKY 2
- #define DISKX 55
-
/*
* DISPINIT - clears the screen, puts up the info labels, and
* displays the initial information (device names).
--- 8,13 -----
#define HOSTLEN 40 /* Length of hostname */
/*
* DISPINIT - clears the screen, puts up the info labels, and
* displays the initial information (device names).
***************
*** 41,47
if (dualcpu)
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");
--- 29,35 -----
if (dualcpu)
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");
***************
*** 44,50
mvprintw(TIMEY,LEFT,"Time: user nice sys idle");
#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");
--- 32,38 -----
mvprintw(TIMEY,LEFT,"Time: user nice sys idle");
#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");
***************
*** 49,55
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 */
for(i = 0; i < DK_NDRIVE; i++) {
--- 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(NETIFY,LEFT,"Name Ipkts Ierrs Opkts Oerrs Collis Oqueue");
/* add the disk drive names to the screen */
for(i = 0; i < DK_NDRIVE && DISKY+1+i < LINES-3; i++) {
***************
*** 52,58
mvprintw(NETIFY,LEFT,"Name Ipkts Ierrs Opkts Oerrs Collis Oqueue");
/* add the disk drive names to the screen */
! for(i = 0; i < DK_NDRIVE; i++) {
if (*dr_name[i])
mvprintw(DISKY+1+i,DISKX,dr_name[i]);
else
--- 40,46 -----
mvprintw(NETIFY,LEFT,"Name Ipkts Ierrs Opkts Oerrs Collis Oqueue");
/* add the disk drive names to the screen */
! for(i = 0; i < DK_NDRIVE && DISKY+1+i < LINES-3; i++) {
if (*dr_name[i])
mvprintw(DISKY+1+i,DISKX,dr_name[i]);
else
***************
*** 62,68
mvprintw(DISKY+2+i,DISKX,"Total:");
/* put up the network interface names */
! for (i = 0; i < numif; i++)
mvprintw(NETIFY+1+i,LEFT,nifinfo[i].name);
}
--- 50,56 -----
mvprintw(DISKY+2+i,DISKX,"Total:");
/* put up the network interface names */
! for (i = 0; i < numif && NETIFY+1+i < LINES-1; i++)
mvprintw(NETIFY+1+i,LEFT,nifinfo[i].name);
}
***************
*** 73,79
{
int i;
! for (i = 0; i < numif; i++)
mvprintw(NETIFY+1+i,LEFT+7,"%5d %5d %5d %5d %5d %5d",
nifdat[i].ipackets, nifdat[i].ierrors,
nifdat[i].opackets, nifdat[i].oerrors,
--- 61,67 -----
{
int i;
! for (i = 0; i < numif && NETIFY+1+i < LINES-1; i++)
mvprintw(NETIFY+1+i,LEFT+7,"%5d %5d %5d %5d %5d %5d",
nifdat[i].ipackets, nifdat[i].ierrors,
nifdat[i].opackets, nifdat[i].oerrors,
Working file: io.c
Moved the definitions of the screen positions of various fields into "mon.h".
Moved some columns around, and shortened some, to align them with their column
headings.
Fixed to limit the number of disks listed to the number that will fit on all
but the last line of the screen.
*** /tmp/,RCSt1a06338 Sat Dec 8 20:54:56 1984
--- io.c Sat Dec 8 20:46:43 1984
***************
*** 13,23
/* Temporary Defines - All output should be moved to dispinfo */
#include <curses.h>
! #define CHARX 37
! #define CHARY 5
! #define DISKX 55
! #define DISKY 2
! #define DISKOFF 6
#define DISKWDS DISKOFF
#define DISKXFER DISKOFF+4
#define DISKSEEK DISKOFF+8
--- 13,19 -----
/* Temporary Defines - All output should be moved to dispinfo */
#include <curses.h>
! #define DISKOFF 7
#define DISKWDS DISKOFF
#define DISKXFER DISKOFF+4
#define DISKSEEK DISKOFF+8
***************
*** 81,86
if (!*dr_name[dn])
return(0);
y = dn + DISKY+1;
lasty = y;
if (s.dk_mspw[dn] == 0.0) {
--- 77,83 -----
if (!*dr_name[dn])
return(0);
+ /* only display info that fits on the screen */
y = dn + DISKY+1;
if (y >= LINES-3)
return(0);
***************
*** 82,87
return(0);
y = dn + DISKY+1;
lasty = y;
if (s.dk_mspw[dn] == 0.0) {
mvprintw(y,DISKX+DISKOFF,"%4.0f%4.0f%6.1f ", 0.0, 0.0, 0.0);
--- 79,87 -----
/* only display info that fits on the screen */
y = dn + DISKY+1;
+ if (y >= LINES-3)
+ 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);
***************
*** 84,90
y = dn + DISKY+1;
lasty = y;
if (s.dk_mspw[dn] == 0.0) {
! mvprintw(y,DISKX+DISKOFF,"%4.0f%4.0f%6.1f ", 0.0, 0.0, 0.0);
return(0);
}
atime = s.dk_time[dn];
--- 84,90 -----
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);
}
atime = s.dk_time[dn];
***************
*** 103,109
tps = s.dk_xfer[dn]/etime;
mvprintw(y,DISKX+DISKWDS,"%4.0f", kbps);
mvprintw(y,DISKX+DISKXFER,"%4.0f", tps);
! mvprintw(y,DISKX+DISKSEEK,"%6.1f ",
s.dk_seek[dn] ? itime*1000./s.dk_seek[dn] : 0.0);
return(1); /* Update totals */
--- 103,109 -----
tps = s.dk_xfer[dn]/etime;
mvprintw(y,DISKX+DISKWDS,"%4.0f", kbps);
mvprintw(y,DISKX+DISKXFER,"%4.0f", tps);
! mvprintw(y,DISKX+DISKSEEK,"%5.1f",
s.dk_seek[dn] ? itime*1000./s.dk_seek[dn] : 0.0);
return(1); /* Update totals */
Working file: mon.c
Removed the definition of "ttyb" because it wasn't used anymore and caused
it not to compile with our S5 tty driver.
Fixed to put the terminal into no-echo mode.
Moved the command prompt to the defined bottom of the screen rather than line
23.
Fixed to clear the command prompt line when exiting.
*** /tmp/,RCSt1a06349 Sat Dec 8 20:55:13 1984
--- mon.c Sat Dec 8 20:48:31 1984
***************
*** 10,16
#include <curses.h>
#include <signal.h>
- struct sgttyb ttyb;
int done();
/*
--- 10,15 -----
#include <curses.h>
#include <signal.h>
int done();
/*
***************
*** 104,109
tintv.tv_usec = 0;
initscr(); /* init curses package */
crmode(); /* set terminal into cbreak mode */
nifinit(); /* get initial net interfaces data */
dispinit(); /* initialize display */
for(;;){
--- 103,109 -----
tintv.tv_usec = 0;
initscr(); /* init curses package */
crmode(); /* set terminal into cbreak mode */
+ noecho(); /* set terminal into no-echo mode */
nifinit(); /* get initial net interfaces data */
dispinit(); /* initialize display */
for(;;){
***************
*** 117,123
time(&clock);
mvprintw(0,40,ctime(&clock));
dispupdate();
! mvprintw(23, 0, "CMD> ");
refresh();
tin = 1;
i = select(2, &tin, (int *)0, (int *)0, &tintv);
--- 117,123 -----
time(&clock);
mvprintw(0,40,ctime(&clock));
dispupdate();
! mvprintw(LINES-1, 0, "CMD> ");
refresh();
tin = 1;
i = select(2, &tin, (int *)0, (int *)0, &tintv);
***************
*** 132,138
}
/*
! * DONE - put the term back in non CBREAK mode and exit.
*/
done()
{
--- 132,138 -----
}
/*
! * DONE - put the term back in ECHO, non CBREAK mode and exit.
*/
done()
{
***************
*** 136,141
*/
done()
{
refresh();
endwin();
exit(0);
--- 136,142 -----
*/
done()
{
+ mvprintw(LINES-1,0,"\n");
refresh();
endwin();
exit(0);
Working file: mon.h
Moved the definitions of the screen positions of various fields into "mon.h".
*** /tmp/,RCSt1a06363 Sat Dec 8 20:55:41 1984
--- mon.h Sat Dec 8 20:49:41 1984
***************
*** 96,98
#define rate s.Rate
#define total s.Total
--- 96,112 -----
#define rate s.Rate
#define total s.Total
+
+ /*
+ * Positions of various data on the screen.
+ */
+ #define LEFT 0
+ #define PROCY 2
+ #define CPUY 5
+ #define TIMEY 8
+ #define PAGEY 11
+ #define CHARY 5
+ #define CHARX 37
+ #define NETIFY 17
+ #define DISKY 2
+ #define DISKX 55
Working file: vm.c
Moved the definitions of the screen positions of various fields into "mon.h",
and changed PROCS to PROCY and PAGE to PAGEY because that's what they're called
in the definitions from "display.c".
Moved some columns around to align them with their column headings.
*** /tmp/,RCSt1a06370 Sat Dec 8 20:55:59 1984
--- vm.c Sat Dec 8 20:52:02 1984
***************
*** 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;
***************
*** 60,66
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) );
***************
*** 62,70
/* 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",
***************
*** 67,73
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),
***************
*** 70,76
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)+
***************
*** 73,79
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);
***************
*** 75,81
/* 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 */
***************
*** 79,85
, 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);
#ifdef DUALCPU
if (dualcpu)
--- 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)
***************
*** 88,94
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,
--- 82,88 -----
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,
***************
*** 115,121
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);
#ifdef DUALCPU
--- 109,115 -----
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
More information about the Comp.sources.bugs
mailing list