wht@n4hgf.UUCP (Warren Tucker) (07/16/90)
Posting-number: Volume 14, Issue 3 Submitted-by: wht@n4hgf.UUCP (Warren Tucker) Archive-name: u386mon-2.0/part03 #!/bin/sh # This is part 03 of u386mon.2.0 if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= proc.c ============== echo "x - extracting proc.c (Text)" sed 's/^X//' << 'SHAR_EOF' > proc.c && X/* CHK=0x9B13 */ X/*+------------------------------------------------------------------------- X proc.c - u386mon proc table functions X X Defined functions: X display_proc(win,y,x) X grok_proc() X pstat_text(pstat) X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:07-11-1990-03:45-root@n4hgf-faster proc table manipulation */ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */ X/*:06-17-1990-16:46-wht-creation */ X X#define M_TERMINFO X X#include <curses.h> X#include <panel.h> X#include <sys/types.h> X#undef NGROUPS_MAX X#undef NULL X#include <sys/param.h> X#include <sys/immu.h> X#include <sys/region.h> X#include <sys/proc.h> X#include <sys/var.h> X#include <nlist.h> X#include "nlsym.h" X#include "libkmem.h" X#include "libnlsym.h" X#include "u386mon.h" X Xextern struct var v; X Xstruct proc *procs = (struct proc *)0; Xstruct proc *oldprocs = (struct proc *)0; Xstruct proc **pprocs = (struct proc **)0; Xstruct proc **poldprocs = (struct proc **)0; X Xint procs_per_pstat[SXBRK + 1]; Xint procs_in_core; Xint procs_alive; X X/*+------------------------------------------------------------------------- X pstat_text(pstat) X--------------------------------------------------------------------------*/ Xchar * Xpstat_text(pstat) Xchar pstat; X{ Xstatic char errant[10]; X X switch(pstat) X { X case SSLEEP: return("sleep "); X case SRUN: return("run "); X case SZOMB: return("zombie"); X case SSTOP: return("stop "); X case SIDL: return("idle "); X case SONPROC: return("onproc"); X case SXBRK: return("xbrk "); X } X (void)sprintf(errant,"%06u?",(unsigned char)pstat); X return(errant); X X} /* end of pstat_text */ X X/*+------------------------------------------------------------------------- X grok_proc() - read and examine kernel process table X--------------------------------------------------------------------------*/ Xvoid Xgrok_proc() X{ Xregister iproc; Xregister struct proc *tproc; Xstatic char *memfail = "cannot alloc memory for proc table"; X X if(!procs) X { X if(!(procs = (struct proc *)malloc(sizeof(struct proc) * v.v_proc))) X leave_text(memfail,1); X if(!(oldprocs = (struct proc *)malloc(sizeof(struct proc) * v.v_proc))) X leave_text(memfail,1); X if(!(pprocs = (struct proc **)malloc(sizeof(struct proc *) * v.v_proc))) X leave_text(memfail,1); X if(!(poldprocs=(struct proc **)malloc(sizeof(struct proc *)*v.v_proc))) X leave_text(memfail,1); X } X kread((caddr_t)procs,procaddr,sizeof(struct proc) * v.v_proc); X for(iproc = 0; iproc < SXBRK + 1; iproc++) X procs_per_pstat[iproc] = 0; X procs_in_core = 0; X procs_alive = 0; X X for(iproc = 0; iproc < v.v_proc; iproc++) X { X tproc = pprocs[iproc] = (procs + iproc); X X if(tproc->p_stat) X procs_alive++; X X procs_per_pstat[tproc->p_stat]++; /* count # procs in each state */ X X if(tproc->p_flag & SLOAD) /* count # procs in memory */ X procs_in_core++; X } X X} /* end of grok_proc */ X X/*+------------------------------------------------------------------------- X display_proc(win,y,x) X--------------------------------------------------------------------------*/ Xvoid Xdisplay_proc(win,y,x) XWINDOW *win; Xint y; Xint x; X{ Xregister istat; X X grok_proc(); X X use_cp(win,cpBANNER); X wmove(win,y++,x); X waddstr(win,"-- Proc ---"); X for(istat = SSLEEP; istat <= SXBRK; istat++) X { X wmove(win,y++,x); X disp_info_int(win,pstat_text(istat)," %3d",procs_per_pstat[istat]); X } X wmove(win,y++,x); X disp_info_int(win,"total "," %3d",procs_alive); X wmove(win,y++,x); X disp_info_int(win,"in mem"," %3d",procs_in_core); X} /* end of display_proc */ X X/* vi: set tabstop=4 shiftwidth=4: */ X/* end of proc.c */ SHAR_EOF $TOUCH -am 0715025190 proc.c && chmod 0644 proc.c || echo "restore of proc.c failed" set `wc -c proc.c`;Wc_c=$1 if test "$Wc_c" != "3815"; then echo original size 3815, current size $Wc_c fi # ============= tune.c ============== echo "x - extracting tune.c (Text)" sed 's/^X//' << 'SHAR_EOF' > tune.c && X/* CHK=0xECB8 */ X/*+------------------------------------------------------------------------- X tune.c - u386mon tune struct display X X Defined functions: X display_tune(win,y,x) X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-25-1990-17:33-wht@n4hgf-alpha sort identifiers */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */ X/*:06-17-1990-14:59-wht-creation */ X X#define M_TERMINFO X X#include <curses.h> X#include <panel.h> X#include <sys/types.h> X#include <sys/tuneable.h> X#include "u386mon.h" X X/*+------------------------------------------------------------------------- X display_tune(win,y,x) X--------------------------------------------------------------------------*/ Xvoid Xdisplay_tune(win,y,x) XWINDOW *win; Xint y; Xint x; X{ X X use_cp(win,cpBANNER); X wmove(win,y++,x); X waddstr(win,"-- Tune ---------"); X wmove(win,y++,x); X disp_static_int(win,"t_ageintvl ","%5d",tune.t_ageinterval); X wmove(win,y++,x); X disp_static_int(win,"t_bdflushr ","%5d",tune.t_bdflushr); X wmove(win,y++,x); X disp_static_int(win,"t_gpgshi ","%5d",tune.t_gpgshi); X wmove(win,y++,x); X disp_static_int(win,"t_gpgslo ","%5d",tune.t_gpgslo); X wmove(win,y++,x); X disp_static_int(win,"t_gpgsmsk ","0x%03lx",tune.t_gpgsmsk); X wmove(win,y++,x); X disp_static_int(win,"t_maxfc ","%5d",tune.t_maxfc); X wmove(win,y++,x); X disp_static_int(win,"t_maxsc ","%5d",tune.t_maxsc); X wmove(win,y++,x); X disp_static_int(win,"t_maxumem ","%5d",tune.t_maxumem); X wmove(win,y++,x); X disp_static_int(win,"t_minarmem ","%5d",tune.t_minarmem); X wmove(win,y++,x); X disp_static_int(win,"t_minasmem ","%5d",tune.t_minasmem); X X} /* end of display_tune */ X X/* vi: set tabstop=4 shiftwidth=4: */ X/* end of tune.c */ SHAR_EOF $TOUCH -am 0715025190 tune.c && chmod 0644 tune.c || echo "restore of tune.c failed" set `wc -c tune.c`;Wc_c=$1 if test "$Wc_c" != "1956"; then echo original size 1956, current size $Wc_c fi # ============= u386mon.c ============== echo "x - extracting u386mon.c (Text)" sed 's/^X//' << 'SHAR_EOF' > u386mon.c && X/* CHK=0x0852 */ Xchar *revision = "2.00"; X/*+------------------------------------------------------------------------- X u386mon.c - UNIX 386 system monitor X X Defined functions: X adb_trap() X calc_cpu_avg(per_state) X calc_wait_avg(per_state) X caught_signal(sig) X draw_cpuscale_literals(win,y,x) X draw_per_sec_literals(win,y,x) X draw_waitscale_literals(win,y,x) X extra_info_stuff() X extra_static_stuff() X get_cpu_avg(cpu_ticks,period) X get_elapsed_time(elapsed_seconds) X get_wait_avg(wait_ticks,period) X leave(exit_code) X leave_text(text,exit_code) X leaving(exit_code) X main(argc,argv,envp) X update_cpuscale(win,y,x,width,per_state) X update_waitscale(win,y,x,width,per_state,total_ticks) X X00000000001111111111222222222233333333334444444444555555555566666666667777777777 X01234567890123456789012345678901234567890123456789012345678901234567890123456789 X u386mon xxx.xxx PLOCK INVALID hh:mm:ss wht@n4hgf X X---- CPU --- tot usr ker brk --------------------------------------------------- X Instant % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X 5 Sec Avg % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X10 Sec Avg % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X---- Wait -- tot io pio swp --------------------------------------------------- X Instant % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X 5 Sec Avg % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X10 Sec Avg % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:07-11-1990-03:45-root@n4hgf-faster proc table manipulation */ X/*:07-10-1990-19:06-root@n4hgf-redesign attributes/color pairs */ X/*:07-10-1990-18:33-root@n4hgf-move pio wait to medium alert */ X/*:07-10-1990-18:01-root@n4hgf-"improvement" didnt do much, but leave for now */ X/*:07-10-1990-13:54-root@n4hgf-improve nap heuristics and catch signals */ X/*:07-08-1990-20:31-root@n4hgf-make room for phread/phwrite */ X/*:07-03-1990-02:48-root@n4hgf-more accurate timing using ftime calculations */ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-27-1990-01:07-wht@n4hgf-add ^R and ^L refresh */ X/*:06-25-1990-17:34-wht@n4hgf-add detail extra for 25 line tubes */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */ X/*:06-15-1990-18:32-wht@n4hgf-creation */ X X#define M_TERMINFO X X#include <curses.h> X#undef timeout /* conflict in curses.h and bootinfo.h per trb@ima.ima.isc.com */ X#include <panel.h> X#include <signal.h> X#include <string.h> X#include <fcntl.h> X#include <nlist.h> X#include <errno.h> X#include <time.h> X#include <sys/types.h> X#include <sys/timeb.h> X#include <sys/lock.h> X#include <sys/utsname.h> X#include <sys/stat.h> X#include <sys/ascii.h> X#undef NGROUPS_MAX X#undef NULL X#include <sys/param.h> X#include <sys/bootinfo.h> X#include <sys/tuneable.h> X#include <sys/sysinfo.h> X#include <sys/sysmacros.h> X#include <sys/immu.h> X#include <sys/region.h> X#include <sys/proc.h> X#include <sys/var.h> X#include "nlsym.h" X#include "libkmem.h" X#include "libmem.h" X#include "libswap.h" X#include "libnlsym.h" X#include "u386mon.h" X Xlong nap(); XPANEL *mkpanel(); X X#define delta_msec(t,t0) ((( t.time * 1000L) + t.millitm) - \ X ((t0.time * 1000L) + t0.millitm)) X Xstruct sysinfo sysinfo; Xstruct sysinfo sysinfo_last; X#define sysidelta(x) (sysinfo.x - sysinfo_last.x) X Xstruct minfo minfo; Xstruct minfo minfo_last; X#define midelta(x) (minfo.x - minfo_last.x) X Xstruct bootinfo bootinfo; Xstruct tune tune; Xstruct utsname utsname; Xstruct var v; Xstruct timeb timeb_cycle_start; Xstruct timeb timeb_cycle_end; Xstruct timeb timeb_info_read; Xstruct timeb timeb_last_info_read; Xint hz; Xint nswap; Xint maxmem; Xint freemem; Xdaddr_t myreadcnt = 0L; Xint stat_period_msec_y = -1; Xint stat_period_msec_x = -1; Xint color_avail; X XPANEL *pscr; XWINDOW *wscr; Xextern WINDOW *wdet; X X#define CPU_AVG_MAX 10 Xint cpu_avg_init = 0; Xtime_t *cpu_avg[CPU_AVG_MAX]; Xtime_t cpu_ticks[5]; X X#define WAIT_AVG_MAX 10 Xint wait_avg_init = 0; Xtime_t *wait_avg[WAIT_AVG_MAX]; Xtime_t wait_ticks[5]; X X/*+------------------------------------------------------------------------- X leaving() - perform leave() basic processing and return X--------------------------------------------------------------------------*/ Xvoid Xleaving() X{ X wmove(wscr,CMD_TLY,0); X use_cp(wscr,cpLIT); X wclrtoeol(wscr); X pflush(); X endwin(); X} /* end of leaving */ X X/*+------------------------------------------------------------------------- X leave(exit_code) - leave program with exit code X--------------------------------------------------------------------------*/ Xvoid Xleave(exit_code) Xint exit_code; X{ X leaving(); X exit(exit_code); X} /* end of leave */ X X/*+------------------------------------------------------------------------- X leave_text(text,exit_code) - leave program with message and exit code XIf exit_code == 255, do wperror X--------------------------------------------------------------------------*/ Xvoid Xleave_text(text,exit_code) Xchar *text; Xint exit_code; X{ X if(exit_code == 255) X { X int y; X register x; X extern int errno; X extern int sys_nerr; X extern char *sys_errlist[]; X X top_panel(pscr); X wmove(wscr,MSG_TLY - 2,0); X use_cp(wscr,cpHIGH); X x = 0; X while(x++ < COLS) X waddch(wscr,(chtype)' '); X wmove(wscr,MSG_TLY - 1,0); X wprintw(wscr,"errno %d",errno); X if(errno < sys_nerr) X wprintw(wscr,": %s",sys_errlist[errno]); X getyx(wscr,y,x); X while(x++ < COLS) X waddch(wscr,(chtype)' '); X } X disp_msg(cpHIGH,text); X leave(exit_code); X} /* end of leave_text */ X X/*+------------------------------------------------------------------------- X adb_trap() - convenient trap for catching abort X--------------------------------------------------------------------------*/ X#ifdef DEBUG Xvoid Xadb_trap() X{ X printf("too bad .... goodbye\n"); X} /* end of adb_trap */ X#endif X X/*+------------------------------------------------------------------------- X caught_signal(sig) - SIGHUP thru SIGSYS: leave with possible abort X--------------------------------------------------------------------------*/ Xvoid Xcaught_signal(sig) Xint sig; X{ X leaving(); X switch(sig) X { X case SIGQUIT: X case SIGILL: X case SIGTRAP: X case SIGIOT: X case SIGEMT: X case SIGFPE: X case SIGBUS: X case SIGSEGV: X case SIGSYS: X#ifdef DEBUG X adb_trap(); /* if debugging, stop at convenient breakpoint */ X#endif X abort(); X } X exit(200); X} /* end of caught_signal */ X X/*+----------------------------------------------------------------------- X char *get_elapsed_time(elapsed_seconds) - "ddd+hh:mm:ss" returned X static string address is returned X------------------------------------------------------------------------*/ Xchar * Xget_elapsed_time(elapsed_seconds) Xtime_t elapsed_seconds; X{ Xstatic char elapsed_time_str[32]; Xtime_t dd,hh,mm,ss; X X dd = 0; X hh = elapsed_seconds / 3600; X if(hh > 24) X { X dd = hh / 24; X elapsed_seconds -= dd * 3600 * 24; X hh %= 24; X } X elapsed_seconds -= hh * 3600; X mm = elapsed_seconds / 60L; X elapsed_seconds -= mm * 60L; X ss = elapsed_seconds; X X if(dd) X (void)sprintf(elapsed_time_str,"%3ld+%02ld:%02ld:%02ld",dd,hh,mm,ss); X else X (void)sprintf(elapsed_time_str," %2ld:%02ld:%02ld",hh,mm,ss); X return(elapsed_time_str); X} /* end of get_elapsed_time */ X X/*+------------------------------------------------------------------------- X draw_cpuscale_literals(win) X--------------------------------------------------------------------------*/ Xvoid Xdraw_cpuscale_literals(win,y,x) XWINDOW *win; Xint y; Xint x; X{ Xint x2 = x; X X wmove(win,y,x); X use_cp(wscr,cpBANNER); X waddstr(win,"---- CPU --- tot usr ker brk "); X getyx(win,y,x2); X while(x2 < COLS) X waddch(win,(chtype)'-'),x2++; X use_cp(wscr,cpLIT); X wmove(win,y + 1,x); X waddstr(win," Instant % "); X wmove(win,y + 2,x); X waddstr(win," 5 Sec Avg %"); X wmove(win,y + 3,x); X waddstr(win,"10 Sec Avg %"); X X} /* end of draw_cpuscale_literals */ X X/*+------------------------------------------------------------------------- X update_cpuscale(win,y,width,per_state) X X000000000011111111112222222222333333333344444444445555555555666666 X012345678901234567890123456789012345678901234567890123456789012345 Xtot usr ker misc X### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X--------------------------------------------------------------------------*/ X#define _CPUSCALE_TX 0 X#define _CPUSCALE_UX 4 X#define _CPUSCALE_KX 8 X#define _CPUSCALE_BX 12 X#define _CPUSCALE_SX 16 X Xtime_t Xupdate_cpuscale(win,y,x,width,per_state) XWINDOW *win; Xint y; Xint x; Xregister width; Xtime_t *per_state; X{ Xregister itmp; Xint accum = 0; Xtime_t idle = per_state[CPU_IDLE] + per_state[CPU_WAIT]; Xtime_t cpu_ticks_total = idle + per_state[CPU_SXBRK] + X per_state[CPU_IDLE] + per_state[CPU_KERNEL] + per_state[CPU_USER]; Xtime_t percent_user = (per_state[CPU_USER] * 100) / cpu_ticks_total; Xtime_t percent_kernel = (per_state[CPU_KERNEL] * 100) / cpu_ticks_total; Xtime_t percent_break = (per_state[CPU_SXBRK] * 100) / cpu_ticks_total; Xtime_t percent_busy = percent_user + percent_kernel + percent_break; X X if(!idle) /* take care of integer div truncation */ X percent_busy = 100; X X wmove(win,y, x + _CPUSCALE_TX); X if(percent_busy < 70) X use_cp(wscr,cpLOW); X else if(percent_busy < 90) X use_cp(wscr,cpMED); X else X use_cp(wscr,cpHIGH); X wprintw(win,"%3ld",percent_busy); X X wmove(win,y, x + _CPUSCALE_UX); X use_cp(wscr,cpINFO); X wprintw(win,"%3ld",percent_user); X X wmove(win,y, x + _CPUSCALE_KX); X wprintw(win,"%3ld",percent_kernel); X X wmove(win,y, x + _CPUSCALE_BX); X wprintw(win,"%3ld",percent_break); X X wmove(win,y, x + _CPUSCALE_SX); X X use_cp(wscr,cpLOW); X itmp = (width * percent_user) / 100; X accum += itmp; X while(itmp--) X waddch(win,(chtype)'u'); X X use_cp(wscr,cpMED); X itmp = (width * percent_kernel) / 100; X accum += itmp; X while(itmp--) X waddch(win,(chtype)'k'); X X use_cp(wscr,cpHIGH); X itmp = (width * percent_break) / 100; X accum += itmp; X while(itmp--) X waddch(win,(chtype)'b'); X X if((percent_busy > 98) && ((width - accum) > 0)) X { X waddch(win,(chtype)'*'); X accum++; X } X X if((itmp = (width - accum)) > 0) X { X while(itmp--) X waddch(win,(chtype)' '); X } X return(cpu_ticks_total); X} /* end of update_cpuscale */ X X/*+------------------------------------------------------------------------- X calc_cpu_avg(per_state) - add per_state array to avg array X--------------------------------------------------------------------------*/ Xvoid Xcalc_cpu_avg(per_state) Xtime_t per_state[]; X{ Xregister itmp; X X if(!cpu_avg_init) X { X for(itmp = 0; itmp < CPU_AVG_MAX; itmp++) X (void)memcpy(cpu_avg[itmp],per_state,sizeof(time_t) * 5); X cpu_avg_init = 1; X } X else X { X for(itmp = 0; itmp < CPU_AVG_MAX - 1; itmp++) X (void)memcpy(cpu_avg[itmp],cpu_avg[itmp + 1],sizeof(time_t) * 5); X (void)memcpy(cpu_avg[itmp],per_state,sizeof(time_t) * 5); X } X X} /* end of calc_cpu_avg */ X X/*+------------------------------------------------------------------------- X get_cpu_avg(cpu_ticks,period) X--------------------------------------------------------------------------*/ Xget_cpu_avg(cpu_ticks,period) Xtime_t cpu_ticks[]; Xint period; X{ Xregister iperiod = CPU_AVG_MAX; Xregister istate; Xregister count = period; X X for(istate = 0; istate < 5; istate++) X cpu_ticks[istate] = 0; X X while(count--) X { X iperiod--; X for(istate = 0; istate < 5; istate++) X { X cpu_ticks[istate] += (cpu_avg[iperiod])[istate]; X } X } X X for(istate = 0; istate < 5; istate++) X cpu_ticks[istate] /= period; X X} /* end of get_cpu_avg */ X X/*+------------------------------------------------------------------------- X draw_waitscale_literals(win) X--------------------------------------------------------------------------*/ Xvoid Xdraw_waitscale_literals(win,y,x) XWINDOW *win; Xint y; Xint x; X{ Xint x2 = x; X X wmove(win,y,x); X use_cp(wscr,cpBANNER); X waddstr(win,"---- Wait -- tot io pio swp -- (% of real time) "); X getyx(win,y,x2); X while(x2 < COLS) X waddch(win,(chtype)'-'),x2++; X use_cp(wscr,cpLIT); X wmove(win,y + 1,x); X waddstr(win," Instant % "); X wmove(win,y + 2,x); X waddstr(win," 5 Sec Avg %"); X wmove(win,y + 3,x); X waddstr(win,"10 Sec Avg %"); X X} /* end of draw_waitscale_literals */ X X/*+------------------------------------------------------------------------- X draw_per_sec_literals(win) X--------------------------------------------------------------------------*/ Xvoid Xdraw_per_sec_literals(win,y,x) XWINDOW *win; Xint y; Xint x; X{ X X wmove(win,y,x); X use_cp(wscr,cpBANNER); X waddstr(win,"---- Sysinfo/Minfo --- (last "); X getyx(win,stat_period_msec_y,stat_period_msec_x); X waddstr(win," 1000 msec activity) "); X getyx(win,y,x); X while(x < getmaxx(win)) X waddch(win,(chtype)'-'),x++; X X} /* end of draw_per_sec_literals */ X X/*+------------------------------------------------------------------------- X update_waitscale(win,y,width,per_state) X X000000000011111111112222222222333333333344444444445555555555666666 X012345678901234567890123456789012345678901234567890123456789012345 Xtot io pio swp X### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X--------------------------------------------------------------------------*/ X#define _WAITSCALE_TX 0 X#define _WAITSCALE_IX 4 X#define _WAITSCALE_PX 8 X#define _WAITSCALE_WX 12 X#define _WAITSCALE_SX 16 X Xtime_t Xupdate_waitscale(win,y,x,width,per_state,total_ticks) XWINDOW *win; Xint y; Xint x; Xregister width; Xtime_t *per_state; Xtime_t total_ticks; X{ Xregister itmp; Xint accum = 0; Xtime_t percent_io = 0L; Xtime_t percent_swap = 0L; Xtime_t percent_pio = 0L; Xtime_t percent_total_wait; Xtime_t total_wait; X X/* crock: because of latency, total_ticks < all wait ticks sometimes */ X total_wait = per_state[W_IO] + per_state[W_SWAP] + per_state[W_PIO]; X if(total_ticks < total_wait) X total_ticks = total_wait; X X if(total_ticks) X { X percent_io = (per_state[W_IO] * 100) / total_ticks; X percent_pio = (per_state[W_PIO] * 100) / total_ticks; X percent_swap = (per_state[W_SWAP] * 100) / total_ticks; X } X X percent_total_wait = percent_io + percent_swap + percent_pio; X wmove(win,y, x + _WAITSCALE_TX); X if(percent_total_wait < 30) X use_cp(wscr,cpLOW); X else if(percent_total_wait < 50) X use_cp(wscr,cpMED); X else X use_cp(wscr,cpHIGH); X wprintw(win,"%3ld",percent_total_wait); X X use_cp(wscr,cpINFO); X wmove(win,y, x + _WAITSCALE_IX); X wprintw(win,"%3ld",percent_io); X X wmove(win,y, x + _WAITSCALE_PX); X wprintw(win,"%3ld",percent_pio); X X wmove(win,y, x + _WAITSCALE_WX); X wprintw(win,"%3ld",percent_swap); X X wmove(win,y, x + _WAITSCALE_SX); X X use_cp(wscr,cpLOW); X itmp = (width * percent_io) / 100; X accum += itmp; X while(itmp--) X waddch(win,(chtype)'i'); X X use_cp(wscr,cpMED); X itmp = (width * percent_pio) / 100; X accum += itmp; X while(itmp--) X waddch(win,(chtype)'p'); X X use_cp(wscr,cpHIGH); X itmp = (width * percent_swap) / 100; X accum += itmp; X while(itmp--) X waddch(win,(chtype)'s'); X X if((itmp = (width - accum)) > 0) X { X while(itmp--) X waddch(win,(chtype)' '); X } X X} /* end of update_waitscale */ X X/*+------------------------------------------------------------------------- X calc_wait_avg(per_state) - add per_state array to avg array X--------------------------------------------------------------------------*/ Xvoid Xcalc_wait_avg(per_state) Xtime_t per_state[]; X{ Xregister itmp; X X if(!wait_avg_init) X { X for(itmp = 0; itmp < WAIT_AVG_MAX; itmp++) X (void)memcpy(wait_avg[itmp],per_state,sizeof(time_t) * 3); X wait_avg_init = 1; X } X else X { X for(itmp = 0; itmp < WAIT_AVG_MAX - 1; itmp++) X (void)memcpy(wait_avg[itmp],wait_avg[itmp + 1],sizeof(time_t) * 3); X (void)memcpy(wait_avg[itmp],per_state,sizeof(time_t) * 3); X } X X} /* end of calc_wait_avg */ X X/*+------------------------------------------------------------------------- X get_wait_avg(wait_ticks,period) X--------------------------------------------------------------------------*/ Xget_wait_avg(wait_ticks,period) Xtime_t wait_ticks[]; Xint period; X{ Xregister iperiod = WAIT_AVG_MAX; Xregister istate; Xregister count = period; X X for(istate = 0; istate < 3; istate++) X wait_ticks[istate] = 0; X X while(count--) X { X iperiod--; X for(istate = 0; istate < 3; istate++) X { X wait_ticks[istate] += (wait_avg[iperiod])[istate]; X } X } X X for(istate = 0; istate < 3; istate++) X wait_ticks[istate] /= period; X X} /* end of get_wait_avg */ X X/*+------------------------------------------------------------------------- X extra_static_stuff()/extra_info_stuff() - for 43 line display X--------------------------------------------------------------------------*/ Xvoid Xextra_static_stuff() X{ X display_var(wscr,EXTRA_TLY,EXTRA1_TLX); X display_bootinfo(wscr,EXTRA_TLY,EXTRA2_TLX); X display_tune(wscr,EXTRA_TLY,EXTRA3_TLX); X} /* end of extra_static_stuff */ Xvoid Xextra_info_stuff() X{ X display_proc(wscr,EXTRA_TLY,EXTRA4_TLX); X} /* end of extra_info_stuff */ X X/*+------------------------------------------------------------------------- X read_sysinfo_and_minfo() X--------------------------------------------------------------------------*/ Xvoid Xread_sysinfo_and_minfo() X{ X timeb_last_info_read = timeb_info_read; X (void)ftime(&timeb_info_read); X kread((caddr_t)&sysinfo,sysinfoaddr,sizeof(sysinfo)); X kread((caddr_t)&minfo,minfoaddr,sizeof(minfo)); X} /* end of read_sysinfo_and_minfo */ X X/*+------------------------------------------------------------------------- X main(argc,argv,envp) X--------------------------------------------------------------------------*/ X/*ARGSUSED*/ Xmain(argc,argv,envp) Xint argc; Xchar **argv; Xchar **envp; X{ Xregister itmp; Xregister char *cptr; Xregister chtype cmd; Xregister chtype initial_cmd = 0; Xint errflg = 0; Xint plock_indicator = 0; Xtime_t total_ticks; Xlong stat_period_msec; Xlong nap_msec; Xint y,x; Xint invalidity = 0; Xlong ltmp; Xstruct tm *lt; Xstatic char stdoutbuf[2048]; Xchar s80[80]; Xextern char *optarg; Xextern int optind; X X/* X * curses works better if standard output is fully buffered X */ X (void)setvbuf(stdout,stdoutbuf,_IOFBF,sizeof(stdoutbuf)); X X/* X * check out command line X */ X while((itmp = getopt(argc,argv,"lPps")) != -1) X { X switch(itmp) X { X case 'P': X case 'p': X#ifdef M_UNIX X case 's': X#endif X initial_cmd = (chtype) itmp; X break; X case 'l': X plock_indicator = 1; X break; X case '?': X errflg++; X } X } X if(errflg || (optind != argc)) X { X static char *usage_str[]= X { X "usage: u386mon [-l] [-p | -P]", X "-l lock process into memory (if root)", X "-p begin with short ps display", X "-P begin with long ps display (if 43 line screen)", X (char *)0 X }; X char **cpptr = usage_str; X while(*cpptr) X (void)fprintf(stderr,"%s\n",*(cpptr++)); X exit(1); X } X X/* X * if man wants to plock() try it; fail silently if non-root X */ X if(plock_indicator && plock(PROCLOCK)) X { X nice(-5); X plock_indicator = 0; X } X X/* X * Real(tm) performance monitor users will have done a kernel link X * and won't need to rely on /etc/systemid X */ X if(uname(&utsname)) X { X leave_text("uname failed",255); X exit(1); X } X X/* X * allocate memory for cpu time array averaging buckets X */ X for(itmp = 0; itmp < CPU_AVG_MAX; itmp++) X { X if(!(cpu_avg[itmp] = (time_t *)malloc(sizeof(time_t) * 5))) X leave_text("cannot alloc memory for cpu avg arrays",1); X } X X/* X * allocate memory for wait time array averaging buckets X */ X for(itmp = 0; itmp < WAIT_AVG_MAX; itmp++) X { X if(!(wait_avg[itmp] = (time_t *)malloc(sizeof(time_t) * 3))) X leave_text("cannot alloc memory for wait avg arrays",1); X } X X/* X * initialize curses environment X */ X if(!initscr()) X { X (void)printf("curses init failed\n"); X exit(1); X } X color_avail = has_colors(); X clear(); X refresh(); X X if((LINES < 24) || (COLS < 80)) X { X waddstr(stdscr,"\n\n\nNeed at least 80x24 screen\n\n"); X refresh(); X endwin(); X exit(1); X } X X noecho(); X keypad(stdscr,1); X typeahead(-1); X X/* X * see u386mon.h cXXX definitons for A_BOLD requirements for bright colors X */ X if(color_avail) X { X start_color(); X init_pair(cpLIT,cBLU,cBLK); X init_pair(cpINFO,cGRN,cBLK); X init_pair(cpLOW,cLTG,cBLK); X init_pair(cpMED,cYEL,cBLK); X init_pair(cpHIGH,cRED,cBLK); X init_pair(cpBANNER,cBLK,cWHT); X init_pair(cpREVERSE,cRED,cWHT); X init_pair(cpBANWARN,cBLU,cWHT); X } X X /* a hack for now -- assuming AT char set */ X#ifdef HI_BIT_CAN_BE_SET X acs_map['l'] = A_ALTCHARSET | sTL; X acs_map['m'] = A_ALTCHARSET | sTR; X acs_map['j'] = A_ALTCHARSET | sBL; X acs_map['k'] = A_ALTCHARSET | sBR; X acs_map['x'] = A_ALTCHARSET | sVR; /* vertical rule */ X acs_map['q'] = A_ALTCHARSET | sHR; /* horizontal rule */ X acs_map['t'] = A_ALTCHARSET | sLT; /* left hand T */ X acs_map['u'] = A_ALTCHARSET | sRT; /* right hand T */ X#endif X X if(!(pscr = mkpanel(LINES,COLS,0,0))) X { X addstr("cannot make screen panel"); X refresh(); X endwin(); X exit(1); X } X wscr = panel_window(pscr); X top_panel(pscr); X X/* X * catch signals that can leave our tty in disarray X */ X for(itmp = SIGHUP; itmp < SIGSYS; itmp++) X signal(itmp,caught_signal); X X/* X * read nlist symbols, open /dev/kmem, /dev/mem, /dev/swap, X * initialize detail environment X * (all of these must occur after curses init) X * drop euid and egid (after opening privileged mem/devices) X * initialize process status uid->name hasher X */ X nlsym_read(); X kinit(0); /* /dev/kmem, read access only */ X minit(0); /* /dev/mem, read access only */ X sinit(); /* /dev/swap, only read access available */ X (void)setuid(getuid()); /* some people run us setuid, so clen that up */ X (void)setgid(getgid()); /* now that we have the fds open, drop egid */ X kread((caddr_t)&v,vaddr,sizeof(v)); X detail_init(); X X/* X * start fireworks X */ X wmove(wscr,0,0); X use_cp(wscr,cpBANNER); X wprintw(wscr," u386mon %s ",revision); X#ifdef M_UNIX X cptr = "SCO"; X#else X cptr = "ISC"; X#endif X wprintw(wscr,"%s - %s %s ",utsname.nodename, X cptr,utsname.release); X getyx(wscr,y,x); X while(x < getmaxx(wscr)) X waddch(wscr,(chtype)' '),x++; X wmove(wscr,0,71); X waddstr(wscr,"wht@n4hgf"); X if(plock_indicator) X { X wmove(wscr,0,38); X use_cp(wscr,cpMED); X waddstr(wscr," PLOCK "); X use_cp(wscr,cpBANNER); X } X wmove(wscr,CMD_TLY,0); X if(LINES >= 43) X waddstr(wscr," ESC=quit P=long ps p=short ps m=main "); X else X waddstr(wscr," ESC=quit p=ps e=extra m=main "); X#ifdef M_UNIX X waddstr(wscr," s=sio "); X#endif X if(getuid() == 0) /* root can launch fireworks very predictably */ X waddstr(wscr," l=plock on u=plock off "); X getyx(wscr,y,x); X while(x < getmaxx(wscr)) X waddch(wscr,(chtype)' '),x++; X use_cp(wscr,cpLIT); X X/* X * make initial kmem readings X */ X hz = (cptr = getenv("HZ")) ? atoi(cptr) : HZ; X kread((caddr_t)&maxmem,maxmemaddr,sizeof(maxmem)); X kread((caddr_t)&nswap,nswapaddr,sizeof(nswap)); X kread((caddr_t)&tune,tuneaddr,sizeof(tune)); X kread((caddr_t)&bootinfo,bootinfoaddr,sizeof(bootinfo)); X read_sysinfo_and_minfo(); X sysinfo_last = sysinfo; X minfo_last = minfo; X timeb_last_info_read = timeb_info_read; X X/* X * initialize static display (literals) X */ X draw_cpuscale_literals(wscr,CPUSCALE_TLY,0); X draw_waitscale_literals(wscr,WAITSCALE_TLY,0); X draw_per_sec_literals(wscr,PER_SEC_TLY,0); X X if(LINES >= 43) X extra_static_stuff(); X X/* X * while(user_not_bored) entertain_and_inform_user(); X */ X while(1) X { X ftime(&timeb_cycle_start); X stat_period_msec = delta_msec(timeb_info_read,timeb_last_info_read); X (void)time(<mp); X lt = localtime(<mp); X wmove(wscr,0,62); X use_cp(wscr,cpBANNER); X wprintw(wscr,"%02d:%02d:%02d",lt->tm_hour,lt->tm_min,lt->tm_sec); X X /* heuristic validity determination */ X wmove(wscr,0,48); X if((itmp = stat_period_msec > 4000L) || (invalidity > 5)) X { X use_cp(wscr,cpHIGH); X waddstr(wscr," INVALID "); X if(itmp) X { X invalidity += (stat_period_msec >= 8000L) X ? 8 X : ((stat_period_msec / 1000) - 2); X } X } X else if((itmp = (stat_period_msec > 2500L)) || (invalidity > 2)) X { X use_cp(wscr,cpMED); X waddstr(wscr," INEXACT "); X if(itmp) X invalidity += 2; X } X if(invalidity && !(--invalidity)) X { X use_cp(wscr,cpBANNER); X waddstr(wscr," "); X } X if(stat_period_msec > 2000L) X use_cp(wscr,cpREVERSE); X else if(stat_period_msec > 1500L) X use_cp(wscr,cpBANWARN); X else X use_cp(wscr,cpBANNER); X wmove(wscr,stat_period_msec_y,stat_period_msec_x); X wprintw(wscr,"%5ld",stat_period_msec); X X kread((caddr_t)&freemem,freememaddr,sizeof(freemem)); X read_sysinfo_and_minfo(); X X#ifdef FIRST_TRY /* going this way seems to get cpu+wait ticks > real time */ X for (itmp = 0; itmp < 5; itmp++) X cpu_ticks[itmp] = sysidelta(cpu[itmp]); X for (itmp = 0; itmp < 3; itmp++) X wait_ticks[itmp] = sysidelta(wait[itmp]); X#else X for (itmp = 0; itmp < 5; itmp++) X { X if(itmp != CPU_WAIT) X cpu_ticks[itmp] = sysidelta(cpu[itmp]); X } X cpu_ticks[CPU_WAIT] = 0; X for (itmp = 0; itmp < 3; itmp++) X cpu_ticks[CPU_WAIT] += (wait_ticks[itmp] = sysidelta(wait[itmp])); X#endif X X total_ticks = update_cpuscale(wscr,CPUSCALE_TLY + 1,CPUSCALE_SX, X CPUSCALE_WIDTH,cpu_ticks); X X update_waitscale(wscr,WAITSCALE_TLY + 1,WAITSCALE_SX, X WAITSCALE_WIDTH,wait_ticks,total_ticks); X X calc_cpu_avg(cpu_ticks); X calc_wait_avg(wait_ticks); X X get_cpu_avg(cpu_ticks,5); X total_ticks = update_cpuscale(wscr,CPUSCALE_TLY + 2,CPUSCALE_SX, X CPUSCALE_WIDTH,cpu_ticks); X X get_wait_avg(wait_ticks,5); X update_waitscale(wscr,WAITSCALE_TLY + 2,WAITSCALE_SX, X WAITSCALE_WIDTH,wait_ticks,total_ticks); X X get_cpu_avg(cpu_ticks,10); X total_ticks = update_cpuscale(wscr,CPUSCALE_TLY + 3,CPUSCALE_SX, X CPUSCALE_WIDTH,cpu_ticks); X X get_wait_avg(wait_ticks,10); X update_waitscale(wscr,WAITSCALE_TLY + 3,WAITSCALE_SX, X WAITSCALE_WIDTH,wait_ticks,total_ticks); X X X use_cp(wscr,cpINFO); X y = PER_SEC_TLY + 1; X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"bread ","%7ld",sysidelta(bread)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"bwrite ","%7ld",sysidelta(bwrite)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"lread ","%7ld",sysidelta(lread)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"lwrite ","%7ld",sysidelta(lwrite)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"phread ","%7ld",sysidelta(phread)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"phwrite ","%7ld",sysidelta(phwrite)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"swapin ","%7ld",sysidelta(swapin)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"swapout ","%7ld",sysidelta(swapout)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"bswapin ","%7ld",sysidelta(bswapin)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"bswapout ","%7ld",sysidelta(bswapout)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"iget ","%7ld",sysidelta(iget)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"namei ","%7ld",sysidelta(namei)); X wmove(wscr,y++,PER_SEC1_TLX); X disp_info_long(wscr,"dirblk ","%7ld",sysidelta(dirblk)); X X y = PER_SEC_TLY + 1; X wmove(wscr,y++,PER_SEC2_TLX); X if((ltmp = sysidelta(readch) - myreadcnt) < 0) X ltmp = 0; X disp_info_long(wscr,"readch ","%7ld",ltmp); X myreadcnt = 0; /* reset /dev/{mem,kmem,swap} read count */ X X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_long(wscr,"writch ","%7ld",sysidelta(writech)); X X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_long(wscr,"rawch ","%7ld",sysidelta(rawch)); X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_long(wscr,"canch ","%7ld",sysidelta(canch)); X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_long(wscr,"outch ","%7ld",sysidelta(outch)); X X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_long(wscr,"msg ","%7ld",sysidelta(msg)); X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_long(wscr,"sema ","%7ld",sysidelta(sema)); X X wmove(wscr,y++,PER_SEC2_TLX); X disp_static_long(wscr, "maxmem ","%6ldk",(long)maxmem * NBPP / 1024); X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_long(wscr, "frmem ","%6ldk",(long)freemem * NBPP / 1024); X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_int (wscr, "mem used","%6d%%", X 100 - (int)((freemem * 100) / maxmem)); X X wmove(wscr,y++,PER_SEC2_TLX); X disp_static_int(wscr, "nswap ","%6ldk",nswap/2); X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_long(wscr, "frswp ","%6ldk",minfo.freeswap/2); X wmove(wscr,y++,PER_SEC2_TLX); X disp_info_int(wscr, "swp used","%6d%%", X 100 - (int)((minfo.freeswap * 100) / nswap)); X X y = PER_SEC_TLY + 1; X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"pswitch ","%5ld",sysidelta(pswitch)); X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"syscall ","%5ld",sysidelta(syscall)); X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"sysread ","%5ld",sysidelta(sysread)); X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"syswrit ","%5ld",sysidelta(syswrite)); X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"sysfork ","%5ld",sysidelta(sysfork)); X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"sysexec ","%5ld",sysidelta(sysexec)); X X y++; X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"runque ","%5ld",sysidelta(runque)); X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"runocc ","%5ld",sysidelta(runocc)); X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"swpque ","%5ld",sysidelta(swpque)); X wmove(wscr,y++,PER_SEC3_TLX); X disp_info_long(wscr,"swpocc ","%5ld",sysidelta(swpocc)); X X y = PER_SEC_TLY + 1; X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"vfault ","%3ld",midelta(vfault)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"demand ","%3ld",midelta(demand)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"pfault ","%3ld",midelta(pfault)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"cw ","%3ld",midelta(cw)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"steal ","%3ld",midelta(steal)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"frdpgs ","%3ld",midelta(freedpgs)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"vfpg ","%3ld",midelta(vfpg)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"sfpg ","%3ld",midelta(sfpg)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"vspg ","%3ld",midelta(vspg)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"sspg ","%3ld",midelta(sspg)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"pnpfault","%3ld",sysidelta(pnpfault)); X wmove(wscr,y++,PER_SEC4_TLX); X disp_info_long(wscr,"wrtfault","%3ld",sysidelta(wrtfault)); X X y = PER_SEC_TLY + 1; X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"unmodsw ","%3ld",midelta(unmodsw)); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"unmodfl ","%3ld",midelta(unmodfl)); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"psoutok ","%3ld",midelta(psoutok)); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"psinfai ","%3ld",midelta(psinfail)); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"psinok ","%3ld",midelta(psinok)); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"rsout ","%3ld",midelta(rsout)); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"rsin ","%3ld",midelta(rsin)); X X y++; X wmove(wscr,y++,PER_SEC5_TLX); X use_cp(wscr,cpLIT); X waddstr(wscr,"pages on "); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"swap ","%5ld",midelta(swap)); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"cache ","%5ld",midelta(cache)); X wmove(wscr,y++,PER_SEC5_TLX); X disp_info_long(wscr,"file ","%5ld",midelta(file)); X X if(LINES >= 43) X extra_info_stuff(); X X X detail_panel_update(); X X if(initial_cmd) X { X detail_panel_cmd(initial_cmd); X initial_cmd = 0; X } X X pflush(); X X if(rdchk(0)) X { X switch(cmd = wgetch(wscr)) X { X case 'L' & 0x1F: /* ^L */ X case 'R' & 0x1F: /* ^R */ X touchwin(wscr); X wrefresh(wscr); X if(wdet) X { X touchwin(wdet); X wrefresh(wscr); X } X break; X X case 'q': X case A_ESC: X goto GOOD_BYE; X#ifdef M_UNIX X case 'b': X if(bootinfo.bootstrlen > 79) X itmp = 79; X else X itmp = bootinfo.bootstrlen; X kread(s80,bootinfoaddr + X (bootinfo.bootstr - (caddr_t)&bootinfo),itmp); X s80[itmp] = 0; X disp_msg(cpMED,s80); X break; X#endif X case 'e': X case 'P': X case 'p': X case 'm': X#ifdef M_UNIX X case 's': X#endif X detail_panel_cmd(cmd); X break; X case 'l': X if(!plock_indicator) X { X if(!plock(PROCLOCK)) X { X plock_indicator = 1; X wmove(wscr,0,38); X use_cp(wscr,cpMED); X waddstr(wscr," PLOCK "); X nice(-5); X } X } X break; X case 'u': X if(plock_indicator) X { X if(!plock(UNLOCK)) X { X plock_indicator = 0; X wmove(wscr,0,38); X use_cp(wscr,cpBANNER); X waddstr(wscr," "); X nice(5); X } X } X break; X } X } X X /* remember previous statistics for next delta */ X sysinfo_last = sysinfo; X minfo_last = minfo; X X /* ex-lax: all in the name of regularity */ X ftime(&timeb_cycle_end); X nap_msec = 1000L - delta_msec(timeb_cycle_end,timeb_cycle_start); X if(nap_msec < 700L) X nap_msec = 700L; X (void)nap(nap_msec); X } X XGOOD_BYE: X leave_text("",0); X /*NOTREACHED*/ X} /* end of main */ X X/* vi: set tabstop=4 shiftwidth=4: */ X/* end of u386mon.c */ SHAR_EOF $TOUCH -am 0715025290 u386mon.c && chmod 0644 u386mon.c || echo "restore of u386mon.c failed" set `wc -c u386mon.c`;Wc_c=$1 if test "$Wc_c" != "33152"; then echo original size 33152, current size $Wc_c fi # ============= var.c ============== echo "x - extracting var.c (Text)" sed 's/^X//' << 'SHAR_EOF' > var.c && X/* CHK=0xE896 */ X/*+------------------------------------------------------------------------- X var.c - u386mon var struct display X X Defined functions: X display_var(win,y,x) X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-25-1990-17:33-wht@n4hgf-alpha sort identifiers */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-21-1990-14:27-r@n4hgf-version x0.12 seems bug free */ X/*:06-17-1990-14:59-wht-creation */ X X#define M_TERMINFO X X#include <curses.h> X#include <panel.h> X#include <sys/types.h> X#include <sys/var.h> X#include "u386mon.h" X X/*+------------------------------------------------------------------------- X display_var(win,y,x) X--------------------------------------------------------------------------*/ Xvoid Xdisplay_var(win,y,x) XWINDOW *win; Xint y; Xint x; X{ X use_cp(win,cpBANNER); X wmove(win,y++,x); X waddstr(win,"-- Var ---------"); X wmove(win,y++,x); X disp_static_int(win,"v_autoup ","%5d",v.v_autoup); X wmove(win,y++,x); X disp_static_int(win,"v_buf ","%5d",v.v_buf); X wmove(win,y++,x); X disp_static_int(win,"v_clist ","%5d",v.v_clist); X wmove(win,y++,x); X disp_static_int(win,"v_file ","%5d",v.v_file); X wmove(win,y++,x); X disp_static_int(win,"v_hbuf ","%5d",v.v_hbuf); X wmove(win,y++,x); X disp_static_int(win,"v_inode ","%5d",v.v_inode); X wmove(win,y++,x); X disp_static_int(win,"v_maxpmem ","%5d",v.v_maxpmem); X wmove(win,y++,x); X disp_static_int(win,"v_maxup ","%5d",v.v_maxup); X wmove(win,y++,x); X disp_static_int(win,"v_mount ","%5d",v.v_mount); X wmove(win,y++,x); X disp_static_int(win,"v_pbuf ","%5d",v.v_pbuf); X wmove(win,y++,x); X disp_static_int(win,"v_proc ","%5d",v.v_proc); X wmove(win,y++,x); X disp_static_int(win,"v_region ","%5d",v.v_region); X wmove(win,y++,x); X disp_static_int(win,"v_vhndfrac ","%5d",v.v_vhndfrac); X X} /* end of display_var */ X X/* vi: set tabstop=4 shiftwidth=4: */ X/* end of var.c */ SHAR_EOF $TOUCH -am 0715025190 var.c && chmod 0644 var.c || echo "restore of var.c failed" set `wc -c var.c`;Wc_c=$1 if test "$Wc_c" != "2094"; then echo original size 2094, current size $Wc_c fi # ============= libkmem.h ============== echo "x - extracting libkmem.h (Text)" sed 's/^X//' << 'SHAR_EOF' > libkmem.h && X/* CHK=0x635C */ X/*+----------------------------------------------------------------------- X libkmem.h X ...!emory!n4hgf!wht X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */ X/*:10-28-1988-14:46-afterlint-creation */ X X#ifndef BUILDING_LINT_ARGS X#ifdef LINT_ARGS X X/* libkmem.c */ Xvoid kinit(int ); Xvoid kread(char *,long ,int ); Xvoid kwrite(long ,char *,int ); X X#else /* compiler doesn't know about prototyping */ X X/* libkmem.c */ Xvoid kinit(); Xvoid kread(); Xvoid kwrite(); X X#endif /* LINT_ARGS */ X#endif /* BUILDING_LINT_ARGS */ X X/* end of libkmem.h */ SHAR_EOF $TOUCH -am 0715025090 libkmem.h && chmod 0644 libkmem.h || echo "restore of libkmem.h failed" set `wc -c libkmem.h`;Wc_c=$1 if test "$Wc_c" != "874"; then echo original size 874, current size $Wc_c fi # ============= libmem.h ============== echo "x - extracting libmem.h (Text)" sed 's/^X//' << 'SHAR_EOF' > libmem.h && X/* CHK=0xDACD */ X/*+----------------------------------------------------------------------- X libmem.h X ...!emory!n4hgf!wht X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */ X/*:10-28-1988-14:46-afterlint-creation */ X X#ifndef BUILDING_LINT_ARGS X#ifdef LINT_ARGS X X/* libmem.c */ Xvoid minit(int ); Xvoid mread(char *,long ,int ); Xvoid mwrite(long ,char *,int ); X X#else /* compiler doesn't mnow about prototyping */ X X/* libmem.c */ Xvoid minit(); Xvoid mread(); Xvoid mwrite(); X X#endif /* LINT_ARGS */ X#endif /* BUILDING_LINT_ARGS */ X X/* end of libmem.h */ SHAR_EOF $TOUCH -am 0715025090 libmem.h && chmod 0644 libmem.h || echo "restore of libmem.h failed" set `wc -c libmem.h`;Wc_c=$1 if test "$Wc_c" != "870"; then echo original size 870, current size $Wc_c fi # ============= libswap.h ============== echo "x - extracting libswap.h (Text)" sed 's/^X//' << 'SHAR_EOF' > libswap.h && X/* CHK=0xF21C */ X/*+----------------------------------------------------------------------- X libswap.h X ...!emory!n4hgf!wht X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-22-1990-02:03-root@n4hgf-creation from libmem */ X X#ifndef BUILDING_LINT_ARGS X#ifdef LINT_ARGS X X/* libswap.c */ Xvoid sinit(void ); Xvoid sread(char *,long ,int ); X X#else /* compiler doesn't mnow about prototyping */ X X/* libswap.c */ Xvoid sinit(); Xvoid sread(); Xvoid swrite(); X X#endif /* LINT_ARGS */ X#endif /* BUILDING_LINT_ARGS */ X X/* end of libswap.h */ SHAR_EOF $TOUCH -am 0715025190 libswap.h && chmod 0644 libswap.h || echo "restore of libswap.h failed" set `wc -c libswap.h`;Wc_c=$1 if test "$Wc_c" != "795"; then echo original size 795, current size $Wc_c fi # ============= libnlsym.h ============== echo "x - extracting libnlsym.h (Text)" sed 's/^X//' << 'SHAR_EOF' > libnlsym.h && X/* CHK=0x6491 */ X/*+----------------------------------------------------------------------- X libnlsym.h X ...!emory!n4hgf!wht X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */ X/*:10-28-1988-14:47-afterlint-creation */ X X#ifndef BUILDING_LINT_ARGS X#ifdef LINT_ARGS X X/* libnlsym.c */ Xvoid nlsym_error(char * ); Xvoid nlsym_read(void); X X#else /* compiler doesn't know about prototyping */ X X/* libnlsym.c */ Xvoid nlsym_error(); Xvoid nlsym_read(); X X#endif /* LINT_ARGS */ X#endif /* BUILDING_LINT_ARGS */ X X/* end of libnlsym.h */ SHAR_EOF $TOUCH -am 0715025190 libnlsym.h && chmod 0644 libnlsym.h || echo "restore of libnlsym.h failed" set `wc -c libnlsym.h`;Wc_c=$1 if test "$Wc_c" != "841"; then echo original size 841, current size $Wc_c fi echo "End of part 3, continue with part 4" exit 0 -------------------------------------------------------------------- Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US Sforzando (It., sfohr-tsahn'-doh). A direction to perform the tone or chord with special stress, or marked and sudden emphasis.