home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
1
/
1507
< prev
next >
Wrap
Internet Message Format
|
1990-12-28
|
51KB
From: wht@n4hgf.uucp (Warren Tucker)
Newsgroups: alt.sources
Subject: u386mon 1.0, UNIX 386 system monitor, part 01/02
Message-ID: <120@n4hgf.uucp>
Date: 24 Jun 90 20:20:01 GMT
Submitted-by: wht@n4hgf
Archive-name: u386mon.1.00/part02
#!/bin/sh
# This is part 02 of u386mon.1.00
if touch 2>&1 | fgrep 'mmdd' > /dev/null
then TOUCH=touch
else TOUCH=true
fi
# ============= libkmem.c ==============
echo "x - extracting libkmem.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > libkmem.c &&
X/*LINTLIBRARY*/
X/*+-------------------------------------------------------------------------
X libkmem.c -- /dev/kmem routines for SCO UNIX/386 (maybe other *NIX)
X ...!emory!n4hgf!wht
X
X Defined functions:
X kinit(write_needed)
X kread(caddr,kaddr,len)
X kwrite(kaddr,caddr,len)
X
X routines were originally written by Mike "Ford" Ditto: kudos!!!
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
X/*:12-07-1988-22:06-wht-put in test for initialized fdkmem */
X/*:10-27-1988-22:44-wht-creation of file */
X
X#include <sys/types.h>
X#include <fcntl.h>
X#include "libkmem.h"
X
Xvoid leave_text();
X
Xextern int errno;
X
Xstatic int fdkmem = -2;
Xdaddr_t lseek();
X
X/*+-------------------------------------------------------------------------
X kinit(write_needed)
X--------------------------------------------------------------------------*/
Xvoid
Xkinit(write_needed)
Xint write_needed;
X{
X if(fdkmem >= 0)
X return;
X if((fdkmem=open("/dev/kmem",(write_needed) ? O_RDWR : O_RDONLY,0)) < 0)
X leave_text("can't open /dev/kmem",1);
X
X} /* end of kinit */
X
X/*+-------------------------------------------------------------------------
X kread(caddr,kaddr,len)
X--------------------------------------------------------------------------*/
Xvoid
Xkread(caddr,kaddr,len)
Xcaddr_t caddr;
Xdaddr_t kaddr;
Xint len;
X{
Xchar s80[80];
Xextern daddr_t myreadcnt;
X
X#if defined(M_I286)
X kaddr &= 0xFFFFL;
X#endif
X
X if(fdkmem == -2)
X leave_text("kinit() not called",1);
X
X if(lseek(fdkmem,kaddr,0) == -1L)
X {
X (void)sprintf(s80,"kmem seek err (%08lx)",kaddr);
X leave_text(s80,1);
X }
X
X if(read(fdkmem,caddr,len) != len)
X {
X (void)sprintf(s80,
X "kmem read errno %d len %d addr %08lx",errno,len,kaddr);
X leave_text(s80,1);
X }
X myreadcnt += len;
X} /* end of kread */
X
X/*+-------------------------------------------------------------------------
X kwrite(kaddr,caddr,len)
X--------------------------------------------------------------------------*/
X#ifdef KWRITE_NEEDED
Xvoid
Xkwrite(kaddr,caddr,len)
Xdaddr_t kaddr;
Xcaddr_t caddr;
Xint len;
X{
Xchar s80[80];
X
X#if defined(M_I286)
X kaddr &= 0xFFFFL;
X#endif
X
X if(fdkmem == -2)
X leave_text("kinit() not called",1);
X
X if((lseek(fdkmem,kaddr,0) < 0L) || (write(fdkmem,caddr,len) != len))
X {
X (void)sprintf(s80,"/dev/kmem write addr %08lx len %08lx",kaddr,len);
X leave_text(s80,1);
X }
X} /* end of kwrite */
X#endif
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0624151990 libkmem.c &&
chmod 0644 libkmem.c ||
echo "restore of libkmem.c failed"
set `wc -c libkmem.c`;Wc_c=$1
if test "$Wc_c" != "2441"; then
echo original size 2441, current size $Wc_c
fi
# ============= libmem.c ==============
echo "x - extracting libmem.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > libmem.c &&
X/*LINTLIBRARY*/
X/*+-------------------------------------------------------------------------
X libmem.c -- /dev/mem routines for SCO UNIX/386 (maybe other *NIX)
X ...!emory!n4hgf!wht
X
X Defined functions:
X minit(write_needed)
X mread(caddr,maddr,len)
X mwrite(maddr,caddr,len)
X
X routines were originally written by Mike "Ford" Ditto: kudos!!!
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
X/*:12-07-1988-22:06-wht-put in test for initialized fdmem */
X/*:10-27-1988-22:44-wht-creation of file */
X
X#include <sys/types.h>
X#include <fcntl.h>
X#include "libmem.h"
X
Xvoid leave_text();
X
Xextern int errno;
X
Xstatic int fdmem = -2;
Xdaddr_t lseek();
X
X/*+-------------------------------------------------------------------------
X minit(write_needed)
X--------------------------------------------------------------------------*/
Xvoid
Xminit(write_needed)
Xint write_needed;
X{
X if(fdmem >= 0)
X return;
X if((fdmem=open("/dev/mem",(write_needed) ? O_RDWR : O_RDONLY,0)) < 0)
X leave_text("can't open /dev/mem",1);
X
X} /* end of minit */
X
X/*+-------------------------------------------------------------------------
X mread(caddr,maddr,len)
X--------------------------------------------------------------------------*/
Xvoid
Xmread(caddr,maddr,len)
Xcaddr_t caddr;
Xdaddr_t maddr;
Xint len;
X{
Xchar s80[80];
Xextern daddr_t myreadcnt;
X
X#if defined(M_I286)
X maddr &= 0xFFFFL;
X#endif
X
X if(fdmem == -2)
X leave_text("minit() not called",1);
X
X if(lseek(fdmem,maddr,0) == -1L)
X {
X (void)sprintf(s80,"mem seek err (%08lx)",maddr);
X leave_text(s80,1);
X }
X
X if(read(fdmem,caddr,len) != len)
X {
X (void)sprintf(s80,
X "mem read errno %d len %d addr %08lx",errno,len,maddr);
X leave_text(s80,1);
X }
X myreadcnt += len;
X} /* end of mread */
X
X/*+-------------------------------------------------------------------------
X mwrite(maddr,caddr,len)
X--------------------------------------------------------------------------*/
X#ifdef MWRITE_NEEDED
Xvoid
Xmwrite(maddr,caddr,len)
Xdaddr_t maddr;
Xcaddr_t caddr;
Xint len;
X{
Xchar s80[80];
X
X#if defined(M_I286)
X maddr &= 0xFFFFL;
X#endif
X
X if(fdmem == -2)
X leave_text("minit() not called",1);
X
X if((lseek(fdmem,maddr,0) < 0L) || (write(fdmem,caddr,len) != len))
X {
X (void)sprintf(s80,"/dev/mem write addr %08lx len %08lx",maddr,len);
X leave_text(s80,1);
X }
X} /* end of mwrite */
X#endif /* MWRITE_NEEDED */
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0624151990 libmem.c &&
chmod 0644 libmem.c ||
echo "restore of libmem.c failed"
set `wc -c libmem.c`;Wc_c=$1
if test "$Wc_c" != "2443"; then
echo original size 2443, current size $Wc_c
fi
# ============= libswap.c ==============
echo "x - extracting libswap.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > libswap.c &&
X/*LINTLIBRARY*/
X/*+-------------------------------------------------------------------------
X libswap.c -- /dev/swap routines for SCO UNIX/386 (maybe other *NIX)
X ...!emory!n4hgf!wht
X
X Defined functions:
X sinit()
X sread(caddr,maddr,len)
X
X routines were originally written by Mike "Ford" Ditto: kudos!!!
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:06-22-1990-02:00-root@n4hgf-creation from libmem */
X
X#include <sys/types.h>
X#include <fcntl.h>
X#include "libswap.h"
X
Xvoid leave_text();
X
Xextern int errno;
X
Xstatic int fdswap = -2;
Xdaddr_t lseek();
X
X/*+-------------------------------------------------------------------------
X sinit()
X--------------------------------------------------------------------------*/
Xvoid
Xsinit()
X{
X if(fdswap >= 0)
X return;
X if((fdswap=open("/dev/swap",O_RDONLY)) < 0)
X leave_text("can't open /dev/swap (chgrp mem /dev/swap)",1);
X
X} /* end of sinit */
X
X/*+-------------------------------------------------------------------------
X sread(caddr,maddr,len)
X--------------------------------------------------------------------------*/
Xvoid
Xsread(caddr,maddr,len)
Xcaddr_t caddr;
Xdaddr_t maddr;
Xint len;
X{
Xchar s80[80];
Xextern daddr_t myreadcnt;
X
X#if defined(M_I286)
X maddr &= 0xFFFFL;
X#endif
X
X if(fdswap == -2)
X leave_text("sinit() not called",1);
X
X if(lseek(fdswap,maddr,0) == -1L)
X {
X (void)sprintf(s80,"swap seek err (%08lx)",maddr);
X leave_text(s80,1);
X }
X
X if(read(fdswap,caddr,len) != len)
X {
X (void)sprintf(s80,
X "swap read errno %d len %d addr %08lx",errno,len,maddr);
X leave_text(s80,1);
X }
X myreadcnt += len;
X} /* end of sread */
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0624151990 libswap.c &&
chmod 0644 libswap.c ||
echo "restore of libswap.c failed"
set `wc -c libswap.c`;Wc_c=$1
if test "$Wc_c" != "1658"; then
echo original size 1658, current size $Wc_c
fi
# ============= libnlsym.c ==============
echo "x - extracting libnlsym.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > libnlsym.c &&
X/*LINTLIBRARY*/
X/*+-------------------------------------------------------------------------
X libnlsym.c -- common runtime for nlsym users
X ...!emory!n4hgf!wht
X
X Defined functions:
X nlsym_error(text)
X nlsym_read()
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
X/*:10-27-1988-11:44-wht-creation */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <fcntl.h>
X#include <nlist.h>
X
Xvoid leave_text();
X
X#define DEFINE_NLSYM
X#include "nlsym.h"
X#include "libnlsym.h"
X
Xextern int errno;
Xextern char *sys_errlist[];
X
X/*+-------------------------------------------------------------------------
X nlsym_error(text)
X--------------------------------------------------------------------------*/
Xvoid
Xnlsym_error(text)
Xchar *text;
X{
Xchar s128[128];
X
X (void)strcpy(s128,text);
X if(errno)
X {
X (void)strcat(s128," (");
X (void)strcat(s128,sys_errlist[errno]);
X (void)strcat(s128,")");
X }
X (void)strcat(s128," run nlsym");
X leave_text(s128,1);
X} /* end of nlsym_error */
X
X/*+-------------------------------------------------------------------------
X nlsym_read()
X--------------------------------------------------------------------------*/
Xvoid
Xnlsym_read()
X{
Xchar s80[80];
Xint itmp;
Xint fdnlsym;
Xstruct stat curstat; /* current /unix status */
Xstruct stat unixstat; /* /unix status at nlsym run (void)time */
Xlong unique;
X
X if(stat(UNIX_KERNEL,&curstat) < 0)
X {
X (void)sprintf(s80,"cannot stat %s",UNIX_KERNEL);
X nlsym_error(s80);
X }
X
X errno = 0;
X if((fdnlsym = open(UNIX_NLSYM,O_RDONLY,0)) < 0)
X {
X (void)sprintf(s80,"%s open error\n",UNIX_NLSYM);
X nlsym_error(s80);
X }
X
X if(read(fdnlsym,&unixstat,sizeof(unixstat)) != sizeof(unixstat))
X nlsym_error("nlsym_read: /unix stat read error");
X
X if(read(fdnlsym,nlsym,sizeof(nlsym)) != sizeof(nlsym))
X nlsym_error("nlsym_read: nlsym read error");
X
X if(read(fdnlsym,&unique,sizeof(unique)) != sizeof(unique))
X nlsym_error("nlsym_read: `unique' read error");
X
X (void)close(fdnlsym);
X
X if( (unique != NLSYM_UNIQUE) ||
X (unixstat.st_ino != curstat.st_ino) ||
X (unixstat.st_mtime != curstat.st_mtime) ||
X (unixstat.st_size != curstat.st_size))
X {
X (void)sprintf(s80,"%s out of date\n",UNIX_NLSYM);
X nlsym_error(s80);
X }
X
X} /* end of nlsym_read */
SHAR_EOF
$TOUCH -am 0624151990 libnlsym.c &&
chmod 0644 libnlsym.c ||
echo "restore of libnlsym.c failed"
set `wc -c libnlsym.c`;Wc_c=$1
if test "$Wc_c" != "2312"; then
echo original size 2312, current size $Wc_c
fi
# ============= nlsym.c ==============
echo "x - extracting nlsym.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > nlsym.c &&
X/*+-------------------------------------------------------------------------
X nlsym.c -- utility nlist - fast access to kernel /dev/kmem offsets
X ...!emory!n4hgf!wht
X
X Defined functions:
X main(argc,argv,envp)
X nlsym_write_error(code)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
X/*:05-12-1989-18:27-wht-fix endless loop error on cannot nlist */
X/*:10-27-1988-10:58-wht-creation */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <fcntl.h>
X#include <nlist.h>
X
X#define DEFINE_NLSYM
X#include "nlsym.h"
X
X/*+-------------------------------------------------------------------------
X nlsym_write_error(code)
X--------------------------------------------------------------------------*/
Xvoid
Xnlsym_write_error(code)
Xint code;
X{
X (void)fprintf(stderr,"code %d: ",code);
X perror(UNIX_NLSYM);
X exit(1);
X} /* end of nlsym_write_error */
X
X/*+-------------------------------------------------------------------------
X main(argc,argv,envp)
X--------------------------------------------------------------------------*/
X/*ARGSUSED*/
Xmain(argc,argv,envp)
Xint argc;
Xchar **argv;
Xchar **envp;
X{
Xregister int itmp;
Xregister struct nlist *nn;
Xstruct stat unixstat; /* /unix status at nlsym run (void)time */
Xint fdnlsym;
Xint nlist_error = 0;
Xlong unique;
XFILE *kludge;
X
X (void)nlist(UNIX_KERNEL,nlsym);
X
X nn = nlsym;
X while(nn->n_name)
X {
X if(!nn->n_sclass)
X {
X (void)printf("%s: can't nlist\n", nn->n_name);
X nlist_error = 1;
X nn++;
X continue;
X }
X (void)printf("%-12.12s storage class: %04x value: %08lx\n",
X nn->n_name,
X nn->n_sclass,
X nn->n_value);
X nn++;
X }
X
X if(nlist_error)
X {
X (void)fprintf(stderr,"%s NOT produced\n",UNIX_NLSYM);
X exit(1);
X }
X
X if((kludge = fopen(UNIX_NLSYM,"w")) == NULL) /* scratch/create */
X nlsym_write_error(-1);
X (void)fclose(kludge);
X
X if((fdnlsym = open(UNIX_NLSYM,O_WRONLY,0)) < 0)
X nlsym_write_error(fdnlsym);
X
X if(stat(UNIX_KERNEL,&unixstat) < 0)
X {
X (void)fputs("cannot stat ",stderr);
X perror(UNIX_KERNEL);
X exit(1);
X }
X
X if((itmp = write(fdnlsym,&unixstat,sizeof(unixstat))) != sizeof(unixstat))
X nlsym_write_error(itmp);
X
X if((itmp = write(fdnlsym,nlsym,sizeof(nlsym))) != sizeof(nlsym))
X nlsym_write_error(itmp);
X
X unique = NLSYM_UNIQUE;
X if((itmp = write(fdnlsym,&unique,sizeof(unique))) != sizeof(unique))
X nlsym_write_error(itmp);
X
X (void)close(fdnlsym);
X exit(0);
X /*NOTREACHED*/
X} /* end of main */
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0624151990 nlsym.c &&
chmod 0644 nlsym.c ||
echo "restore of nlsym.c failed"
set `wc -c nlsym.c`;Wc_c=$1
if test "$Wc_c" != "2525"; then
echo original size 2525, current size $Wc_c
fi
# ============= proc.c ==============
echo "x - extracting proc.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > proc.c &&
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/*: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;
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 *pp;
X
X if(!procs)
X {
X if(!(procs = (struct proc *)malloc(sizeof(struct proc) * v.v_proc)))
X leave_text("cannot alloc memory for proc table",1);
X if(!(oldprocs = (struct proc *)malloc(sizeof(struct proc) * v.v_proc)))
X leave_text("cannot alloc memory for proc table",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 pp = procs + iproc;
X
X if(pp->p_stat)
X procs_alive++;
X
X procs_per_pstat[pp->p_stat]++; /* count # procs in each state */
X
X if(pp->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 0624151990 proc.c &&
chmod 0644 proc.c ||
echo "restore of proc.c failed"
set `wc -c proc.c`;Wc_c=$1
if test "$Wc_c" != "3188"; then
echo original size 3188, current size $Wc_c
fi
# ============= tune.c ==============
echo "x - extracting tune.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > tune.c &&
X/*+-------------------------------------------------------------------------
X tune.c - u386mon tune struct display
X
X Defined functions:
X display_tune(win,y,x)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
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_gpgslo ","%5d",tune.t_gpgslo);
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_gpgsmsk ","0x%03lx",tune.t_gpgsmsk);
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_maxsc ","%5d",tune.t_maxsc);
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_maxumem ","%5d",tune.t_maxumem);
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_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 0624151990 tune.c &&
chmod 0644 tune.c ||
echo "restore of tune.c failed"
set `wc -c tune.c`;Wc_c=$1
if test "$Wc_c" != "1662"; then
echo original size 1662, current size $Wc_c
fi
# ============= u386mon.c ==============
echo "x - extracting u386mon.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > u386mon.c &&
Xchar *revision = "1.00";
X/*+-------------------------------------------------------------------------
X u386mon.c - UNIX 386 system monitor
X
X Defined functions:
X calc_cpu_avg(cpu_ticks)
X calc_wait_avg(wait_ticks)
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 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 mm/dd/yy hh:mm:ss
X
X---- CPU --- tot usr ker brk ---------------------------------------------------
X Instant % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X 5 Sec Avg % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X10 Sec Avg % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X---- Wait -- tot io swp pio ---------------------------------------------------
X Instant % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X 5 Sec Avg % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X10 Sec Avg % ### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
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#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/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
XPANEL *mkpanel();
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;
Xtime_t now;
Xtime_t then;
Xint hz;
Xint nswap;
Xint maxmem;
Xint freemem;
Xdaddr_t myreadcnt = 0L;
X
XPANEL *pscr;
XWINDOW *wscr;
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 leave(exit_code)
X--------------------------------------------------------------------------*/
Xvoid
Xleave(exit_code)
Xint exit_code;
X{
X wmove(wscr,CMD_TLY,0);
X use_cp(wscr,cpLIT);
X wclrtoeol(wscr);
X pflush();
X endwin();
X exit(exit_code);
X} /* end of leave */
X
X/*+-------------------------------------------------------------------------
X leave_text(text,exit_code)
X--------------------------------------------------------------------------*/
Xvoid
Xleave_text(text,exit_code)
Xchar *text;
Xint exit_code;
X{
X disp_msg(cpHIGH,text);
X leave(exit_code);
X} /* end of leave */
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 swp pio -- (% of real (void)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 1 second 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 swp pio
X### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X--------------------------------------------------------------------------*/
X#define _WAITSCALE_TX 0
X#define _WAITSCALE_IX 4
X#define _WAITSCALE_WX 8
X#define _WAITSCALE_PX 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_swap = (per_state[W_SWAP] * 100) / total_ticks;
X percent_pio = (per_state[W_PIO] * 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 wmove(win,y, x + _WAITSCALE_IX);
X use_cp(wscr,cpINFO);
X wprintw(win,"%3ld",percent_io);
X
X wmove(win,y, x + _WAITSCALE_WX);
X wprintw(win,"%3ld",percent_swap);
X
X wmove(win,y, x + _WAITSCALE_PX);
X wprintw(win,"%3ld",percent_pio);
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_swap) / 100;
X accum += itmp;
X while(itmp--)
X waddch(win,(chtype)'s');
X
X use_cp(wscr,cpHIGH);
X itmp = (width * percent_pio) / 100;
X accum += itmp;
X while(itmp--)
X waddch(win,(chtype)'p');
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 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;
Xint y,x;
Xint invalidity = 0;
Xlong ltmp;
Xstruct tm *lt;
Xstatic char stdoutbuf[1024];
Xextern char *optarg;
Xextern int optind;
X
X while((itmp = getopt(argc,argv,"lPp")) != -1)
X {
X switch(itmp)
X {
X case 'P':
X case 'p':
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 if(plock_indicator && plock(PROCLOCK))
X plock_indicator = 0;
X
X (void)setvbuf(stdout,stdoutbuf,_IOFBF,sizeof(stdoutbuf));
X
X if(uname(&utsname))
X {
X perror("uname");
X exit(1);
X }
X
X for(itmp = 0; itmp < CPU_AVG_MAX; itmp++)
X {
X if(!(cpu_avg[itmp] = (time_t *)malloc(sizeof(time_t) * 5)))
X {
X (void)fputs("cannot alloc memory!\n",stderr);
X exit(1);
X }
X }
X
X for(itmp = 0; itmp < WAIT_AVG_MAX; itmp++)
X {
X if(!(wait_avg[itmp] = (time_t *)malloc(sizeof(time_t) * 3)))
X {
X (void)fputs("cannot alloc memory!\n",stderr);
X exit(1);
X }
X }
X
X if(!initscr())
X {
X (void)printf("curses init failed\n");
X exit(1);
X }
X clear();
X refresh();
X
X nlsym_read();
X kinit(0); /* read access only */
X minit(0); /* read access only */
X sinit();
X init_uid_name_hash(); /* see det_proc.c */
X (void)setgid(getgid());
X
X noecho();
X keypad(stdscr,1);
X typeahead(-1);
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
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
X detail_init();
X top_panel(pscr);
X
X wmove(wscr,0,0);
X use_cp(wscr,cpBANNER);
X wprintw(wscr," u386mon %s ",revision);
X wprintw(wscr,"%s - %s %s ",utsname.nodename,
X utsname.machine,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 m=main ");
X if(getuid() == 0)
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 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)&sysinfo_last,sysinfoaddr,sizeof(sysinfo_last));
X kread((caddr_t)&minfo_last,minfoaddr,sizeof(minfo));
X kread((caddr_t)&tune,tuneaddr,sizeof(tune));
X kread((caddr_t)&v,vaddr,sizeof(v));
X kread((caddr_t)&bootinfo,bootinfoaddr,sizeof(bootinfo));
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 (void)time(&then);
X while(1)
X {
X nap(1000L);
X (void)time(&now);
X wmove(wscr,0,62);
X use_cp(wscr,cpBANNER);
X lt = localtime(&now);
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((now - then) > 4)
X {
X use_cp(wscr,cpHIGH);
X waddstr(wscr," INVALID ");
X invalidity += 3;
X }
X else if((itmp = ((now - then) > 3)) || (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 (void)time(&then);
X
X kread((caddr_t)&freemem,freememaddr,sizeof(freemem));
X kread((caddr_t)&sysinfo,sysinfoaddr,sizeof(sysinfo));
X kread((caddr_t)&minfo,minfoaddr,sizeof(minfo));
X
X#ifdef RIGHTEOUS
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 ","%6ld",sysidelta(bread));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"bwrite ","%6ld",sysidelta(bwrite));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"lread ","%6ld",sysidelta(lread));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"lwrite ","%6ld",sysidelta(lwrite));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"swapin ","%6ld",sysidelta(swapin));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"swapout ","%6ld",sysidelta(swapout));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"bswapin ","%6ld",sysidelta(bswapin));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"bswapout ","%6ld",sysidelta(bswapout));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"iget ","%6ld",sysidelta(iget));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"namei ","%6ld",sysidelta(namei));
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"dirblk ","%6ld",sysidelta(dirblk));
X
X wmove(wscr,y++,PER_SEC1_TLX);
X if((ltmp = sysidelta(readch) - myreadcnt) < 0)
X ltmp = 0;
X disp_info_long(wscr,"readch ","%6ld",ltmp);
X myreadcnt = 0; /* reset /dev/mem & /dev/kmem read count*/
X
X wmove(wscr,y++,PER_SEC1_TLX);
X disp_info_long(wscr,"writch ","%6ld",sysidelta(writech));
X
X y = PER_SEC_TLY + 1;
X/*
X wmove(wscr,y++,PER_SEC2_TLX);
X disp_info_long(wscr,"rcvint ","%5ld",sysidelta(rcvint));
X wmove(wscr,y++,PER_SEC2_TLX);
X disp_info_long(wscr,"xmtint ","%5ld",sysidelta(xmtint));
X wmove(wscr,y++,PER_SEC2_TLX);
X disp_info_long(wscr,"mdmint ","%5ld\n",sysidelta(mdmint));
X*/
X wmove(wscr,y++,PER_SEC2_TLX);
X disp_info_long(wscr,"rawch ","%5ld\n",sysidelta(rawch));
X wmove(wscr,y++,PER_SEC2_TLX);
X disp_info_long(wscr,"canch ","%5ld\n",sysidelta(canch));
X wmove(wscr,y++,PER_SEC2_TLX);
X disp_info_long(wscr,"outch ","%5ld\n",sysidelta(outch));
X
X y++;
X wmove(wscr,y++,PER_SEC2_TLX);
X disp_info_long(wscr,"msg ","%5ld\n",sysidelta(msg));
X wmove(wscr,y++,PER_SEC2_TLX);
X disp_info_long(wscr,"sema ","%5ld\n",sysidelta(sema));
X
X y++;
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 ","%4ld",sysidelta(pswitch));
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"syscall ","%4ld",sysidelta(syscall));
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"sysread ","%4ld",sysidelta(sysread));
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"syswrit ","%4ld",sysidelta(syswrite));
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"sysfork ","%4ld",sysidelta(sysfork));
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"sysexec ","%4ld",sysidelta(sysexec));
X
X y++;
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"runque ","%4ld",sysidelta(runque));
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"runocc ","%4ld",sysidelta(runocc));
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"swpque ","%4ld",sysidelta(swpque));
X wmove(wscr,y++,PER_SEC3_TLX);
X disp_info_long(wscr,"swpocc ","%4ld",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 sysinfo_last = sysinfo;
X minfo_last = minfo;
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 'q':
X case A_ESC:
X goto GOOD_BYE;
X case 'P':
X case 'p':
X case 'm':
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 }
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 }
X }
X break;
X }
X }
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 0624152590 u386mon.c &&
chmod 0644 u386mon.c ||
echo "restore of u386mon.c failed"
set `wc -c u386mon.c`;Wc_c=$1
if test "$Wc_c" != "26771"; then
echo original size 26771, current size $Wc_c
fi
# ============= var.c ==============
echo "x - extracting var.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > var.c &&
X/*+-------------------------------------------------------------------------
X var.c - u386mon var struct display
X
X Defined functions:
X display_var(win,y,x)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
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_buf ","%5d",v.v_buf);
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_file ","%5d",v.v_file);
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_proc ","%5d",v.v_proc);
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_sptmap ","%5d",v.v_sptmap);
X wmove(win,y++,x);
X disp_static_int(win,"v_vhndfrac ","%5d",v.v_vhndfrac);
X wmove(win,y++,x);
X disp_static_int(win,"v_maxpmem ","%5d",v.v_maxpmem);
X
X} /* end of display_var */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of var.c */
SHAR_EOF
$TOUCH -am 0624151990 var.c &&
chmod 0644 var.c ||
echo "restore of var.c failed"
set `wc -c var.c`;Wc_c=$1
if test "$Wc_c" != "1513"; then
echo original size 1513, current size $Wc_c
fi
# ============= libkmem.h ==============
echo "x - extracting libkmem.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > libkmem.h &&
X/*+-----------------------------------------------------------------------
X libkmem.h
X ...!emory!n4hgf!wht
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
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 0624151990 libkmem.h &&
chmod 0644 libkmem.h ||
echo "restore of libkmem.h failed"
set `wc -c libkmem.h`;Wc_c=$1
if test "$Wc_c" != "636"; then
echo original size 636, current size $Wc_c
fi
echo "End of part 2, continue with part 3"
exit 0
---------------------------------------------------------------------
Warren Tucker, TuckerWare gatech!n4hgf!wht or wht%n4hgf@gatech.edu
Ker-au'-lo-phon. An 8-foot partial flue-stop, having metal pipes
surmounted by adjustable rings, and with a hole bored near the top of
each pipe. Tone soft and "reedy".