home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
1
/
1506
< prev
next >
Wrap
Internet Message Format
|
1990-12-28
|
50KB
From: wht@n4hgf.uucp (Warren Tucker)
Newsgroups: alt.sources
Subject: u386mon 1.0, UNIX 386 system monitor, part 01/02
Message-ID: <119@n4hgf.uucp>
Date: 24 Jun 90 20:14:49 GMT
Submitted-by: wht@n4hgf
Archive-name: u386mon.1.00/part01
This is u386mon, a "performance" monitor for SCO UNIX V/386. It may
work with other UNIX systems with a little work. It requires terminfo
style curses and will use color if you have it. It works best with
a 43 line (or greater) screen, but will work with a 25 line screen
with some limitations. It has been tested with 25 and 43 line screens
on the multiscreen console and on a Wyse 60 (using terminfo wy60,
yielding interesting "color" mappings).
#!/bin/sh
# This is u386mon.1.00, a shell archive (shar 3.30)
# made 06/24/1990 20:11 UTC by wht@n4hgf
# Source directory /u1/src/u386mon
#
# existing files WILL be overwritten
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 10903 -rw-r--r-- README
# 6843 -rw-r--r-- Makefile
# 2456 -rw-r--r-- bootinfo.c
# 4232 -rw-r--r-- detail.c
# 15535 -rw-r--r-- det_proc.c
# 4713 -rw-r--r-- disputil.c
# 2441 -rw-r--r-- libkmem.c
# 2443 -rw-r--r-- libmem.c
# 1658 -rw-r--r-- libswap.c
# 2312 -rw-r--r-- libnlsym.c
# 2525 -rw-r--r-- nlsym.c
# 3188 -rw-r--r-- proc.c
# 1662 -rw-r--r-- tune.c
# 26771 -rw-r--r-- u386mon.c
# 1513 -rw-r--r-- var.c
# 636 -rw-r--r-- libkmem.h
# 632 -rw-r--r-- libmem.h
# 557 -rw-r--r-- libswap.h
# 603 -rw-r--r-- libnlsym.h
# 5906 -rw-r--r-- lint_args.h
# 4921 -rw-r--r-- nlsym.h
# 2852 -rw-r--r-- u386mon.h
#
if touch 2>&1 | fgrep 'mmdd' > /dev/null
then TOUCH=touch
else TOUCH=true
fi
# ============= README ==============
echo "x - extracting README (Text)"
sed 's/^X//' << 'SHAR_EOF' > README &&
Xu386mon README - last updated Fri Jun 22 19:31:50 EDT 1990
X
XThis is u386mon, a "performance" monitor for SCO UNIX V/386. It may
Xwork with other UNIX systems with a little work. It requires terminfo
Xstyle curses and will use color if you have it. It works best with
Xa 43 line (or greater) screen, but will work with a 25 line screen
Xwith some limitations. It has been tested with 25 and 43 line screens
Xon the multiscreen console and on a Wyse 60 (using terminfo wy60,
Xyielding interesting "color" mappings).
X
XThis little light show has already helped me diagnose the traditional
X"stop-the-world-and-beat-disk-continually-for-15-seconds" problem as
Xmemory exhaustion. It has also been a good learning experience.
X
XRead through this and you will finally reach "How to get going" below.
X
XSample output
X=============
X(with 43-line screen; a 25 line screen will be missing Var/Bootinfo/Tune/Proc)
X
X u386mon xxxxx n4hgf - i386 3.2 03:12:48 wht@n4hgf
X---- CPU --- tot usr ker brk ---------------------------------------------------
X Instant % 17 4 13 0 uukkkkkk
X 5 Sec Avg % 71 48 23 0 uuuuuuuuuuuuuuuuuuuuuuuukkkkkkkkkkk
X10 Sec Avg % 82 66 16 0 uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuukkkkkkkk
X---- Wait -- tot io swp pio -- (% of real time) -------------------------------
X Instant % 0 0 0 0
X 5 Sec Avg % 2 2 0 0 i
X10 Sec Avg % 1 1 0 0
X---- Sysinfo/Minfo --- (last 1 second activity) --------------------------------
Xbread 0 rawch 0 pswitch 8 vfault 0 unmodfl 0
Xbwrite 7 canch 0 syscall 16 demand 0 psoutok 0
Xlread 0 outch 3076 sysread 4 pfault 0 psinfai 0
Xlwrite 7 syswrit 5 cw 0 psinok 0
Xphread 0 msg 0 sysfork 0 steal 0 rsout 0
Xphwrit 0 sema 0 sysexec 0 frdpgs 0 rsin 0
Xiget 0 vfpg 0
Xnamei 0 maxmem 5716k runque 1 sfpg 0 pages on
Xdirblk 0 frmem 3036k runocc 1 vspg 0 swap 0
Xreadch 34680 mem used 47% swpque 0 sspg 0 cache 0
Xwritch 3076 nswap 10000k swpocc 0 unmodsw 0 file 0
X frswp 10000k
X swp used 0%
X
X
X
X-- Var --------- -- Bootinfo ---------- -- Tune --------- -- Proc ---
Xv_buf 600 basemem 655360 t_gpgslo 25 sleep 23
Xv_inode 200 extmem 6291456 t_gpgshi 40 run 0
Xv_file 200 bflags 00000000 t_gpgsmsk 0x420 zombie 0
Xv_mount 5 memory avail t_ageintvl 9 stop 0
Xv_proc 100 00000000 000a0000 t_maxsc 1 idle 0
Xv_clist 200 00100000 00600000 t_maxfc 1 onproc 1
Xv_sptmap 50 00f40000 00060000 NODM t_maxumem 2560 xbrk 0
Xv_vhndfrac 16 memory used t_bdflushr 1 total 24
Xv_maxpmem 0 00000000 00004000 RSVD t_minarmem 25 in mem 24
X 006b9000 00038000 KBSS t_minasmem 25
X 006f1000 0000f000 KDTA
X 00fa5000 0005b000 KTXT
X
X
XThe main display
X================
X
XA brief description of reported information:
X
X1. The CPU utilization is shown with smoothing of 1 ("instant"),
X 5 and 10 seconds. Total CPU usage is shown, with user, kernel
X and "break" subdivided. Most performance utilities (vmstat)
X lump kernel (CPU_KERNEL) and wait (CPU_WAIT) times together
X as kernel time. u386mon considers CPU_WAIT time as idle (the
X CPU could have been doing something if an otherwise ready process
X wasn't waited).
X
X On a color display, total cpu utilization is displayed in
X green if the cpu utilization is below 70%, yellow if utilization
X is between 70% and 89% and red if 90% or above.
X
X2. The Wait display shows the 1 ("instant"), 5 and 10 second smoothed
X percentages of real time no process could be run because otherwise
X ready to run processes were waiting on logical, swap or physical I/O.
X
X On a color display, total wait time is displayed in green if it is
X below 30%, yellow if utilization is between 30% and 49% and red if
X 50% or above.
X
X3. Sysinfo/Minfo display shows, generally, the number of events for a
X measured value since the last display update. For example, runque
X shows the number of times a process was placed on the run queue.
X An exception is the memory and swap space fields: These numbers
X reflect absolute current utilization.
X
X4. If you run u386mon on a 43 line display, extra information is displayed
X on the bottom of the screen (from the struct var v, bootinfo
X and proc kernel databases).
X
X5. On a color display, static numeric values, such as maxmem appear
X in blue (the same color as screen literals/labels). Dynamic
X numeric values are displayed in green, with the exception of
X total cpu and wait percentages, which appear in light green,
X red or yellow.
X
X6. An "INEXACT" indication on the top line means that u386mon was
X not scheduled quickly enough to capture accurate 1 second
X values. Continued INEXACT indication suggests the 5 and 10
X second smoothed values are also wrong.
X
X An "INVALID" indication means u386mon was not scheduled for 4
X seconds or more; all dynamic values are suspect.
X IN GENERAL, if you see any red characters on the display,
X immediately take grain of salt. If you have no color screen
X and still see red, add tequila to salt.
X
X7. If you are running as root, you may use the -l switch or the
X 'l' command to lock u386mon into memory. If you do this, PLOCK
X will appear at the top of the screen to remind you of this hoggy
X behavior. The u386mon process will not be listed in a process
X status display since SSYS (locked, resident) processes are not
X shown.
X
XProcess Status Display
X======================
X
X1. Pressing 'p' causes a process status display of sorts to be
X shown, overlaying Sysinfo/Minfo on a 25 line screen or
X Var/Bootinfo/Tune/Proc on a 43 line screen. On a 43 line screen, 'P'
X causes a larger ps display to be shown, overlaying Sysinfo/Minfo and
X Var/Bootinfo/Tune/Proc.
X
X Sample output:
X
XS USER PID CPU PRI NI UCPU SCPU SIZE TTY CMD
Xs root 148 0 26 20 0:00 0:05 108 ?? /etc/cron
Xs wht 14946 2 39 20 0:02 0:11 224 05 TMR 01000a12
Xs wht 14947 2 39 20 0:02 0:11 220 05 TMR 01011101
Xs wht 14950 0 27 20 0:00 0:02 228 05 IP 01000a12
Xs wht 14951 1 27 20 0:00 0:02 224 05 IP 01011101
Xs wht 14952 0 27 20 0:01 0:02 228 05 TP4 01000a12
Xs wht 14953 1 27 20 0:01 0:03 224 05 TP4 01011101
Xs wht 14957 0 27 20 0:00 0:04 200 05 smpad.x
Xs wht 14960 1 27 20 0:00 0:04 204 05 mmpad.x
Xs root 15044 0 28 20 0:01 0:01 296 12 vi README
Xs uucp 15053 0 30 26 0:00 0:00 696 ?? /usr/lib/uucp/uusched
Xs uucp 15055 0 30 26 0:00 0:00 748 ?? UUCICO -r1 -sgatech
Xs uucp 15060 0 28 26 0:00 0:00 768 ?? dialTBIT tty2E 8944201UC 192
X
X NOTES
X a. S - two character status
X 1st character - process status
X s - sleeping
X R - ready to run (might be running if u386mon were not)
X z - zombie
X d - stopped by debugger
X i - idle (in creation?)
X p - running on processor (on single CPU systems, only u386mon
X will show this)
X x - XBREAK - process growing or shrinking
X 2nd character - process swap status
X S - process is swapped
X blank - process is in memory
X
X b. If the process is running with setuid, a '#' appears to
X the right of the username.
X
X c. On color systems, processes ready to run are shown in yellow
X unless they are ready, but swapped out, in which case they
X are shown in red.
X
X3. Since a limited space is available for displaying process
X status, particularly on a 25-line screen, a selective elimination
X algorithm is used to whittle the list when insufficient room
X is available. init (pid 1) and system/resident (SSYS)
X processes are never displayed. When a display cycle is to begin
X and there is not room for all of the processes to be shown,
X processes are eliminated in the following order:
X
X a. 'getty', 'uugetty', 'sh', 'csh', and 'ksh'
X b. swapped and zombie processes
X c. sleeping processes
X
X If there is still insufficient room, an indication to the effect
X is displayed (tough cookies).
X
X
XA $0.0002 tour: why nlsym and /unix.nlsym?
X==========================================
X
XAccess to kernel (/dev/kmem) and physical (/dev/mem) memory and
Xswap (/dev/swap) is required for u386mon to do its thing.
XTo find kmem addresses of interest, an nlist(S) call must be made
Xagainst /unix. This can be quite expensive.
X
XThe 'nlist' procedure is performed by a separate program (nlsym)
Xand the resulting nlist structure array is stored in /unix.nlsym.
Xu386mon thus may obtain nlist information rapidly without nlist(S) each
Xtime it is executed. Also stored in /unix.nlsym is a stat structure of
X/unix at the time of nlsym execution. A unique word is stored at the
Xend of the file in case /unix.nlsym's nlist structure is expanded for
Xother applications. The u386mon program reads /unix.nlsym by means
Xof facilities in libnlsym.c. If the stat structure in /unix.nlsym
Xdoes not match a dynamic stat of /unix or if the unique word does
Xnot match, the nlist information is not trusted and u386mon prompts
Xthe user to run (or have run) the nlsym program to update /unix.nlsym.
X
XMany symbols are nlist'ed by nlsym which are not used by u386mon.
XYou may find other uses for libnlsym/libkmem which makle use of them.
X
XHow to get going
X================
X
X1. you must run the make as root since u386mon must be setuid to
X 'mem' and nlsym must produce /unix.nlsym.
X
X2. nlsym must be run by root (the Makefile will do this the first time)
X
X3. making against Makefile as root will
X a. make nlsym
X b. make u386mon and set-gid to group 'mem'
X c. run nlsym to produce /unix.nlsym
X
X4. Sources are in 4-spaced tab format (please don't flame :-)).
X
X5. You may have to chgrp mem /dev/swap; I did. For some reason,
X I found the group name for /dev/swap on my system to be 'network'.
X I guess something may have been broken by my changing the group,
X but it hasn't bit me yet.
X
X6. 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
XComments are appreciated.
XWarren Tucker N4HGF
Xemory!n4hgf!wht -or- wht%n4hgf.uucp@emory.mathcs.emory.edu
X
SHAR_EOF
$TOUCH -am 0624152190 README &&
chmod 0644 README ||
echo "restore of README failed"
set `wc -c README`;Wc_c=$1
if test "$Wc_c" != "10903"; then
echo original size 10903, current size $Wc_c
fi
# ============= Makefile ==============
echo "x - extracting Makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile &&
X#+--------------------------------------------------------------
X# Makefile for nlsym utilities for SCO UNIX V/386
X# ...!emory!n4hgf!wht
X#---------------------------------------------------------------
X#+:EDITS:*/
X#:06-21-1990-14:27-r@n4hgf-version x0.12 seems bug free
X#:06-19-1990-21:37-wht@n4hgf-get ready for 0.08 release
X
XVERSION = 1.00
X
X#handle Sys V make "feature" of using SHELL
XSHELL = /bin/sh
X
XCFLAGS = -c -Octl -DLINT_ARGS
X
XLIB = -lpanel -lcurses -lx
X#FCRC = fcrc -u $*.c ;
X
X.c.o:; $(FCRC) cc $(CFLAGS) $*.c
X
XSRC = \
X bootinfo.c\
X detail.c\
X det_proc.c\
X disputil.c\
X libkmem.c\
X libmem.c\
X libswap.c\
X libnlsym.c\
X nlsym.c\
X proc.c\
X tune.c\
X u386mon.c\
X var.c
X
XHDR = \
X libkmem.h\
X libmem.h\
X libswap.h\
X libnlsym.h\
X lint_args.h\
X nlsym.h\
X u386mon.h
X
XNLSYM_OBJ =\
X nlsym.o
X
XU386MON_OBJ =\
X u386mon.o\
X detail.o\
X det_proc.o\
X bootinfo.o\
X proc.o\
X tune.o\
X var.o\
X disputil.o\
X libkmem.o\
X libmem.o\
X libswap.o\
X libnlsym.o
X
Xall: nlsym u386mon /unix.nlsym
X
Xnlsym: $(NLSYM_OBJ)
X cc -o $@ $(NLSYM_OBJ) $(LIB)
X
Xu386mon: $(U386MON_OBJ)
X cc -o $@ $(U386MON_OBJ) $(LIB)
X chmod 2711 u386mon
X chgrp mem u386mon
X
X/unix.nlsym: nlsym /unix
X nlsym
X chmod 644 /unix.nlsym
X
X#not delivered
Xsrc.fls: $(SRC) Makefile
X ls $(SRC) > src.fls
X
Xlint_args: src.fls
X echo ' ' > lint_args.h
X csh zgcc src.fls lint_args.h $(CFLAGS)
X
Xclean:
X rm -f $(U386MON_OBJ) $(NLSYM_OBJ) \
X core u386mon.lint Makefile.bak src.fls mkdep.*
X
Xclobber: clean
X rm -f nlsym u386mon
X
Xlint:
X lint -ux *.c > u386mon.lint
X
X#for shar 3.27 or later
Xshar:
X shar -a -n u386mon.$(VERSION) -l 50 -o $(VERSION).sh \
X README Makefile $(SRC) $(HDR)
X
X# MAKE DEPEND: regenerate .c:.h, .ol:.c, .ol:.asm dependencies automatically
X#
Xdepend:
X rm -f mkdep.rule.tmp
X if test '$(SRC)' ;\
X then (grep '^#include' $(SRC) \
X | sed -e 's?:[^<]*<\([^>]*\)>.*?: /usr/include/\1?'\
X -e 's?:[^"]*"\([^"]*\)".*?: \1?'\
X -e 's?\(.*\)\.c?\1.o?'\
X >> mkdep.rule.tmp) ;\
X fi
X
X echo '/^# DO NOT DELETE THIS LINE' >mkdep.ex.tmp
X echo '.+1,$$d' >>mkdep.ex.tmp
X echo 'r mkdep.rule.tmp' >> mkdep.ex.tmp
X echo 'w' >> mkdep.ex.tmp
X cp Makefile Makefile.new
X ex Makefile.new < mkdep.ex.tmp
X rm mkdep.ex.tmp mkdep.rule.tmp
X echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile.new
X echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY'>>Makefile.new
X echo '# see make depend above'>>Makefile.new
X mv Makefile Makefile.bak
X mv Makefile.new Makefile
X
X# DO NOT DELETE THIS LINE
Xbootinfo.o: /usr/include/curses.h
Xbootinfo.o: /usr/include/panel.h
Xbootinfo.o: /usr/include/sys/types.h
Xbootinfo.o: /usr/include/sys/bootinfo.h
Xbootinfo.o: u386mon.h
Xdetail.o: /usr/include/curses.h
Xdetail.o: /usr/include/panel.h
Xdetail.o: /usr/include/signal.h
Xdetail.o: /usr/include/string.h
Xdetail.o: /usr/include/fcntl.h
Xdetail.o: /usr/include/nlist.h
Xdetail.o: /usr/include/errno.h
Xdetail.o: /usr/include/time.h
Xdetail.o: /usr/include/pwd.h
Xdetail.o: /usr/include/utmp.h
Xdetail.o: /usr/include/sys/types.h
Xdetail.o: /usr/include/sys/utsname.h
Xdetail.o: /usr/include/sys/stat.h
Xdetail.o: /usr/include/sys/ascii.h
Xdetail.o: /usr/include/sys/param.h
Xdetail.o: /usr/include/sys/bootinfo.h
Xdetail.o: /usr/include/sys/tuneable.h
Xdetail.o: /usr/include/sys/sysinfo.h
Xdetail.o: /usr/include/sys/sysmacros.h
Xdetail.o: /usr/include/sys/immu.h
Xdetail.o: /usr/include/sys/region.h
Xdetail.o: /usr/include/sys/proc.h
Xdetail.o: /usr/include/sys/var.h
Xdetail.o: nlsym.h
Xdetail.o: libkmem.h
Xdetail.o: libnlsym.h
Xdetail.o: u386mon.h
Xdet_proc.o: /usr/include/curses.h
Xdet_proc.o: /usr/include/panel.h
Xdet_proc.o: /usr/include/signal.h
Xdet_proc.o: /usr/include/string.h
Xdet_proc.o: /usr/include/fcntl.h
Xdet_proc.o: /usr/include/nlist.h
Xdet_proc.o: /usr/include/errno.h
Xdet_proc.o: /usr/include/time.h
Xdet_proc.o: /usr/include/pwd.h
Xdet_proc.o: /usr/include/utmp.h
Xdet_proc.o: /usr/include/sys/types.h
Xdet_proc.o: /usr/include/sys/stat.h
Xdet_proc.o: /usr/include/sys/ascii.h
Xdet_proc.o: /usr/include/sys/param.h
Xdet_proc.o: /usr/include/sys/bootinfo.h
Xdet_proc.o: /usr/include/sys/tuneable.h
Xdet_proc.o: /usr/include/sys/sysinfo.h
Xdet_proc.o: /usr/include/sys/sysmacros.h
Xdet_proc.o: /usr/include/sys/immu.h
Xdet_proc.o: /usr/include/sys/region.h
Xdet_proc.o: /usr/include/sys/proc.h
Xdet_proc.o: /usr/include/sys/fs/s5dir.h
Xdet_proc.o: /usr/include/sys/user.h
Xdet_proc.o: /usr/include/sys/var.h
Xdet_proc.o: nlsym.h
Xdet_proc.o: libkmem.h
Xdet_proc.o: libmem.h
Xdet_proc.o: libswap.h
Xdet_proc.o: libnlsym.h
Xdet_proc.o: u386mon.h
Xdisputil.o: /usr/include/curses.h
Xdisputil.o: /usr/include/panel.h
Xdisputil.o: /usr/include/sys/types.h
Xdisputil.o: u386mon.h
Xlibkmem.o: /usr/include/sys/types.h
Xlibkmem.o: /usr/include/fcntl.h
Xlibkmem.o: libkmem.h
Xlibmem.o: /usr/include/sys/types.h
Xlibmem.o: /usr/include/fcntl.h
Xlibmem.o: libmem.h
Xlibswap.o: /usr/include/sys/types.h
Xlibswap.o: /usr/include/fcntl.h
Xlibswap.o: libswap.h
Xlibnlsym.o: /usr/include/stdio.h
Xlibnlsym.o: /usr/include/sys/types.h
Xlibnlsym.o: /usr/include/sys/stat.h
Xlibnlsym.o: /usr/include/fcntl.h
Xlibnlsym.o: /usr/include/nlist.h
Xlibnlsym.o: nlsym.h
Xlibnlsym.o: libnlsym.h
Xnlsym.o: /usr/include/stdio.h
Xnlsym.o: /usr/include/sys/types.h
Xnlsym.o: /usr/include/sys/stat.h
Xnlsym.o: /usr/include/fcntl.h
Xnlsym.o: /usr/include/nlist.h
Xnlsym.o: nlsym.h
Xproc.o: /usr/include/curses.h
Xproc.o: /usr/include/panel.h
Xproc.o: /usr/include/sys/types.h
Xproc.o: /usr/include/sys/param.h
Xproc.o: /usr/include/sys/immu.h
Xproc.o: /usr/include/sys/region.h
Xproc.o: /usr/include/sys/proc.h
Xproc.o: /usr/include/sys/var.h
Xproc.o: /usr/include/nlist.h
Xproc.o: nlsym.h
Xproc.o: libkmem.h
Xproc.o: libnlsym.h
Xproc.o: u386mon.h
Xtune.o: /usr/include/curses.h
Xtune.o: /usr/include/panel.h
Xtune.o: /usr/include/sys/types.h
Xtune.o: /usr/include/sys/tuneable.h
Xtune.o: u386mon.h
Xu386mon.o: /usr/include/curses.h
Xu386mon.o: /usr/include/panel.h
Xu386mon.o: /usr/include/signal.h
Xu386mon.o: /usr/include/string.h
Xu386mon.o: /usr/include/fcntl.h
Xu386mon.o: /usr/include/nlist.h
Xu386mon.o: /usr/include/errno.h
Xu386mon.o: /usr/include/time.h
Xu386mon.o: /usr/include/sys/types.h
Xu386mon.o: /usr/include/sys/lock.h
Xu386mon.o: /usr/include/sys/utsname.h
Xu386mon.o: /usr/include/sys/stat.h
Xu386mon.o: /usr/include/sys/ascii.h
Xu386mon.o: /usr/include/sys/param.h
Xu386mon.o: /usr/include/sys/bootinfo.h
Xu386mon.o: /usr/include/sys/tuneable.h
Xu386mon.o: /usr/include/sys/sysinfo.h
Xu386mon.o: /usr/include/sys/sysmacros.h
Xu386mon.o: /usr/include/sys/immu.h
Xu386mon.o: /usr/include/sys/region.h
Xu386mon.o: /usr/include/sys/proc.h
Xu386mon.o: /usr/include/sys/var.h
Xu386mon.o: nlsym.h
Xu386mon.o: libkmem.h
Xu386mon.o: libmem.h
Xu386mon.o: libswap.h
Xu386mon.o: libnlsym.h
Xu386mon.o: u386mon.h
Xvar.o: /usr/include/curses.h
Xvar.o: /usr/include/panel.h
Xvar.o: /usr/include/sys/types.h
Xvar.o: /usr/include/sys/var.h
Xvar.o: u386mon.h
X# DEPENDENCIES MUST END AT END OF FILE
X# IF YOU PUT STUFF HERE IT WILL GO AWAY
X# see make depend above
SHAR_EOF
$TOUCH -am 0624152590 Makefile &&
chmod 0644 Makefile ||
echo "restore of Makefile failed"
set `wc -c Makefile`;Wc_c=$1
if test "$Wc_c" != "6843"; then
echo original size 6843, current size $Wc_c
fi
# ============= bootinfo.c ==============
echo "x - extracting bootinfo.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > bootinfo.c &&
X/*+-------------------------------------------------------------------------
X bootinfo.c - u386mon bootinfo struct display
X
X Defined functions:
X bmemf_text(flags)
X display_bootinfo(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/bootinfo.h>
X#include "u386mon.h"
X
X/*+-------------------------------------------------------------------------
X bmemf_text(flags)
X--------------------------------------------------------------------------*/
Xchar *
Xbmemf_text(flags)
Xulong flags;
X{
X flags &= ~B_MEM_DOWN;
X if(!flags)
X return(" ");
X switch(flags)
X {
X case B_MEM_RSRVD: return("RSVD");
X case B_MEM_KTEXT: return("KTXT");
X case B_MEM_KDATA: return("KDTA");
X case B_MEM_KBSS: return("KBSS");
X case B_MEM_NODMA: return("NODM");
X }
X return("????");
X} /* end of bmemf_text */
X
X/*+-------------------------------------------------------------------------
X display_bootinfo(win,y,x)
X--------------------------------------------------------------------------*/
Xvoid
Xdisplay_bootinfo(win,y,x)
XWINDOW *win;
Xint y;
Xint x;
X{
Xregister itmp;
Xregister struct bootmem *bmem;
X
X use_cp(win,cpBANNER);
X wmove(win,y++,x);
X waddstr(win,"-- Bootinfo ----------");
X wmove(win,y++,x);
X disp_static_long(win,"basemem ","%7ldk ",bootinfo.basemem);
X wmove(win,y++,x);
X disp_static_long(win,"extmem ","%7ldk ",bootinfo.extmem);
X wmove(win,y++,x);
X disp_static_long(win,"bflags ","%08lx ",bootinfo.bootflags);
X
X wmove(win,y++,x); waddstr(win,"memory available ");
X for(itmp = 0; itmp < bootinfo.memavailcnt; itmp++)
X {
X bmem = &bootinfo.memavail[itmp];
X if(bmem->flags & B_MEM_DOWN)
X {
X bmem->base -= bmem->extent;
X bmem->flags &= ~B_MEM_DOWN;
X }
X wmove(win,y++,x);
X wprintw(win,"%08lx %08lx %s",bmem->base,bmem->extent,
X bmemf_text(bmem->flags));
X }
X
X wmove(win,y++,x); waddstr(win,"memory used ");
X for(itmp = 0; itmp < bootinfo.memusedcnt; itmp++)
X {
X bmem = &bootinfo.memused[itmp];
X if(bmem->flags & B_MEM_DOWN)
X {
X bmem->base -= bmem->extent;
X bmem->flags &= ~B_MEM_DOWN;
X }
X wmove(win,y++,x);
X wprintw(win,"%08lx %08lx %s",bmem->base,bmem->extent,
X bmemf_text(bmem->flags));
X }
X
X} /* end of display_bootinfo */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of bootinfo.c */
SHAR_EOF
$TOUCH -am 0624151990 bootinfo.c &&
chmod 0644 bootinfo.c ||
echo "restore of bootinfo.c failed"
set `wc -c bootinfo.c`;Wc_c=$1
if test "$Wc_c" != "2456"; then
echo original size 2456, current size $Wc_c
fi
# ============= detail.c ==============
echo "x - extracting detail.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > detail.c &&
X/*+-------------------------------------------------------------------------
X detail.c - UNIX 386 system monitor detail window
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 <pwd.h>
X#include <utmp.h>
X#include <sys/types.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
X#include "nlsym.h"
X#include "libkmem.h"
X#include "libnlsym.h"
X#include "u386mon.h"
X
X#define DPT_NONE 0
X#define DPT_PROC_STATUS 1
X#define DPT_PROC_STATUS43 2
X
XPANEL *mkpanel();
X
Xextern PANEL *pscr;
Xextern WINDOW *wscr;
X
XPANEL *pdet;
XWINDOW *wdet;
Xu_char detail_panel_type = DPT_NONE;
Xint detail_panel_length;
Xint detail_panel_cols;
X
X/*+-------------------------------------------------------------------------
X detail_panel_proc_status_init(full43)
X--------------------------------------------------------------------------*/
Xvoid
Xdetail_panel_proc_status_init(full43)
Xint full43;
X{
X/*
X#define DETAIL_PROC_STATUS_COLS ((LINES >= 43) ? EXTRA4_TLX - 1 : PER_SEC4_TLX)
Xdetail_panel_cols = DETAIL_PROC_STATUS_COLS;
X*/
X
X#define DETAIL_TLY ((LINES >= 43) ? ((full43)?PER_SEC_TLY:PER_SEC_TLY+14)\
X : PER_SEC_TLY)
X
X#define DETAIL_LENGTH (MSG_TLY - DETAIL_TLY)
X
X detail_panel_length = DETAIL_LENGTH;
X detail_panel_cols = COLS;
X if(!(pdet = mkpanel(detail_panel_length,detail_panel_cols,DETAIL_TLY,0)))
X {
X leave_text("cannot make detail panel",0);
X }
X show_panel(pdet);
X top_panel(pdet);
X wdet = panel_window(pdet);
X display_proc_stats(wdet,1);
X
X} /* end of detail_panel_proc_status_init */
X
X/*+-------------------------------------------------------------------------
X detail_panel_proc_status_update()
X--------------------------------------------------------------------------*/
Xvoid
Xdetail_panel_proc_status_update()
X{
X display_proc_stats(wdet,0);
X} /* end of detail_panel_proc_status_update */
X
X/*+-------------------------------------------------------------------------
X detail_destroy()
X--------------------------------------------------------------------------*/
Xvoid
Xdetail_destroy()
X{
X hide_panel(pdet);
X delwin(wdet);
X del_panel(pdet);
X top_panel(pscr);
X disp_msg(cpINFO,"");
X detail_panel_type = DPT_NONE;
X} /* end of detail_destroy */
X
X/*+-------------------------------------------------------------------------
X detail_panel_cmd(cmd)
X
X command: m main screen
X p proc status
X--------------------------------------------------------------------------*/
Xvoid
Xdetail_panel_cmd(cmd)
Xchtype cmd;
X{
X switch(cmd)
X {
X case 'm':
X if(detail_panel_type != DPT_NONE)
X detail_destroy();
X break;
X
X case 'P':
X if(detail_panel_type == DPT_PROC_STATUS43)
X break;
X if(detail_panel_type != DPT_NONE)
X detail_destroy();
X detail_panel_proc_status_init(1);
X detail_panel_type = DPT_PROC_STATUS43;
X break;
X
X case 'p':
X if(detail_panel_type == DPT_PROC_STATUS)
X break;
X if(detail_panel_type != DPT_NONE)
X detail_destroy();
X detail_panel_proc_status_init(0);
X detail_panel_type = DPT_PROC_STATUS;
X break;
X }
X} /* end of detail_panel_cmd */
X
X/*+-------------------------------------------------------------------------
X detail_panel_update()
X--------------------------------------------------------------------------*/
Xvoid
Xdetail_panel_update()
X{
X switch(detail_panel_type)
X {
X case DPT_PROC_STATUS:
X case DPT_PROC_STATUS43:
X detail_panel_proc_status_update();
X break;
X }
X} /* end of detail_panel_update */
X
X/*+-------------------------------------------------------------------------
X detail_init()
X--------------------------------------------------------------------------*/
Xvoid
Xdetail_init()
X{
X} /* end of detail_init */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of detail.c */
SHAR_EOF
$TOUCH -am 0624151990 detail.c &&
chmod 0644 detail.c ||
echo "restore of detail.c failed"
set `wc -c detail.c`;Wc_c=$1
if test "$Wc_c" != "4232"; then
echo original size 4232, current size $Wc_c
fi
# ============= det_proc.c ==============
echo "x - extracting det_proc.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > det_proc.c &&
X/* CHK=0xC5D1 */
X/*+-------------------------------------------------------------------------
X det_proc.c - UNIX V/386 system monitor proc status detail
X ...!emory!n4hgf!wht
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
X/*:01-05-1989-13:27-wht-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 <pwd.h>
X#include <utmp.h>
X#include <sys/types.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/fs/s5dir.h>
X#include <sys/user.h>
X#include <sys/var.h>
X
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
Xextern int errno;
X
Xextern int nprocs;
Xextern struct var v;
Xextern struct proc *procs;
Xextern struct proc *oldprocs;
X
Xint mypid;
Xint noldprocs = 0;
Xint nprocs = 0;
Xint max_procs_to_display;
X
Xstruct user user;
X
X#define min(a,b) (((a) > (b)) ? (b) : (a))
X
X#define p_slotnum p_sigflags[0] /* reuse a field we dont look at */
X
X#define MAX_UTMP 32
Xint nutmps = 0;
Xstruct utmp utmps[MAX_UTMP];
X
X/*+-------------------------------------------------------------------------
X proc_pid_compare(p1,p2)
X--------------------------------------------------------------------------*/
Xproc_pid_compare(p1,p2)
Xstruct proc *p1;
Xstruct proc *p2;
X{
X return(p1->p_pid - p2->p_pid);
X} /* end of proc_pid_compare */
X
X/*+-------------------------------------------------------------------------
X read_and_sort_procs(initial)
X--------------------------------------------------------------------------*/
Xvoid
Xread_and_sort_procs(initial)
Xint initial;
X{
Xregister int iproc;
Xregister char *cptr;
Xstruct proc *tproc;
X
X disp_msg(cpINFO,"");
X if(!initial)
X {
X (void)memcpy((char *)oldprocs,(char *)procs,v.v_proc * sizeof(struct proc));
X noldprocs = nprocs;
X }
X
X/* read current procs */
X grok_proc();
X
X/* if slot not in use, force to end when sorting */
X nprocs = 0;
X for(iproc = 0; iproc < v.v_proc; iproc++)
X {
X tproc = procs + iproc;
X tproc->p_slotnum = iproc; /* save slot number */
X if( (tproc->p_stat == 0) || /* if slot not in use, ... */
X (tproc->p_pid == 1) || /* ... or proc is init, ... */
X (tproc->p_flag & SSYS)) /* ... or proc is system process */
X { /* eliminate from consideration */
X tproc->p_pid = 32767; /* force below selected procs in qsort */
X continue;
X }
X nprocs++;
X }
X
X/* if too many procs, whittle down */
X if(nprocs > max_procs_to_display)
X {
X nprocs = 0;
X for(iproc = 0; iproc < v.v_proc; iproc++)
X {
X tproc = procs + iproc;
X if(tproc->p_pid == 32767) /* previously eliminated? */
X continue;
X else if(get_user(tproc,&user))
X {
X if( !strcmp(cptr = user.u_comm,"csh") ||
X !strcmp(cptr,"sh") ||
X !strcmp(cptr,"ksh") ||
X !strcmp(cptr,"getty") ||
X !strcmp(cptr,"uugetty") )
X {
X tproc->p_pid = 32767;
X continue;
X }
X }
X nprocs++;
X }
X disp_msg(cpLIT,"shells and gettys not displayed");
X }
X
X/* if still too many procs, whittle swapped */
X if(nprocs > max_procs_to_display)
X {
X nprocs = 0;
X for(iproc = 0; iproc < v.v_proc; iproc++)
X {
X tproc = procs + iproc;
X if(tproc->p_pid == 32767) /* previously eliminated? */
X continue;
X else if((!(tproc->p_flag & SLOAD) && (tproc->p_stat != SRUN)) ||
X (tproc->p_stat == SZOMB))
X {
X tproc->p_pid = 32767;
X continue;
X }
X nprocs++;
X }
X disp_msg(cpLIT,"shells, gettys and swapped/zombie procs not displayed");
X }
X/* if still too many procs, whittle hard */
X if(nprocs > max_procs_to_display)
X {
X nprocs = 0;
X for(iproc = 0; iproc < v.v_proc; iproc++)
X {
X tproc = procs + iproc;
X if(tproc->p_pid == 32767) /* previously eliminated? */
X continue;
X else if(tproc->p_stat == SSLEEP)
X {
X tproc->p_pid = 32767;
X continue;
X }
X nprocs++;
X }
X disp_msg(cpLIT,
X "shells, gettys and swapped/zombie/sleeping procs not displayed");
X }
X
X if(nprocs > max_procs_to_display)
X disp_msg(cpMED,"display size too small for all processes");
X
X/* sort new procs array */
X (void)qsort((char *)procs,(unsigned)v.v_proc,
X sizeof(struct proc),proc_pid_compare);
X
X if(initial)
X {
X (void)memcpy((char *)oldprocs,(char *)procs,
X v.v_proc * sizeof(struct proc));
X noldprocs = nprocs;
X }
X
X} /* end of read_and_sort_procs */
X
X/*+-------------------------------------------------------------------------
X read_utmp()
X--------------------------------------------------------------------------*/
Xvoid
Xread_utmp()
X{
Xint utmpfd;
Xregister struct utmp *tutmp = utmps;
X
X nutmps = 0;
X if((utmpfd = open("/etc/utmp",O_RDONLY,755)) < 0)
X leave_text("/etc/utmp open error",errno);
X
X while(read(utmpfd,(char *)(tutmp++),sizeof(struct utmp)) > 0)
X {
X if(++nutmps == MAX_UTMP)
X leave_text("too many utmp entries for me to handle",1);
X }
X (void)close(utmpfd);
X} /* end of read_utmp */
X
X/*+-------------------------------------------------------------------------
X find_utmp_for_pgrp(pgrp)
X--------------------------------------------------------------------------*/
Xstruct utmp *
Xfind_utmp_for_pgrp(pgrp)
Xint pgrp;
X{
Xstruct utmp *tutmp = utmps;
Xregister int count = nutmps;
X
X while(count--)
X {
X if(tutmp->ut_pid == pgrp)
X return(tutmp);
X tutmp++;
X }
X return((struct utmp *)0);
X} /* end of find_utmp_for_pgrp */
X
X/*+-------------------------------------------------------------------------
X pgrp_to_ttyname(pgrp)
X--------------------------------------------------------------------------*/
Xchar *
Xpgrp_to_ttyname(pgrp)
Xint pgrp;
X{
Xregister itmp;
Xstruct utmp *tutmp;
X
X if(!(tutmp = find_utmp_for_pgrp(pgrp)))
X {
X read_utmp();
X tutmp = find_utmp_for_pgrp(pgrp);
X }
X if(!tutmp)
X return("??");
X else
X {
X itmp = strlen(tutmp->ut_id);
X return(&tutmp->ut_id[(itmp >= 2) ? (itmp - 2) : 0]);
X }
X} /* end of pgrp_to_ttyname */
X
X/*+-------------------------------------------------------------------------
X get_user(tproc,tuser)
X--------------------------------------------------------------------------*/
Xget_user(tproc,tuser)
Xstruct proc *tproc;
Xstruct user *tuser;
X{
X register caddr_t uptr = (caddr_t)tuser;
X register int ubrdcount = sizeof(struct user);
X int ipde;
X paddr_t mptr;
X
X if(tproc->p_flag & SULOAD)
X {
X for(ipde = 0; ipde < tproc->p_usize; ipde++)
X {
X if(!tproc->p_ubptbl[ipde].pgm.pg_pres) /* if not resident */
X return(0);
X mptr = tproc->p_ubptbl[ipde].pgm.pg_pfn * NBPP;
X mread(uptr,(daddr_t)mptr,min(ubrdcount,NBPP));
X uptr += NBPP;
X if((ubrdcount -= NBPP) <= 0)
X break;
X }
X }
X else
X {
X mptr = tproc->p_ubdbd.dbd_blkno * NBPSCTR;
X sread(uptr,mptr,ubrdcount);
X }
X /*
X * we can get crap from swap if things change after we get
X * an address to read from, so validate user as best we can
X */
X return(tuser->u_ruid == tproc->p_uid); /* validate it */
X
X} /* end of get_user */
X
X/*+-------------------------------------------------------------------------
Xuid to username conversion; thanks for the idea to William LeFebvre
X--------------------------------------------------------------------------*/
X#define UID_NAME_HASH_SIZE 127 /* prime */
X#define HASH_EMPTY -1
X#define HASHIT(i) ((i) % UID_NAME_HASH_SIZE)
X
Xstruct uid_name_hash_entry {
X int uid;
X char name[10];
X};
X
Xstruct uid_name_hash_entry uid_name_table[UID_NAME_HASH_SIZE];
Xint uid_count = 0;
X
X/*+-------------------------------------------------------------------------
X init_uid_name_hash()
X--------------------------------------------------------------------------*/
Xvoid
Xinit_uid_name_hash()
X{
Xregister int ihash = 0;
Xregister struct uid_name_hash_entry *hashent = uid_name_table;
X
X while(ihash++ < UID_NAME_HASH_SIZE)
X {
X hashent->uid = HASH_EMPTY;
X hashent++;
X }
X} /* end of init_uid_name_hash */
X
X/*+-------------------------------------------------------------------------
X uid_name_enter(uid,name)
X--------------------------------------------------------------------------*/
Xint
Xuid_name_enter(uid,name)
Xregister int uid;
Xregister char *name;
X{
Xregister int table_uid;
Xregister int hashval;
X
X if(++uid_count >= UID_NAME_HASH_SIZE)
X leave_text("too many user names",1);
X
X hashval = HASHIT(uid);
X while((table_uid = uid_name_table[hashval].uid) != HASH_EMPTY)
X {
X if(table_uid == uid)
X return(hashval);
X hashval = (hashval + 1) % UID_NAME_HASH_SIZE;
X }
X
X uid_name_table[hashval].uid = uid;
X (void)strncpy(uid_name_table[hashval].name,name,
X sizeof(uid_name_table[0].name));
X
X return(hashval);
X
X} /* end of uid_name_enter */
X
X/*+-------------------------------------------------------------------------
X getpwent_and_enter(uid)
X--------------------------------------------------------------------------*/
Xgetpwent_and_enter(uid)
Xregister int uid;
X{
Xregister int hashval;
Xregister struct passwd *pwd;
Xchar errant[10];
Xstruct passwd *getpwuid();
X
X pwd = getpwuid(uid);
X endpwent();
X if(pwd)
X {
X hashval = uid_name_enter(pwd->pw_uid,pwd->pw_name);
X return(hashval);
X }
X (void)sprintf(errant,"%d",uid);
X return(uid_name_enter(uid,errant));
X} /* end of getpwent_and_enter */
X
X/*+-------------------------------------------------------------------------
X uid_to_name(uid)
X--------------------------------------------------------------------------*/
Xchar *
Xuid_to_name(uid)
Xregister int uid;
X{
Xregister int uid_hash;
Xregister int table_uid;
X
X uid_hash = HASHIT(uid);
X while((table_uid = uid_name_table[uid_hash].uid) != uid)
X {
X if(table_uid == HASH_EMPTY)
X {
X /* not in hash table */
X uid_hash = getpwent_and_enter(uid);
X break; /* out of while */
X }
X uid_hash = (uid_hash + 1) % UID_NAME_HASH_SIZE;
X }
X return(uid_name_table[uid_hash].name);
X} /* end of char *uid_to_name */
X
X/*+-----------------------------------------------------------------------
X char *get_cpu_time_str(ticks)
X 6-char static string address is returned
X------------------------------------------------------------------------*/
Xchar *get_cpu_time_str(ticks)
Xtime_t ticks;
X{
Xstatic char timestr[10];
Xtime_t mm,ss;
Xextern int hz;
X
X ticks /= hz;
X mm = ticks / 60L;
X ticks -= mm * 60L;
X ss = ticks;
X
X if(mm > 999)
X (void)sprintf(timestr,"%5ldm",mm);
X else
X (void)sprintf(timestr,"%3lu:%02lu",mm,ss);
X return(timestr);
X} /* end of get_cpu_time_str */
X
X#define PROC_Y 1
X#define PROC_X 0
X#define UID_X 2
X#define PID_X 12
X#define CPU_X 18
X#define PRI_X 22
X#define NICE_X 26
X#define UTIME_X 29
X#define STIME_X 36
X#define SIZE_X 43
X#define TTY_X 48
X#define CMD_X 52
X
X/*+-------------------------------------------------------------------------
X display_proc_stat(win,iproc,initial)
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XS USER PID CPU PRI NI UCPU SCPU SIZE TTY CMD
X#!########X ##### ### ### ## ###### ###### #### ### ########
X--------------------------------------------------------------------------*/
Xvoid
Xdisplay_proc_stat(win,iproc,initial)
XWINDOW *win;
Xregister int iproc;
Xregister int initial;
X{
Xregister int positioned = 0;
Xregister struct proc *tproc = procs + iproc;
Xstruct proc *oproc = oldprocs + iproc;
Xint got_user;
Xstatic char *p_stat_str = " sRzdipx"; /* dependent on values of SSLEEP etc */
Xchar buf[20];
X
X use_cp(win,cpINFO);
X if((tproc->p_stat == SRUN) && !(tproc->p_flag & SLOAD))
X use_cp(win,cpHIGH);
X else if((tproc->p_stat == SRUN) || (oproc->p_stat == SRUN))
X use_cp(win,cpMED);
X if(tproc->p_pid != tproc->p_pid)
X initial = 1;
X
X wmove(win,PROC_Y + iproc,PROC_X);
X waddch(win,(chtype)p_stat_str[tproc->p_stat]);
X waddch(win,(tproc->p_flag & SLOAD) ? (chtype)' ' : (chtype)'S');
X positioned = 1;
X
X if(initial)
X {
X if(!positioned)
X wmove(win,PROC_Y + iproc,PROC_X + UID_X);
X (void)sprintf(buf,"%8s",uid_to_name(tproc->p_uid));
X waddstr(win,buf);
X waddch(win,(tproc->p_uid != tproc->p_suid) ? '#' : ' ');
X waddch(win,' ');
X positioned = 1;
X }
X else
X positioned = 0;
X
X if(initial)
X {
X if(!positioned)
X wmove(win,PROC_Y + iproc,PROC_X + PID_X);
X (void)sprintf(buf,"%5d ",tproc->p_pid);
X waddstr(win,buf);
X positioned = 1;
X }
X else
X positioned = 0;
X
X if(initial || (tproc->p_cpu != oproc->p_cpu))
X {
X if(!positioned)
X wmove(win,PROC_Y + iproc,PROC_X + CPU_X);
X (void)sprintf(buf,"%3u ",tproc->p_cpu);
X waddstr(win,buf);
X positioned = 1;
X }
X else
X positioned = 0;
X
X if(initial || (tproc->p_pri != oproc->p_pri))
X {
X if(!positioned)
X wmove(win,PROC_Y + iproc,PROC_X + PRI_X);
X (void)sprintf(buf,"%3u ",tproc->p_pri);
X waddstr(win,buf);
X positioned = 1;
X }
X else
X positioned = 0;
X
X if(initial || (tproc->p_nice != oproc->p_nice))
X {
X if(!positioned)
X wmove(win,PROC_Y + iproc,PROC_X + NICE_X);
X (void)sprintf(buf,"%2d ",tproc->p_nice);
X waddstr(win,buf);
X positioned = 1;
X }
X else
X positioned = 0;
X
X/* since not saving user area, always update fields from it */
X if(!positioned)
X wmove(win,PROC_Y + iproc,PROC_X + UTIME_X);
X if(got_user = get_user(tproc,&user))
X {
X waddstr(win,get_cpu_time_str(user.u_utime));
X waddch(win,' ');
X waddstr(win,get_cpu_time_str(user.u_stime));
X waddch(win,' ');
X/*
X * process size:
X *
X * There are ways that seem right to a man, but the end of them is death.
X * u_tsize and friends are not clicks, but in bytes.
X * I thought this would have been:
X * (ctob((u_long)user.u_tsize + user.u_dsize + user.u_ssize)) / 1024);
X * At least this makes numbers agree with /bin/ps, although I cannot
X * figure out why there is one extra page charged by ps (user is 2 pages).
X */
X (void)sprintf(buf,"%4lu ",
X (((u_long)user.u_tsize + 511) / 1024) +
X (((u_long)user.u_dsize + 511) / 1024) +
X (((u_long)user.u_ssize + 511) / 1024) +
X (((u_long)((user.u_tsize)?1:0) * NBPP) / 1024));
X waddstr(win,buf);
X }
X else
X waddstr(win,"------ ------ ---- ");
X
X/*
X positioned = 1;
X if(!positioned)
X wmove(win,PROC_Y + iproc,PROC_X + TTY_X);
X*/
X (void)sprintf(buf,"%3.3s ",pgrp_to_ttyname(tproc->p_pgrp));
X waddstr(win,buf);
X positioned = 1;
X
X/*
X if(!positioned)
X wmove(win,PROC_Y + iproc,PROC_X + CMD_X);
X*/
X if(got_user)
X {
X register char *cptr = user.u_psargs;
X int y,x,maxx = getmaxx(win);
X getyx(win,y,x);
X while(*cptr && (x < maxx))
X {
X *cptr &= 0x7F;
X if(*cptr < 0x20)
X *cptr = 0x20;
X waddch(win,*cptr);
X cptr++,x++;
X }
X }
X else
X {
X switch(tproc->p_stat)
X {
X case SZOMB:
X waddstr(win,"<zombie>");
X break;
X case SXBRK:
X waddstr(win,"<xbreak>");
X break;
X default:
X waddstr(win,"<swapped>");
X }
X }
X
X wclrtoeol(win);
X
X} /* end of display_proc_stat */
X
X/*+-------------------------------------------------------------------------
X display_proc_stats(win,initial)
X--------------------------------------------------------------------------*/
Xvoid
Xdisplay_proc_stats(win,initial)
XWINDOW *win;
Xint initial;
X{
Xregister int iproc;
Xint y,x;
X
X if(initial)
X {
X use_cp(win,cpBANNER);
X wmove(win,0,0);
X waddstr(win,
X "S USER PID CPU PRI NI UCPU SCPU SIZE TTY CMD");
X getyx(win,y,x);
X while(x < getmaxx(win))
X waddch(win,(chtype)' '),x++;
X }
X mypid = getpid();
X max_procs_to_display = getmaxy(win) - PROC_Y;
X read_and_sort_procs(initial);
X max_procs_to_display = min(nprocs,max_procs_to_display);
X for(iproc = 0; iproc < max_procs_to_display; iproc++)
X display_proc_stat(win,iproc,1);
X wclrtobot(win);
X} /* end of display_proc_stats */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of det_proc.c */
SHAR_EOF
$TOUCH -am 0624151990 det_proc.c &&
chmod 0644 det_proc.c ||
echo "restore of det_proc.c failed"
set `wc -c det_proc.c`;Wc_c=$1
if test "$Wc_c" != "15535"; then
echo original size 15535, current size $Wc_c
fi
# ============= disputil.c ==============
echo "x - extracting disputil.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > disputil.c &&
X/*+-------------------------------------------------------------------------
X disputil.c - u386mon display utilities
X
X Defined functions:
X clear_area(win,y,x,len)
X clear_area_char(win,y,x,len,fillchar)
X disp_info_int(win,label,fmt,value)
X disp_info_long(win,label,fmt,value)
X disp_static_int(win,label,fmt,value)
X disp_static_long(win,label,fmt,value)
X mkpanel(rows,cols,tly,tlx)
X pflush()
X wperror(win,desc)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
X/*:06-17-1990-15:15-wht-creation */
X
X#define M_TERMINFO
X
X#include <curses.h>
X#include <panel.h>
X#include <sys/types.h>
X#include "u386mon.h"
X
X/*+-------------------------------------------------------------------------
X clear_area_char(win,y,x,len,fillchar)
X--------------------------------------------------------------------------*/
Xvoid
Xclear_area_char(win,y,x,len,fillchar)
XWINDOW *win;
Xint y;
Xint x;
Xint len;
Xu_char fillchar;
X{
X wmove(win,y,x);
X while(len-- > 0)
X waddch(win,(chtype)fillchar);
X wmove(win,y,x);
X
X} /* end of clear_area_char */
X
X/*+-------------------------------------------------------------------------
X clear_area(win,y,x,len)
X--------------------------------------------------------------------------*/
Xvoid
Xclear_area(win,y,x,len)
XWINDOW *win;
Xint y;
Xint x;
Xint len;
X{
X clear_area_char(win,y,x,len,' ');
X} /* end of clear_area_char */
X
X/*+-------------------------------------------------------------------------
X pflush() - do update_panels() and doupdate()
X--------------------------------------------------------------------------*/
Xvoid
Xpflush()
X{
X update_panels();
X curs_set(0);
X doupdate();
X curs_set(1);
X} /* end of pflush */
X
X/*+-------------------------------------------------------------------------
X wperror(win,desc)
X--------------------------------------------------------------------------*/
Xvoid
Xwperror(win,desc)
XWINDOW *win;
Xchar *desc;
X{
Xextern int errno;
Xextern int sys_nerr;
Xextern char *sys_errlist[];
X
X waddstr(win,desc);
X waddstr(win,": ");
X if(errno < sys_nerr)
X waddstr(win,sys_errlist[errno]);
X else
X wprintw(win,"error %u",errno);
X
X} /* end of wperror */
X
X/*+-------------------------------------------------------------------------
X mkpanel(rows,cols,tly,tlx) - alloc a win and panel and associate them
X--------------------------------------------------------------------------*/
XPANEL *
Xmkpanel(rows,cols,tly,tlx)
Xint rows;
Xint cols;
Xint tly;
Xint tlx;
X{
XWINDOW *win = newwin(rows,cols,tly,tlx);
XPANEL *pan;
X
X if(!win)
X return((PANEL *)0);
X if(pan = new_panel(win))
X return(pan);
X delwin(win);
X return((PANEL *)0);
X} /* end of mkpanel */
X
X/*+-------------------------------------------------------------------------
X disp_info_long(win,label,fmt,value)
X--------------------------------------------------------------------------*/
Xvoid
Xdisp_info_long(win,label,fmt,value)
XWINDOW *win;
Xchar *label;
Xchar *fmt;
Xlong value;
X{
X use_cp(win,cpLIT);
X waddstr(win,label);
X use_cp(win,cpINFO);
X wprintw(win,fmt,value);
X} /* end of disp_info_long */
X
X/*+-------------------------------------------------------------------------
X disp_info_int(win,label,fmt,value)
X--------------------------------------------------------------------------*/
Xvoid
Xdisp_info_int(win,label,fmt,value)
XWINDOW *win;
Xchar *label;
Xchar *fmt;
Xint value;
X{
X use_cp(win,cpLIT);
X waddstr(win,label);
X use_cp(win,cpINFO);
X wprintw(win,fmt,value);
X} /* end of disp_info_int */
X
X/*+-------------------------------------------------------------------------
X disp_static_long(win,label,fmt,value)
X--------------------------------------------------------------------------*/
Xvoid
Xdisp_static_long(win,label,fmt,value)
XWINDOW *win;
Xchar *label;
Xchar *fmt;
Xlong value;
X{
X use_cp(win,cpLIT);
X waddstr(win,label);
X wprintw(win,fmt,value);
X} /* end of disp_static_long */
X
X/*+-------------------------------------------------------------------------
X disp_static_int(win,label,fmt,value)
X--------------------------------------------------------------------------*/
Xvoid
Xdisp_static_int(win,label,fmt,value)
XWINDOW *win;
Xchar *label;
Xchar *fmt;
Xint value;
X{
X use_cp(win,cpLIT);
X waddstr(win,label);
X wprintw(win,fmt,value);
X} /* end of disp_static_int */
X
X/*+-------------------------------------------------------------------------
X disp_msg(cp,msg)
X--------------------------------------------------------------------------*/
Xvoid
Xdisp_msg(cp,msg)
Xchtype cp;
Xchar *msg;
X{
Xextern WINDOW *wscr;
Xint y;
Xregister int x;
X
X wmove(wscr,MSG_TLY,0);
X use_cp(wscr,cp);
X waddstr(wscr,msg);
X getyx(wscr,y,x);
X while(x < getmaxx(wscr))
X waddch(wscr,(chtype)' '),x++;
X} /* end of disp_msg */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of disputil.c */
SHAR_EOF
$TOUCH -am 0624151990 disputil.c &&
chmod 0644 disputil.c ||
echo "restore of disputil.c failed"
set `wc -c disputil.c`;Wc_c=$1
if test "$Wc_c" != "4713"; then
echo original size 4713, current size $Wc_c
fi
echo "End of part 1, continue with part 2"
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".