Article 13467 of alt.sources: Submitted-by: ljp@tiac.net Archive-name: orion-1.0/part05 ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is `orion.05' (part 5 of orion-1.0). # Do not concatenate these parts, unpack them in order with `/bin/sh'. # File `orion-1.0/liborion/max.c' is being continued... # save_IFS="${IFS}" IFS="${IFS}:" gettext_dir=FAILED locale_dir=FAILED first_param="$1" for dir in $PATH do if test "$gettext_dir" = FAILED && test -f $dir/gettext \ && ($dir/gettext --version >/dev/null 2>&1) then set `$dir/gettext --version 2>&1` if test "$3" = GNU then gettext_dir=$dir fi fi if test "$locale_dir" = FAILED && test -f $dir/shar \ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1) then locale_dir=`$dir/shar --print-text-domain-dir` fi done IFS="$save_IFS" if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED then echo=echo else TEXTDOMAINDIR=$locale_dir export TEXTDOMAINDIR TEXTDOMAIN=sharutils export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi if test ! -r _sh05649/seq; then $echo 'Please unpack part 1 first!' exit 1 fi shar_sequence=`cat _sh05649/seq` if test "$shar_sequence" != 5; then $echo 'Please unpack part' "$shar_sequence" 'next!' exit 1 fi if test ! -f _sh05649/new; then $echo 'x -' 'STILL SKIPPING' 'orion-1.0/liborion/max.c' else $echo 'x -' 'continuing file' 'orion-1.0/liborion/max.c' sed 's/^X//' << 'SHAR_EOF' >> orion-1.0/liborion/max.c && X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include X X#if defined(__GNUC__) || defined(__cplusplus) Xinline X#endif Xsize_t maximum( size_t current, int count, size_t size ) X{ X return current>(count*size) ? current : (count*size); X} SHAR_EOF $echo 'File' 'orion-1.0/liborion/max.c' 'is complete' && chmod 0664 'orion-1.0/liborion/max.c' || $echo 'restore of' 'orion-1.0/liborion/max.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/liborion/max.c:' 'MD5 check failed' 00f1612e219e7f67bd60616f4044a089 orion-1.0/liborion/max.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/liborion/max.c'`" test 835 -eq "$shar_count" || $echo 'orion-1.0/liborion/max.c:' 'original size' '835,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/liborion/mkaddr.c ============== if test -f 'orion-1.0/liborion/mkaddr.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/liborion/mkaddr.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/liborion/mkaddr.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/liborion/mkaddr.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include X X/* X** createAddr() X** X** Create an address file. Call nlist(3) with the given array of X** nlist records, then write the array out to the given filename. X*/ Xint createAddr( struct nlist *recNlist, size_t sizeNlist, X const char *pathAddr, const char *pathKern ) X{ X int fdAddr; X X if( (fdAddr=open(pathAddr,O_WRONLY|O_CREAT|O_TRUNC,0666)) == -1 ) X { X fprintf( stdout, "Bad open(2) of \"%s\". %s.\n", X pathAddr, sys_errlist[errno] ); X return 0; X } X X X if( nlist(pathKern,recNlist) == -1 ) X { X fprintf( stdout, "Bad nlist(3) of \"%s\".\n", X pathKern ); X close( fdAddr ); X return 0; X } X#if 0 X { X int i; X unsigned long info; X X for( i=0; recNlist[i].n_name[0]!='\0'; ++i ) X { X recNlist[i].n_value = 0; X info = 0; X if( getksym(recNlist[i].n_name,&(recNlist[i].n_value), X &info) == -1 ) X { X recNlist[i].n_value = 0; X } X } X } X#endif X X if( write(fdAddr,(void*)recNlist,sizeof(struct nlist)*sizeNlist) == -1 ) X { X fprintf( stdout, "Unable to write to \"%s\".\n", X pathKern ); X close( fdAddr ); X return 0; X } X X close( fdAddr ); X X return 1; X} SHAR_EOF chmod 0664 'orion-1.0/liborion/mkaddr.c' || $echo 'restore of' 'orion-1.0/liborion/mkaddr.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/liborion/mkaddr.c:' 'MD5 check failed' 47e1bb471ca583821a323fdc769dba75 orion-1.0/liborion/mkaddr.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/liborion/mkaddr.c'`" test 1761 -eq "$shar_count" || $echo 'orion-1.0/liborion/mkaddr.c:' 'original size' '1761,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/liborion/native.mk ============== if test -f 'orion-1.0/liborion/native.mk' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/liborion/native.mk' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/liborion/native.mk' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/liborion/native.mk' && X X# ---------------------------------------------------------------- X# X# Copyright (c) 1994,1995,1996 by Larry Plona X# X# This file is part of the Orion software package. The Orion X# software package is copyright by its author, Larry Plona. This X# software, both source code and prepared binaries, may be X# freely distributed as long as all copyright notices remain X# intact and this software is not sold or packaged with other X# commercial software. X# X# No warranty of any kind attached with this software. It is X# supplied as is. X# X# ---------------------------------------------------------------- X X# X# native.mk X# X# General purpose makefile to be distributed with release. This makefile X# is not part of the LPS source code control system. X# X# There should be no need to edit this file; see "../orion.mk". X# X Xinclude ../defines.mk X X.SUFFIXES: .o .C X X# "PLATFORM" is from "../orion.mk". X# "CF" can be used from command line. X# "CFLAGS_LOCAL" can be set in this file. X# XCFLAGS = -D${PLATFORM} ${COPTS} -I. -I${DIR_INC} ${CF} XLDFLAGS = -L. -L${DIR_LIB} X XORION_SRCS = getsyms.c max.c mkaddr.c memread.c fmtbyte.c fmtsec.c \ X fmtstart.c pathadj.c XORION_OBJS=${ORION_SRCS:.c=.o} X Xall:: liborion.a X Xliborion.a:: ${ORION_OBJS} X if [ ! -d ${DIR_LIB} ]; then mkdir -p ${DIR_LIB}; fi X rm -f $@ X ${AR} crv $@ ${ORION_OBJS} X Xclean:: X rm -f liborion.a ${ORION_OBJS} X Xliborion.a:: X /bin/cp liborion.a ${DIR_LIB} X Xincludes:: liborion.h X if [ ! -d ${DIR_INC} ]; then mkdir -p ${DIR_INC}; fi; X -rm -f ${DIR_INC}/liborion.h X ln liborion.h ${DIR_INC}/liborion.h X Xinstall:: X Xinclude ../rules.mk X Xfmtbyte.o: ${DIR_INC}/liborion.h Xgetsyms.o: ${DIR_INC}/liborion.h Xmax.o: ${DIR_INC}/liborion.h Xmemread.o: ${DIR_INC}/liborion.h Xmkaddr.o: ${DIR_INC}/liborion.h Xpathadj.o: ${DIR_INC}/liborion.h SHAR_EOF chmod 0664 'orion-1.0/liborion/native.mk' || $echo 'restore of' 'orion-1.0/liborion/native.mk' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/liborion/native.mk:' 'MD5 check failed' 526fd1770242462a978a1688cf8e70ec orion-1.0/liborion/native.mk SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/liborion/native.mk'`" test 1788 -eq "$shar_count" || $echo 'orion-1.0/liborion/native.mk:' 'original size' '1788,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/liborion/fmtbyte.c ============== if test -f 'orion-1.0/liborion/fmtbyte.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/liborion/fmtbyte.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/liborion/fmtbyte.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/liborion/fmtbyte.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include X X/* X** fmtByte() X** X** Convert an unsigned number representing a size in bytes, to a string. X*/ Xconst char *fmtByte( unsigned b ) X{ X static char buf[31+1]; X unsigned m, k; X X if( b >= 1024*1024 ) X { X if( b % (1024*1024) ) X sprintf( buf, "%.1fM", (float)b/(1024.0*1024.0) ); X else X sprintf( buf, "%uM", b/(1024*1024) ); X } X else if( b >= 1024 ) X { X if( b % 1024 ) X sprintf( buf, "%.1fK", (float)b/1024.0 ); X else X sprintf( buf, "%uK", b/1024 ); X } X else X sprintf( buf, "%ubytes", b ); X X return (const char*)buf; X} SHAR_EOF chmod 0664 'orion-1.0/liborion/fmtbyte.c' || $echo 'restore of' 'orion-1.0/liborion/fmtbyte.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/liborion/fmtbyte.c:' 'MD5 check failed' db492973b46fd2a8bf841e14bf971a0c orion-1.0/liborion/fmtbyte.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/liborion/fmtbyte.c'`" test 1213 -eq "$shar_count" || $echo 'orion-1.0/liborion/fmtbyte.c:' 'original size' '1213,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/liborion/memread.c ============== if test -f 'orion-1.0/liborion/memread.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/liborion/memread.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/liborion/memread.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/liborion/memread.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include X X/* X** memRead() X** X*/ Xint memRead( int fd, caddr_t addr, void *buf, unsigned size ) X{ X int rc; X X if( lseek(fd,addr,SEEK_SET) == -1 ) X { X#ifdef DEBUG X fprintf( stdout, "Bad lseek() (SEEK_SET,0x%x), %s.\n", X sys_errlist[errno] ); X#endif X return 0; X } X X if( (rc=read(fd,buf,size)) == -1 ) X { X#ifdef DEBUG X fprintf( stdout, "Bad read(), %s.\n", X sys_errlist[errno] ); X#endif X return 0; X } X X if( rc != size ) X return 0; X X return 1; X} SHAR_EOF chmod 0664 'orion-1.0/liborion/memread.c' || $echo 'restore of' 'orion-1.0/liborion/memread.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/liborion/memread.c:' 'MD5 check failed' b9c0262b0249746de9f95b9724ad7adb orion-1.0/liborion/memread.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/liborion/memread.c'`" test 1120 -eq "$shar_count" || $echo 'orion-1.0/liborion/memread.c:' 'original size' '1120,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/liborion/fmtstart.c ============== if test -f 'orion-1.0/liborion/fmtstart.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/liborion/fmtstart.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/liborion/fmtstart.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/liborion/fmtstart.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include X X#ifdef VENIX32 Xextern struct tm *localtime( time_t*); X#endif X Xconst char *startFormat( time_t *t ) X{ X struct tm *recTm; X static char buffer[127+1]; X static time_t timeToday = 0; X X if( timeToday == 0 ) X { X struct tm *recTmToday; X X timeToday = time( NULL ); X recTmToday = localtime( &timeToday ); X X timeToday -= (recTmToday->tm_hour*60*60) + (recTmToday->tm_min*60) + X recTmToday->tm_sec; X } X X recTm = localtime( t ); X X#if defined(SVR4) || defined(UW2) || defined(SUN5) || defined(SCO5) X if( *t > timeToday ) X strftime( buffer, 127, "%I:%M:%S %p", recTm ); X else X strftime( buffer, 127, "%D %I:%M:%S %p", recTm ); X#endif X X#if defined(VENIX32) || defined(SVR3) X if( *t > timeToday ) X cftime( buffer, "%I:%M:%S %p", recTm ); X else X cftime( buffer, "%D %I:%M:%S %p", recTm ); X#endif X X return (const char*)buffer; X} SHAR_EOF chmod 0664 'orion-1.0/liborion/fmtstart.c' || $echo 'restore of' 'orion-1.0/liborion/fmtstart.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/liborion/fmtstart.c:' 'MD5 check failed' 9445857b03ae90d8753c1ebb7ec6059f orion-1.0/liborion/fmtstart.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/liborion/fmtstart.c'`" test 1506 -eq "$shar_count" || $echo 'orion-1.0/liborion/fmtstart.c:' 'original size' '1506,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/liborion/fmtsec.c ============== if test -f 'orion-1.0/liborion/fmtsec.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/liborion/fmtsec.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/liborion/fmtsec.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/liborion/fmtsec.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include"liborion.h" X Xconst char *secFormat( time_t seconds ) X{ X unsigned long min, sec; X static char strTime[31+1]; X X min = seconds / 60; X sec = seconds % 60; X X sprintf( strTime, "%02ld:%02ld", min, sec ); X X return (const char*)strTime; X} SHAR_EOF chmod 0664 'orion-1.0/liborion/fmtsec.c' || $echo 'restore of' 'orion-1.0/liborion/fmtsec.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/liborion/fmtsec.c:' 'MD5 check failed' fc6380f394402d9cbffb97ce45e10967 orion-1.0/liborion/fmtsec.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/liborion/fmtsec.c'`" test 892 -eq "$shar_count" || $echo 'orion-1.0/liborion/fmtsec.c:' 'original size' '892,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/liborion/pathadj.c ============== if test -f 'orion-1.0/liborion/pathadj.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/liborion/pathadj.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/liborion/pathadj.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/liborion/pathadj.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include X X/* X** pathAdjust() X** X** Given a path, a buffer and a length, Put as much of the path X** as will fit into the buffer. Copying is done on a per segment X** basis, starting with the last segment in the path. X*/ Xint pathAdjust( const char *path, char *buf, size_t len ) X{ X int curs, last; X int plen; X X /* X ** Copy an appropriate amount of the path into the saved X ** table. Starting at the end of the path, back up segment X ** by segment copying until the buffer is full. X */ X X#if 0 X /* Skip the leading "/dev". */ X path += 4; X#endif X X /* Set cursor to last character in path. */ X for( curs=0; path[curs]!='\0'; ++curs ); X X /* Length of source path. */ X plen = curs; X X /* Remember the start of the last fitting segment. */ X last = curs; X X /* Loop through the segments. */ X while( 1 ) X { X /* Set cursor to the start of the segment (or start of path). */ X for( ; (curs>0)&&(path[curs]!='/'); --curs ); X X /* Cursor is on a '/'. Check size without '/'. */ X if( path[curs] == '/' ) X { X if( plen-(curs+1) > len ) X break; X X if( curs <= 0 ) X { X last = curs+1; X break; X } X } X X /* If at the start of the path, quit. */ X if( curs <= 0 ) X { X /* Will the current segment fit? */ X if( plen-curs <= len ) X last = curs; X break; X } X X /* New previous segment. */ X last = curs+1; X X /* Start of next segment. */ X --curs; X } X X strncpy( buf, &path[last], len ); X buf[len] = '\0'; X X return 1; X} SHAR_EOF chmod 0664 'orion-1.0/liborion/pathadj.c' || $echo 'restore of' 'orion-1.0/liborion/pathadj.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/liborion/pathadj.c:' 'MD5 check failed' d9aeeb7e836f7052aa619d508025910f orion-1.0/liborion/pathadj.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/liborion/pathadj.c'`" test 2122 -eq "$shar_count" || $echo 'orion-1.0/liborion/pathadj.c:' 'original size' '2122,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/orion.mk ============== if test -f 'orion-1.0/orion.mk' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/orion.mk' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/orion.mk' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/orion.mk' && X X# ---------------------------------------------------------------- X# X# Copyright (c) 1994,1995,1996 by Larry Plona X# X# This file is part of the Orion software package. The Orion X# software package is copyright by its author, Larry Plona. This X# software, both source code and prepared binaries, may be X# freely distributed as long as all copyright notices remain X# intact and this software is not sold or packaged with other X# commercial software. X# X# No warranty of any kind attached with this software. It is X# supplied as is. X# X# ---------------------------------------------------------------- X X# X# orion.mk X# X# Makefile to be distributed with release. This makefile is not part of X# the lps source code control system. X# X# This makefile should not need to be edited. X# X Xinclude defines.mk X X Xall:: X for i in ${SUBDIRS}; do \ X cd $$i; ${MAKE} -f native.mk all; cd ..; done X Xclean:: X for i in ${SUBDIRS}; do \ X cd $$i; ${MAKE} -f native.mk clean; cd ..; done X -rm -f lib/*.a include/*.h X Xincludes:: X for i in ${SUBDIRS}; do \ X cd $$i; ${MAKE} -f native.mk includes; cd ..; done X Xinstall:: X if [ ! -d ${DIR_INST} ]; then mkdir -p ${DIR_INST}; fi X if [ ! -d ${DIR_INST}/bin ]; then mkdir -p ${DIR_INST}/bin; fi X if [ ! -d ${DIR_INST}/man/${MAN_MAN1} ]; \ X then mkdir -p ${DIR_INST}/man/${MAN_MAN1}; fi X for i in ${SUBDIRS}; do \ X cd $$i; ${MAKE} -f native.mk install; cd ..; done X XFORCE: SHAR_EOF chmod 0664 'orion-1.0/orion.mk' || $echo 'restore of' 'orion-1.0/orion.mk' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/orion.mk:' 'MD5 check failed' 6e7cdd6e2adad0301ecc8a01a0a0dd13 orion-1.0/orion.mk SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/orion.mk'`" test 1422 -eq "$shar_count" || $echo 'orion-1.0/orion.mk:' 'original size' '1422,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/rules.mk ============== if test -f 'orion-1.0/rules.mk' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/rules.mk' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/rules.mk' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/rules.mk' && X X# ---------------------------------------------------------------- X# X# Copyright (c) 1994,1995,1996 by Larry Plona X# X# This file is part of the Orion software package. The Orion X# software package is copyright by its author, Larry Plona. This X# software, both source code and prepared binaries, may be X# freely distributed as long as all copyright notices remain X# intact and this software is not sold or packaged with other X# commercial software. X# X# No warranty of any kind attached with this software. It is X# supplied as is. X# X# ---------------------------------------------------------------- X X# X# rules.mk X# X# Makefile to be distributed with release. This makefile is not part of X# the lps source code control system. X# X# This makefile should not need to be edited; see "orion.mk". X# X X# X# Basic rules. X# X X.c.o: X ${CC} -c ${CFLAGS} $< X X.C.o: X ${CXX} -c ${CXXFLAGS} $< SHAR_EOF chmod 0664 'orion-1.0/rules.mk' || $echo 'restore of' 'orion-1.0/rules.mk' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/rules.mk:' 'MD5 check failed' 5c3c41dec0a168245c878df429c38c51 orion-1.0/rules.mk SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/rules.mk'`" test 887 -eq "$shar_count" || $echo 'orion-1.0/rules.mk:' 'original size' '887,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/defines.mk ============== if test -f 'orion-1.0/defines.mk' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/defines.mk' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/defines.mk' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/defines.mk' && X X# ---------------------------------------------------------------- X# X# Copyright (c) 1994,1995,1996 by Larry Plona X# X# This file is part of the Orion software package. The Orion X# software package is copyright by its author, Larry Plona. This X# software, both source code and prepared binaries, may be X# freely distributed as long as all copyright notices remain X# intact and this software is not sold or packaged with other X# commercial software. X# X# No warranty of any kind attached with this software. It is X# supplied as is. X# X# ---------------------------------------------------------------- X X# X# defines.mk X# X# Makefile to be distributed with release. This makefile is not part of X# the lps source code control system. X# X# Edit the labeled section. No other makefile should need to be edited. X# X X# X# Start of editable defines. X# X X# X# Source/build directory (root of distribution). X# XDIR_BUILD = /usr/answers/tmp/orion-1.0 X X# X# Root of install directory. X# XDIR_INST = /usr/local X X# X# Platform. X# X X# X# For UnixWare 2 systems X# Excluding UnixWare 1 X# XPLATFORM = UW2 XCOPTS = XPIS_LIBS = -lelf XSARG_LIBS = -lelf XMEMOWN = bin XMEMGRP = sys XMAN_MAN1 = man1 X X# X# For SunOS 5.x (Solaris 2.x) systems. X# X#PLATFORM = SUN5 X#PIS_LIBS = -lelf X#SARG_LIBS = -lelf X#MEMOWN = root X#MEMGRP = sys X#MAN_MAN1 = man1 X X# X# For SCO 3.2v5 systems. X# X#PLATFORM = SCO5 X#COPTS = X#PIS_LIBS = -lelf -lsocket X#SARG_LIBS = -lelf -lsocket X#MEMOWN = bin X#MEMGRP = mem X#MAN_MAN1 = man.1 X X# X# For SCO 3.2v4 systems. X# X#PLATFORM = SCO4 X#COPTS = X#PIS_LIBS = X#SARG_LIBS = X#MEMOWN = bin X#MEMGRP = mem X#MAN_MAN1 = man.1 X X# X# For SVR4 systems X# Including UnixWare 1 X# Excluding UnixWare 2 X# Excluding SunOS 5 X# X#PLATFORM = SVR4 X#COPTS = X#PIS_LIBS = -lelf X#SARG_LIBS = -lelf X#MEMOWN = bin X#MEMGRP = sys X#MAN_MAN1 = man1 X X# X# For VENIX 3.2 systems. X# Remove the WOLLONG32 define and use of "netinclude", if Wollongong's X# WIN/TCP include files are not being used. X# X#PLATFORM = VENIX32 X#COPTS = -DWOLLONG32 -I/usr/netinclude X#PIS_LIBS = -lrtx X#SARG_LIBS = -lrtx X#MEMOWN = bin X#MEMGRP = sys X#MAN_MAN1 = man1 X X# X# For SVR3 systems X# Excluding VENIX 3.2 X# Including SCO 3.2v2 X# For SCO UNIX, set MAN_MAN1 to "man.1". X# X#PLATFORM = -DSVR3 X#COPTS = X#MEMOWN = bin X#MEMGRP = sys X#MAN_MAN1 = man1 X XCC = gcc XSHELL = /bin/sh XMAKE = make X X# X# End of editable defines. X# X XDIR_LIB = ${DIR_BUILD}/lib XDIR_INC = ${DIR_BUILD}/include XDIR_BIN = ${DIR_BUILD}/bin X XSUBDIRS = liborion pis docs X#SUBDIRS = liborion pis sargent sarrep docs SHAR_EOF chmod 0664 'orion-1.0/defines.mk' || $echo 'restore of' 'orion-1.0/defines.mk' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/defines.mk:' 'MD5 check failed' 05bdaf0d1f284ee1b2b67dd73f3d42b6 orion-1.0/defines.mk SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/defines.mk'`" test 2518 -eq "$shar_count" || $echo 'orion-1.0/defines.mk:' 'original size' '2518,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/README ============== if test -f 'orion-1.0/README' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/README' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/README' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/README' && X X ---------------------------------------------------------------- X X Copyright (c) 1994,1995,1996 by Larry Plona X X This file is part of the Orion software package. The Orion X software package is copyright by its author, Larry Plona. This X software, both source code and prepared binaries, may be X freely distributed as long as all copyright notices remain X intact and this software is not sold or packaged with other X commercial software. X X No warranty of any kind attached with this software. It is X supplied as is. X X ---------------------------------------------------------------- X Xorion 1.0 X X XINTRODUCTION X X This is the distribution of Orion 1.0. Orion is a set of administration X utilities which make use of information found in the UNIX kernel. X X This distribution includes only the 1.0 version of "pis" - a X replacement for the standard ps utility. And an alpha version of X "sargent" - a replacement for the sar command. X X Official support exists for UnixWare 2, SCO 3.2v5, SunOS 5.4. Nominal X support exists for SCO 3.2v2, VENIX 3.2, generic SVR3 and generic X SVR4. X X The sargent alpha code only compiles under UnixWare 2 and SCO UNIX X 3.2v5. X X XBUILDING X X Edit "defines.mk" as instructed. X X make -f orion.mk clean X make -f orion.mk includes X make -f orion.mk all X make -f orion.mk install X X The constant "CF" can be set on the make command line to add X compile options such as "-g". X X The source for other commands is included, but is not built X (or supported) at this time. X X XINSTALLED FILES X X /bin/mkpis X /bin/pis X /man/man.1/pis.1 X X Both executables must be set-gid so that they can read "/dev/kmem" X (either "sys" or "mem"). X X XDOCUMENTATION X X In addtion to the man page, the troff file orion.ps is a PostScript X rendition of the pis manual. X X XTHE FUTURE X X The next release of Orion will probably feature "sargent" and "sarrep", X replacements for the standard sar utility. X X XBUGS AND INFORMATION X X Send mail to: X Larry Plona X ljp@tiac.net X X All comments, suggestions and bug reports are welcome. SHAR_EOF chmod 0664 'orion-1.0/README' || $echo 'restore of' 'orion-1.0/README' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/README:' 'MD5 check failed' 5d4fe03370577fc693f7374f1f3bf76a orion-1.0/README SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/README'`" test 2128 -eq "$shar_count" || $echo 'orion-1.0/README:' 'original size' '2128,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/sargent/native.mk ============== if test ! -d 'orion-1.0/sargent'; then $echo 'x -' 'creating directory' 'orion-1.0/sargent' mkdir 'orion-1.0/sargent' fi if test -f 'orion-1.0/sargent/native.mk' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/sargent/native.mk' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/sargent/native.mk' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/sargent/native.mk' && X X# ---------------------------------------------------------------- X# X# Copyright (c) 1994,1995,1996 by Larry Plona X# X# This file is part of the Orion software package. The Orion X# software package is copyright by its author, Larry Plona. This X# software, both source code and prepared binaries, may be X# freely distributed as long as all copyright notices remain X# intact and this software is not sold or packaged with other X# commercial software. X# X# No warranty of any kind attached with this software. It is X# supplied as is. X# X# ---------------------------------------------------------------- X X# X# native.mk X# X# General purpose makefile to be distributed with release. This makefile X# is not part of the LPS source code control system. X# X# There should be no need to edit this file; see "../orion.mk". X# X Xinclude ../defines.mk X X# "PLATFORM" is from "../orion.mk". X# "CF" can be used from command line. X# XCFLAGS = -D${PLATFORM} ${COPTS} -I. -I${DIR_INC} ${CF} XLDFLAGS = -L. -L${DIR_LIB} X XSARG_SRCS = sarg.c netstat.c mount.c ipcs.c ps.c venix.c wollong.c sar.c \ X proc.c basic1.c kern.c streams.c tty.c memsys.c module.c disk.c XSARG_OBJS=${SARG_SRCS:.c=.o} X Xall:: sargent X Xincludes:: sarg.h X if [ ! -d ${DIR_INC} ]; then mkdir -p ${DIR_INC}; fi; X -rm -f ${DIR_INC}/sarg.h; X ln sarg.h ${DIR_INC}/sarg.h X Xsargent:: ${SARG_OBJS} X rm -f $@ X ${CC} -o $@ ${SARG_OBJS} ${LDFLAGS} -lorion ${SARG_LIBS} X Xclean:: X rm -f sargent ${SARG_OBJS} X Xinstall:: X chown ${MEMOWN} sargent X chgrp ${MEMGRP} sargent X chmod 775 sargent X if [ ${PLATFORM} = "SUN5" ]; then chmod u+s; fi X if [ ${PLATFORM} != "SUN5" ]; then chmod g+s; fi X mv sargent ${DIR_INST}/bin/sargent X Xinclude ../rules.mk SHAR_EOF chmod 0664 'orion-1.0/sargent/native.mk' || $echo 'restore of' 'orion-1.0/sargent/native.mk' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/sargent/native.mk:' 'MD5 check failed' 84b46f64fd5fb38b540a08660d2e6383 orion-1.0/sargent/native.mk SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/sargent/native.mk'`" test 1689 -eq "$shar_count" || $echo 'orion-1.0/sargent/native.mk:' 'original size' '1689,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/sargent/basic1.c ============== if test -f 'orion-1.0/sargent/basic1.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/sargent/basic1.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/sargent/basic1.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/sargent/basic1.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include"sarg_p.h" X X/* X** basic1Sample() X** X** Sysinfo version. X** X** Create a basic1 record from the sysinfo, minfo and other X** sar related kernel structures. X*/ X#if defined(ORION_FEAT_SYSINFO) Xint basic1Sample( int fdMem ) X{ X int i; X struct syserr recErr; X struct flckinfo recFlock; X struct minfo recMinfo; X struct sargBasic1 recBasic1; X struct sysinfo *si; X X if( globalProfile.p_debug ) X fputs( "Making Basic1 sample.\n", stdout ); X X /* X ** Lots of data comes from the sysinfo structure. X */ X X si = (struct sysinfo*)siFetch( SARG_VAR_SYSINFO ); X X /* X ** CPU usage. X */ X recBasic1.cpu[SARG_CPU_IDLE] = si->cpu[CPU_IDLE]; X recBasic1.cpu[SARG_CPU_USER] = si->cpu[CPU_USER]; X recBasic1.cpu[SARG_CPU_KERN] = si->cpu[CPU_KERNEL]; X recBasic1.cpu[SARG_CPU_WAIT] = si->cpu[CPU_WAIT]; X recBasic1.cpu[SARG_CPU_SWAP] = si->cpu[CPU_SXBRK]; X recBasic1.wait[SARG_WAIT_IO] = si->wait[W_IO]; X recBasic1.wait[SARG_WAIT_SWAP] = si->wait[W_SWAP]; X recBasic1.wait[SARG_WAIT_PIO] = si->wait[W_PIO]; X X /* X ** System call data. X */ X recBasic1.cntSys = si->syscall; X recBasic1.cntSysFork = si->sysfork; X recBasic1.cntSysLwp = 0; /* Not available. */ X recBasic1.cntSysExec = si->sysexec; X recBasic1.cntSysRead = si->sysread; X recBasic1.cntSysWrite = si->syswrite; X X /* X ** Misc. X */ X recBasic1.cntPswitch = si->pswitch; X recBasic1.cntSwapIn = si->swapin; X recBasic1.cntSwapOut = si->swapout; X X /* X ** X */ X X memRead( fdMem, memAddr(SARG_VAR_MINFO), (void*)&recMinfo, X sizeof(recMinfo) ); X X recBasic1.cntVfault = recMinfo.vfault; X X /* X ** Get table sizes. X */ X recBasic1.cntProcMax = globalProfile.kern_var.v_proc; X recBasic1.cntFileMax = globalProfile.kern_var.v_file; X recBasic1.cntInodeMax = globalProfile.kern_var.v_inode; X X memRead( fdMem, memAddr(SARG_VAR_SYSERR), (void*)&recErr, X sizeof(recErr) ); X recBasic1.cntProcOvf = recErr.procovf; X recBasic1.cntFileOvf = recErr.fileovf; X recBasic1.cntInodeOvf = recErr.inodeovf; X X memRead( fdMem, memAddr(SARG_VAR_FLOCK), (void*)&recFlock, X sizeof(recFlock) ); X recBasic1.cntLock = recFlock.reccnt; X recBasic1.cntLockMax = recFlock.recs; X recBasic1.cntLockOvf = recFlock.recovf; X X /* X ** Find out how many inodes are in use. Read in the entire X ** inode table and count the number of referenced inodes. X */ X { X struct inode *recInode; X X if( !memFetch(SARG_VAR_INODE,globalProfile.p_scratch, X sizeof(struct inode)*recBasic1.cntInodeMax) ) X { X fprintf( stdout, "Could not fetch \"inode\". %s.\n", X sys_errlist[errno] ); X return 0; X } X recBasic1.cntInode = 0; X for( recInode=(struct inode*)globalProfile.p_scratch,i=0; X ii_count <= 0 ) X continue; X ++(recBasic1.cntInode); X } X } X X /* X ** Find out how many files are in use. Read in the entire X ** file table and count the number of referenced entries. X */ X { X struct file *recFile; X X if( !memFetch(SARG_VAR_FILE,globalProfile.p_scratch, X sizeof(struct file)*recBasic1.cntFileMax) ) X { X fprintf( stdout, "Could not fetch \"file\". %s.\n", X sys_errlist[errno] ); X return 0; X } X recBasic1.cntFile = 0; X for( recFile=(struct file*)globalProfile.p_scratch,i=0; X if_count <= 0 ) X continue; X ++(recBasic1.cntFile); X } X } X X /* X ** Find out how many procs are in use. Read in the entire X ** proc table and count the number of referenced entries. X */ X { X struct proc *recProc; X X if( !memFetch(SARG_VAR_PROC,globalProfile.p_scratch, X sizeof(struct proc)*recBasic1.cntProcMax) ) X { X fprintf( stdout, "Bad read(2) of table proc. %s.\n", X sys_errlist[errno] ); X return 0; X } X recBasic1.cntProc = 0; X for( recProc=(struct proc*)globalProfile.p_scratch,i=0; X ip_stat != 0 ) X ++(recBasic1.cntProc); X } X } X X return diskWrite((void*)&recBasic1,sizeof(recBasic1), X SARG_RTYP_BASIC1); X} X#endif X X/* X** basic1Sample() X** X** Metrics version. X** X** Create a basic1 record from the "metrics" family of X** kernel structures. Other System V variants use the X** "sar" family of structures. X*/ X#if defined(ORION_FEAT_METRICS) Xint basic1Sample( int fdMem ) X{ X struct sargBasic1 recBasic1; X struct mets *m; X X if( globalProfile.p_debug ) X fputs( "Making Basic1 sample.\n", stdout ); X X if( !memFetch(SARG_VAR_METS,(void*)&globalProfile.kern_mets, X sizeof(struct mets)) ) X { X fprintf( stdout, "Could not fetch \"mets\". %s.\n", X sys_errlist[errno] ); X return 0; X } X X m = &globalProfile.kern_mets; X X recBasic1.cntProcMax = m->mets_proc_resrc.msr_proc[MET_MAX]; X recBasic1.cntFileMax = m->mets_files.msf_file[MET_MAX]; X recBasic1.cntLockMax = m->mets_files.msf_flck[MET_MAX]; X recBasic1.cntProcOvf = m->mets_proc_resrc.msr_proc[MET_FAIL]; X recBasic1.cntFileOvf = m->mets_files.msf_file[MET_FAIL]; X recBasic1.cntLockOvf = m->mets_files.msf_flck[MET_FAIL]; X recBasic1.cntProc = m->mets_proc_resrc.msr_proc[MET_INUSE]; X recBasic1.cntFile = m->mets_files.msf_file[MET_INUSE]; X recBasic1.cntLock = m->mets_files.msf_flck[MET_INUSE]; X if( globalProfile.p_findings ) X { X fprintf( stdout, "proc max %d\n", recBasic1.cntProcMax ); X fprintf( stdout, "proc fail %d\n", recBasic1.cntProcOvf ); X fprintf( stdout, "proc use %d\n", recBasic1.cntProc ); X } X X /* X ** Aggregate inode metrics. X */ X { X int i; X X recBasic1.cntInodeMax = 0; X recBasic1.cntInode = 0; X recBasic1.cntInodeOvf = 0; X X for( i=0; imets_inodes[i].msi_inodes[MET_MAX]; X recBasic1.cntInode += m->mets_inodes[i].msi_inodes[MET_INUSE]; X recBasic1.cntInodeOvf += m->mets_inodes[i].msi_inodes[MET_FAIL]; X } X } X X /* X ** Aggregate CPU metrics. X */ X { X int i; X struct metp_cpu *ptr; X X recBasic1.cpu[SARG_CPU_IDLE] = 0; X recBasic1.cpu[SARG_CPU_USER] = 0; X recBasic1.cpu[SARG_CPU_KERN] = 0; X recBasic1.cpu[SARG_CPU_WAIT] = 0; X recBasic1.cpu[SARG_CPU_SWAP] = 0; /* Not available. */ X recBasic1.wait[SARG_WAIT_IO] = 0; /* Not available. */ X recBasic1.wait[SARG_WAIT_SWAP] = 0; X recBasic1.wait[SARG_WAIT_PIO] = 0; X X if( (ptr=(struct metp_cpu*)metFetch(SARG_VAR_CPU)) != NULL ) X { X for( i=0; impc_cpu[MET_CPU_IDLE]; X recBasic1.cpu[SARG_CPU_WAIT] += ptr->mpc_cpu[MET_CPU_WAIT]; X recBasic1.cpu[SARG_CPU_USER] += ptr->mpc_cpu[MET_CPU_USER]; X recBasic1.cpu[SARG_CPU_KERN] += ptr->mpc_cpu[MET_CPU_SYS]; X ptr += sizeof(struct metp_cpu); X } X } X else X { X fputs( "Could not read CPU metrics.\n", stdout ); X } X X if( globalProfile.p_findings ) X { X fprintf( stdout, "idle %ld.\n", recBasic1.cpu[SARG_CPU_IDLE] ); X fprintf( stdout, "wait %ld.\n", recBasic1.cpu[SARG_CPU_USER] ); X fprintf( stdout, "user %ld.\n", recBasic1.cpu[SARG_CPU_KERN] ); X fprintf( stdout, "kern %ld.\n", recBasic1.cpu[SARG_CPU_WAIT] ); X } X } X X /* X ** FUTURE: Formerly minfo.vfault. X */ X X { X struct vmmeter *ptr; X X if( (ptr=(struct vmmeter*)metFetch(SARG_VAR_VMMETER)) != NULL ) X { X recBasic1.cntPswitch = ptr->v_swtch; X recBasic1.cntVfault = ptr->v_faults; X if( globalProfile.p_findings ) X { X fprintf( stdout, "pswitch %ld\n", ptr->v_swtch ); X fprintf( stdout, "vfault %ld\n", ptr->v_faults ); X } X } X } X X /* X ** System call activity. X */ X { X int i; X struct metp_syscall *ptr; X X if( (ptr=(struct metp_syscall*)metFetch(SARG_VAR_SYSCALL)) != NULL ) X { X for( i=0; imps_syscall; X recBasic1.cntSysFork = ptr->mps_fork; X recBasic1.cntSysLwp = ptr->mps_lwpcreate; X recBasic1.cntSysExec = ptr->mps_exec; X recBasic1.cntSysRead = ptr->mps_read; X recBasic1.cntSysWrite = ptr->mps_write; X ptr += sizeof(struct metp_syscall); X } X } X else X { X fputs( "Could not read syscall metrics.\n", stdout ); X } X } X X /* X ** X */ X { X int i; X struct metp_vm *ptr; X X if( (ptr=(struct metp_vm*)metFetch(SARG_VAR_VM)) != NULL ) X { X for( i=0; impv_swpin; X recBasic1.cntSwapOut = ptr->mpv_swpout; X ptr += sizeof(struct metp_vm); X } X } X else X { X fputs( "Could not read VM metrics.\n", stdout ); X } X } X X return diskWrite((void*)&recBasic1,sizeof(recBasic1), X SARG_RTYP_BASIC1); X} X#endif SHAR_EOF chmod 0664 'orion-1.0/sargent/basic1.c' || $echo 'restore of' 'orion-1.0/sargent/basic1.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/sargent/basic1.c:' 'MD5 check failed' 0c69afaaa8320b261da9595ee4374d2e orion-1.0/sargent/basic1.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/sargent/basic1.c'`" test 9229 -eq "$shar_count" || $echo 'orion-1.0/sargent/basic1.c:' 'original size' '9229,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/sargent/ipcs.c ============== if test -f 'orion-1.0/sargent/ipcs.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/sargent/ipcs.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/sargent/ipcs.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/sargent/ipcs.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include"sarg_p.h" X X/* X** Ipcs record type. X** X** Tracks data regarding the IPC facility. X*/ Xint ipcsSample( int fdMem ) X{ X int i; X unsigned long cntMsgs; X unsigned long cntMdata; X struct msginfo msginfo; X struct msqid_ds *recQid; X struct seminfo recSeminfo; X struct sargIpcs sargIpcs; X#if defined(ORION_FEAT_SYSINFO) X struct sysinfo *si; X#endif X X /* X ** Note that under UnixWare 2, the message queue code is X ** loaded on demand. X */ X X#if defined(ORION_FEAT_SYSINFO) X si = siFetch( SARG_VAR_SYSINFO ); X X sargIpcs.cntOpMsg = si->msg; X sargIpcs.cntOpSem = si->sema; X#endif X X if( !memFetch(SARG_VAR_MSGINFO, X (void*)&msginfo,sizeof(struct msginfo)) ) X { X#if defined(UW2) X sargIpcs.loaded = 0; X return diskWrite((void*)&sargIpcs,sizeof(struct sargIpcs), X SARG_RTYP_IPCS); X#else X fputs( "Could not fetch \"msginfo\".\n", stdout ); X return 0; X#endif X } X X if( !memFetch(SARG_VAR_MSGQUE,globalProfile.p_scratch, X sizeof(struct msqid_ds)*msginfo.msgmni) ) X { X#if defined(UW2) X sargIpcs.loaded = 0; X return diskWrite((void*)&sargIpcs,sizeof(struct sargIpcs), X SARG_RTYP_IPCS); X#else X fputs( "Could not fetch \"msgque\".\n", stdout ); X return 0; X#endif X } X X sargIpcs.cntQueues = msginfo.msgmni; X cntMsgs = 0; X cntMdata = 0; X X for( recQid=(struct msqid_ds*)globalProfile.p_scratch,i=0; X imsg_qnum; X cntMdata += recQid->msg_cbytes; X } X X sargIpcs.cntMsgs = cntMsgs; X sargIpcs.cntMdata = cntMdata; X sargIpcs.perMsgs = ((float)cntMsgs/(float)msginfo.msgtql) * 100.0; X sargIpcs.perMdata = ((float)cntMdata/(float)msginfo.msgmnb) * 100.0; X X if( !memFetch(SARG_VAR_SEMINFO,&recSeminfo,sizeof(struct seminfo)) ) X { X#if defined(UW2) X sargIpcs.loaded = 0; X return diskWrite((void*)&sargIpcs,sizeof(struct sargIpcs), X SARG_RTYP_IPCS); X#else X fputs( "Could not fetch \"seminfo\".\n", stdout ); X return 0; X#endif X } X X sargIpcs.cntSems = recSeminfo.semmns; X X return diskWrite((void*)&sargIpcs,sizeof(struct sargIpcs),SARG_RTYP_IPCS); X} SHAR_EOF chmod 0664 'orion-1.0/sargent/ipcs.c' || $echo 'restore of' 'orion-1.0/sargent/ipcs.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/sargent/ipcs.c:' 'MD5 check failed' 0642fd3c205a5f59495e2ea960477699 orion-1.0/sargent/ipcs.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/sargent/ipcs.c'`" test 2720 -eq "$shar_count" || $echo 'orion-1.0/sargent/ipcs.c:' 'original size' '2720,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/sargent/kern.c ============== if test -f 'orion-1.0/sargent/kern.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/sargent/kern.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/sargent/kern.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/sargent/kern.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include"sarg_p.h" X X/* X** This module contains all of the data structures and functions which X** find and retreive kernel structures. X** X** There are three basic records used: X** X** recNlist: Array of standard nlist(3E) records. Each platform has X** two, one of addresses used by sar, the other used by sargent. X** Only one table is used during the execution. The table X** is populated by reading nlist structures stored in the address X** file (either /tmp/sa.adrfl or /tmp/ssa.adrfl). X** X** tableOffsets: Maps variable ids to indices into the recNlist X** table. Each kernel structure has an id defined in "_p.h". X** The memXXX() functions access this table. X** X** metTab: The local metrics family of kernel structures are X** dynamically stored. This table maps their variable ids to X** storage locations. These kernel structures come in multiples - X** one for each CPU in the system. X** X** The following functions act on the above tables. X** X** memInit() X** Selects which table "recNlist" will point to. This is chosen X** by runtime option. X** X** [kernel address] memAddr( [var id] ) X** Converts a kernel id into a memory address. This only works for X** ids of non local metrics variables. X** X** [0/1] memFetch( [var id], [buffer], [var size] ) X** Reads the given kernel structure from memory. Places the data in X** the given buffer. X** X** [0/1] metInit() X** Initializes the local metrics cache. Reads the array of addresses X** of engines and initializes the offsets into the engine for each X** local metrics structure. X** X** [local address] metFetch( [var id] ) X** Reads the given local metrics structures, caches them, and X** returns a pointer to the cached record. This routine only X** works on variable ids of local metrics structures. X** X** The metrics and local metrics family of kernel structures only exists X** in the UnixWare 2 platform. Support for sar(1M) compatability does not X** exist in the UnixWare 2 platform. X** X** Adding new entries X** The sar version of the "recNlist" table must match the address file X** used by that platform's sar(1M) utility. You can't change this. X** X** Entries may be added to the version of the "recNlist" table at X** will. Just add a new variable id, and update the "recOffsets" table. X** Make sure that the id is defined only for those platforms which X** actully have the variable. X** X** Adding entries to the local metrics cache is more complicated. The X** cache init routine (metInit()) must be updated to insert the offset X** into the engine record (struct plocalmet) of this new structure. The X** offset is added into the "metTab" table. And a new variable id must X** be added. X*/ X X/* X** Entry in local metrics cache table. X*/ Xstruct metEnt X{ X unsigned var; X size_t size; X off_t offset; X void *ptr; X}; X X/* X*/ Xstruct siEnt X{ X unsigned var; X size_t size; X char init; X void *buf; X}; X X#ifdef SVR4 X/* X** The SVR4 address file used by sar. Reverse engineered. X** When sar compatability is used, "recNlist" points to X** this table. X*/ X#define SARG_NL_HDSTAT 0 X#define SARG_NL_SYSINFO 1 X#define SARG_NL_MINFO 2 X#define SARG_NL_INODE 3 X#define SARG_NL_FILECNT 4 X#define SARG_NL_TEXT 5 X#define SARG_NL_NPROC 6 X#define SARG_NL_FLCKINFO 7 X#define SARG_NL_V 8 X#define SARG_NL_SYSERR 9 X#define SARG_NL_RFSRVINFOT 10 X#define SARG_NL_MINSERVE 11 X#define SARG_NL_MAXSERVE 12 X#define SARG_NL_RFCINFOT 13 X#define SARG_NL_NINODE 14 X#define SARG_NL_RFSRVINFO 15 X#define SARG_NL_RFCLFSINFO 16 X#define SARG_NL_RFSRFSINFO 17 X#define SARG_NL_RFCINFO 18 X#define SARG_NL_KMEMINFO 19 X#define SARG_NL_VMINFO 20 X#define SARG_NL_BOOTINFO 21 X#define SARG_NL_i214BDD 22 Xstatic struct nlist recNlistSar[] = X{ X { "hdstat", 0, 0 }, X { "sysinfo", 0, 0 }, X { "minfo", 0, 0 }, X { "inode", 0, 0 }, X { "filecnt", 0, 0 }, X { "text", 0, 0 }, X { "nproc", 0, 0 }, X { "flckinfo", 0, 0 }, X { "v", 0, 0 }, X { "syserr", 0, 0 }, X { "rf_srv_info_t", 0, 0 }, X { "minserve", 0, 0 }, X { "maxserve", 0, 0 }, X { "rfc_info_t", 0, 0 }, X { "ninode", 0, 0 }, X { "rf_srv_info", 0, 0 }, X { "rfcl_fsinfo", 0, 0 }, X { "rfsr_fsinfo", 0, 0 }, X { "rfc_info", 0, 0 }, X { "kmeminfo", 0, 0 }, X { "vminfo", 0, 0 }, X { "bootinfo", 0, 0 }, X { "i214bdd", 0, 0 }, X { 0, 0, 0 } X}; X/* X** Lsar address file for SVR4. When sar compatability is not being X** used, "recNlist" points to this table. X*/ X#define SARG_LNL_SYSINFO 0 X#define SARG_LNL_MINFO 1 X#define SARG_LNL_NPROC 2 X#define SARG_LNL_V 3 X#define SARG_LNL_MSGINFO 4 X#define SARG_LNL_SEMINFO 5 Xstatic struct nlist recNlistLsar[] = X{ X { "sysinfo", 0, 0 }, /* struct sysinfo */ X { "minfo", 0, 0 }, /* struct minfo */ X { "nproc", 0, 0 }, /* short */ X { "v", 0, 0 }, /* struct var */ X { "msginfo", 0, 0 }, /* struct msginfo */ X { "seminfo", 0, 0 }, /* struct seminfo */ X { "", 0, 0 }, /* Terminating entry */ X}; X#endif X X#if defined(UW2) X/* X** Sargent does not support sar(1M) compatability for the UnixWare 2 X** platform. The stub below exists to reduce the number of "ifdefs" X** in the code. X*/ X#define SARG_NL_V -1 Xstatic struct nlist recNlistSar[] = X{ X { "", 0, 0 }, /* Terminating entry. */ X}; X X/* X** Lsar address file for UnixWare 2. "recNlist" always points to X** this table. X*/ X/* These constants are offsets into a table. */ X#define SARG_LNL_METS 0 X#define SARG_LNL_LOCALPTR 1 X#define SARG_LNL_LOCALOFF 2 X#define SARG_LNL_V 3 X#define SARG_LNL_MODHEAD 4 X#define SARG_LNL_DISKCNT 5 X#define SARG_LNL_SD01DP 6 X#define SARG_LNL_ROOTVFS 7 Xstatic struct nlist recNlistLsar[] = X{ X { "m", 0, 0 }, /* struct mets */ X { "met_localdata_ptrs_p", 0, 0 }, /* struct met_localdata_ptrs */ X { "met_ppmets_offsets", 0, 0 }, /* struct met_ppmets_offsets */ X { "v", 0, 0 }, /* struct var */ X { "modhead", 0, 0 }, /* struct modctl */ X { "sd01_diskcnt", 0, 0 }, /* int */ X { "sd01_dp", 0, 0 }, /* struct disk[] */ X { "rootvfs", 0, 0 }, /* struct vfs */ X { "", 0, 0 }, /* Terminating entry */ X}; X X/* X** UnixWare 2 metrics buffer pool. X*/ Xstatic struct metEnt metTab[] = X{ X { SARG_VAR_STR, sizeof(struct metp_str_resrc), 0, NULL }, X { SARG_VAR_CPU, sizeof(struct metp_cpu), 0, NULL }, X { SARG_VAR_VMMETER, sizeof(struct vmmeter), 0, NULL }, X { SARG_VAR_BUF, sizeof(struct metp_buf), 0, NULL }, X { SARG_VAR_TTY, sizeof(struct metp_tty), 0, NULL }, X { SARG_VAR_SYSCALL, sizeof(struct metp_syscall), 0, NULL }, X { SARG_VAR_VM, sizeof(struct metp_vm), 0, NULL }, X { SARG_VAR_KMEM, sizeof(struct metp_kmem)*MET_KMEM_NCLASS, 0, NULL }, X { SARG_VAR_NULL, 0, 0, NULL } X}; X#endif X X#ifdef SCO5 X/* X** Sargent does not support sar(1M) compatability for the SCO5 X** platform. The stub below exists to reduce the number of "ifdefs" X** in the code. X*/ X#define SARG_NL_V -1 X#define SARG_NL_SYSINFO -1 X#define SARG_NL_MINFO -1 X#define SARG_NL_INODE -1 X#define SARG_NL_FILE -1 X#define SARG_NL_PROC -1 X#define SARG_NL_FLOCK -1 X#define SARG_NL_SYSERR -1 Xstatic struct nlist recNlistSar[] = X{ X { "", 0, 0 }, /* Terminating entry. */ X}; X/* X** Sargent address file for SCO 3.2v5. X*/ X#define SARG_LNL_SYSINFO 0 X#define SARG_LNL_MINFO 1 X#define SARG_LNL_INODE 2 X#define SARG_LNL_FILE 3 X#define SARG_LNL_PROC 4 X#define SARG_LNL_FLOCK 5 X#define SARG_LNL_V 6 X#define SARG_LNL_SYSERR 7 X#define SARG_LNL_FREEMEM 8 X#define SARG_LNL_QUEUE 9 X#define SARG_LNL_MBLOCK 10 X#define SARG_LNL_NMBLOCK 11 X#define SARG_LNL_DBLOCK 12 X#define SARG_LNL_MSGINFO 13 X#define SARG_LNL_MSGQUE 14 X#define SARG_LNL_SEMINFO 15 X#define SARG_LNL_MOUNT 16 X#define SARG_LNL_NFSTYP 17 X#define SARG_LNL_FSINFO 18 X#define SARG_LNL_NDISKS 19 X#define SARG_LNL_DSKPROBE 20 X#define SARG_LNL_SDSKSTATS 21 X#define SARG_LNL_DSKSTUFF 22 X#define SARG_LNL_STRSTAT 23 Xstatic struct nlist recNlistLsar[] = X{ X { "sysinfo", 0, 0 }, /* struct sysinfo */ X { "minfo", 0, 0 }, /* struct minfo */ X { "inode", 0, 0 }, /* struct inode[] */ X { "file", 0, 0 }, /* struct file[] */ X { "proc", 0, 0 }, /* struct proc[] */ X { "flckinfo", 0, 0 }, /* struct flckinfo */ X { "v", 0, 0 }, /* struct var */ X { "syserr", 0, 0 }, /* struct syserr */ X { "freemem", 0, 0 }, /* int */ X { "queue", 0, 0 }, /* struct queue[] */ X { "mblock", 0, 0 }, /* mblk_t[] */ X { "nmblock", 0, 0 }, /* int */ X { "dblock", 0, 0 }, /* dblk_t[] */ X { "msginfo", 0, 0 }, /* struct msginfo */ X { "msgque", 0, 0 }, /* struct msqid_ds[] */ X { "seminfo", 0, 0 }, /* struct seminfo */ X { "mount", 0, 0 }, /* struct mount[] */ X { "nfstyp", 0, 0 }, /* short */ X { "fsinfo", 0, 0 }, /* struct fsinfo[] */ SHAR_EOF : || $echo 'restore of' 'orion-1.0/sargent/kern.c' 'failed' fi $echo 'End of' 'orion-1.0' 'part' '5' $echo 'File' 'orion-1.0/sargent/kern.c' 'is continued in part' '6' echo 6 > _sh05649/seq exit 0 Article 13471 of alt.sources: Submitted-by: ljp@tiac.net Archive-name: orion-1.0/part02 ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is `orion.02' (part 2 of orion-1.0). # Do not concatenate these parts, unpack them in order with `/bin/sh'. # File `orion-1.0/sarrep/tty.c' is being continued... # save_IFS="${IFS}" IFS="${IFS}:" gettext_dir=FAILED locale_dir=FAILED first_param="$1" for dir in $PATH do if test "$gettext_dir" = FAILED && test -f $dir/gettext \ && ($dir/gettext --version >/dev/null 2>&1) then set `$dir/gettext --version 2>&1` if test "$3" = GNU then gettext_dir=$dir fi fi if test "$locale_dir" = FAILED && test -f $dir/shar \ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1) then locale_dir=`$dir/shar --print-text-domain-dir` fi done IFS="$save_IFS" if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED then echo=echo else TEXTDOMAINDIR=$locale_dir export TEXTDOMAINDIR TEXTDOMAIN=sharutils export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi if test ! -r _sh05649/seq; then $echo 'Please unpack part 1 first!' exit 1 fi shar_sequence=`cat _sh05649/seq` if test "$shar_sequence" != 2; then $echo 'Please unpack part' "$shar_sequence" 'next!' exit 1 fi if test ! -f _sh05649/new; then $echo 'x -' 'STILL SKIPPING' 'orion-1.0/sarrep/tty.c' else $echo 'x -' 'continuing file' 'orion-1.0/sarrep/tty.c' sed 's/^X//' << 'SHAR_EOF' >> orion-1.0/sarrep/tty.c && X fputs( "\tTTY Subsystem.\n", stdout ); X X if( recSave.countTtyOut>0 && recSave.countTtyOut<1000 ) X { X fprintf( stdout, "\t\tOutput: %.1f ch/s (%lu ch)\n", X recSave.rateTtyOut, (int)recSave.countTtyOut ); X } X else X { X fprintf( stdout, "\t\tOutput: %.1f ch/s\n", X (int)recSave.rateTtyOut ); X } X if( recSave.countTtyRaw>0 && recSave.countTtyRaw < 1000 ) X { X fprintf( stdout, "\t\tRaw: %.1f ch/s (%lu ch)\n", X recSave.rateTtyRaw, (int)recSave.countTtyRaw ); X } X else X { X fprintf( stdout, "\t\tRaw: %.1f ch/s\n", X (int)recSave.rateTtyRaw ); X } X if( recSave.countTtyCan>0 && recSave.countTtyCan<1000 ) X { X fprintf( stdout, "\t\tCanonical: %.1f ch/s (%lu ch)\n", X recSave.rateTtyCan, (int)recSave.countTtyCan ); X } X else X { X fprintf( stdout, "\t\tCanonical: %.1f ch/s\n", X (int)recSave.rateTtyCan ); X } X fprintf( stdout, "\t\tModem: %.1f intr/s.\n", X recSave.rateTtyModem ); X fprintf( stdout, "\t\tTransmit: %.1f intr/s.\n", X recSave.rateTtyTx ); X fprintf( stdout, "\t\tReceive: %.1f intr/s.\n", X recSave.rateTtyRx ); X X orecSar = recSar; X timeLast = timeCurr; X X return 1; X} SHAR_EOF $echo 'File' 'orion-1.0/sarrep/tty.c' 'is complete' && chmod 0664 'orion-1.0/sarrep/tty.c' || $echo 'restore of' 'orion-1.0/sarrep/tty.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/sarrep/tty.c:' 'MD5 check failed' a034bd0c0a565e608ebb10095890c08a orion-1.0/sarrep/tty.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/sarrep/tty.c'`" test 3838 -eq "$shar_count" || $echo 'orion-1.0/sarrep/tty.c:' 'original size' '3838,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/sarrep/sarrep.h ============== if test -f 'orion-1.0/sarrep/sarrep.h' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/sarrep/sarrep.h' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/sarrep/sarrep.h' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/sarrep/sarrep.h' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X/* X** $Id: sarrep.h,v 1.4 1996/06/24 06:14:44 ljp Exp $ X** X** $Log: sarrep.h,v $ X * Revision 1.4 1996/06/24 06:14:44 ljp X * SCO UNIX 3.2v4 support. Disk record type. X * X * Revision 1.3 1996/05/26 07:31:08 ljp X * Support for Streams, Module and Memsys records. X * X*/ X X#ifndef SARREP_H X#define SARREP_H X X/* X** VENIX32 and SVR3 get their kernel headers X** from "liborion.h". X*/ X#if !defined(VENIX32) && !defined(SVR3) X#include X#endif X X#include X#include X X#define SARREP_MAX_CPUTIMES 5 /* For sysinfo structure. */ X#define SARREP_MAX_WAITTIMES 3 /* For sysinfo structure. */ X#define SARREP_MAX_PROCS SARG_MAX_PROCS*4 X X/* X** Per process data held across sargent records. X*/ Xstruct proctracks X{ X pid_t pid; X time_t timeLast; X time_t timeCpu; X}; X Xextern int globalDebug; Xextern struct proctracks globalProcs[]; X Xextern const char *S_Empty; Xextern const char *S_FormatTime; X Xextern int crunchBasic1( int, struct sargHdr* ); Xextern int basic1Init( void ); Xextern int crunchProc( int, struct sargHdr* ); Xextern int procInit( void ); Xextern int crunchPs( int, struct sargHdr* ); X#ifdef WOLLONG32 Xextern int crunchWollong( int, struct sargHdr* ); X#endif Xextern int crunchMount( int, struct sargHdr* ); Xextern int crunchNetstat( int, struct sargHdr* ); Xextern int crunchIpcs( int, struct sargHdr* ); Xextern int ipcsInit( void ); Xextern int crunchReboot( int, struct sargHdr* ); Xextern int crunchTty( int, struct sargHdr* ); Xextern int ttyInit( void ); Xextern int crunchStreams( int, struct sargHdr* ); Xextern int crunchMemsys( int, struct sargHdr* ); Xextern int crunchModule( int, struct sargHdr* ); Xextern int crunchDisk( int, struct sargHdr* ); X#ifdef VENIX32 Xextern int crunchVenix( int, struct sargHdr* ); X#endif Xextern int recRead( int, unsigned, void*, unsigned ); Xextern const char *timeFormat( time_t, const char* ); X X#endif SHAR_EOF chmod 0664 'orion-1.0/sarrep/sarrep.h' || $echo 'restore of' 'orion-1.0/sarrep/sarrep.h' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/sarrep/sarrep.h:' 'MD5 check failed' d5ea7ef6e64d2c5d596f2aad904538c7 orion-1.0/sarrep/sarrep.h SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/sarrep/sarrep.h'`" test 2506 -eq "$shar_count" || $echo 'orion-1.0/sarrep/sarrep.h:' 'original size' '2506,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/sarrep/module.c ============== if test -f 'orion-1.0/sarrep/module.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/sarrep/module.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/sarrep/module.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/sarrep/module.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X/* X** $Id: module.c,v 1.1 1996/05/26 07:31:05 ljp Exp $ X** X** $Log: module.c,v $ X * Revision 1.1 1996/05/26 07:31:05 ljp X * Support for Streams, Module and Memsys records. X * X*/ X X#include"sarrep.h" X Xint crunchModule( int fd, struct sargHdr *hdr ) X{ X int rc; X unsigned short i, j; X size_t size; X struct sargModule *recSar; X X /* X ** Read the first field of the record. X */ X if( (rc=read(fd,(void*)&i,sizeof(unsigned short))) == -1 ) X return rc; X X size = sizeof(struct sargModule) + ((i-1)*sizeof(recSar->loaded[0])); X X if( (recSar=(struct sargModule*)malloc(size)) == NULL ) X return 0; X X recSar->count = i; X X /* Skip 2 pad bytes. */ X read( fd, (void*)&(recSar->loaded[0]), 2 ); X X if( (rc=read(fd,(void*)&(recSar->loaded[0]), X size-(sizeof(unsigned short)+2))) < 1 ) X { X return rc; X } X X fputs( "\tKernel modules.\n", stdout ); X X fprintf( stdout, "\t\tLoaded modules.\n" ); X for( i=0; icount; i+=4 ) X { X fprintf( stdout, "\t\t" ); X for( j=0; (j<3)&&(i+jcount); ++j ) X { X fprintf( stdout, " %04u %10s", X recSar->loaded[i+j].id, recSar->loaded[i+j].name ); X } X fputc( (int)'\n', stdout ); X } X X return 1; X} SHAR_EOF chmod 0664 'orion-1.0/sarrep/module.c' || $echo 'restore of' 'orion-1.0/sarrep/module.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/sarrep/module.c:' 'MD5 check failed' cc2efa8c908e1c47738ddc423f51309a orion-1.0/sarrep/module.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/sarrep/module.c'`" test 1827 -eq "$shar_count" || $echo 'orion-1.0/sarrep/module.c:' 'original size' '1827,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/sarrep/sarrep.c ============== if test -f 'orion-1.0/sarrep/sarrep.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/sarrep/sarrep.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/sarrep/sarrep.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/sarrep/sarrep.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X/* X** $Id: sarrep.c,v 1.5 1996/06/25 03:51:49 ljp Exp $ X** X** $Log: sarrep.c,v $ X * Revision 1.5 1996/06/25 03:51:49 ljp X * Removed reference to PROC1. X * X * Revision 1.4 1996/06/24 06:14:43 ljp X * SCO UNIX 3.2v4 support. Disk record type. X * X * Revision 1.3 1996/05/26 07:31:07 ljp X * Support for Streams, Module and Memsys records. X * X*/ X X/* X** VENIX32 and SVR3 get their kernel X** includes from "liborion.h". X*/ X#include"sarrep.h" X X/* X** String table. X*/ Xconst char *S_Empty = ""; Xconst char *S_FormatTime = "%I:%M:%S %p %D"; Xstatic const char *S_FormatStamp = "%I:%M:%S"; Xstatic const char *S_PrefixSa = "sa"; Xstatic const char *S_PrefixLsa = "ssa"; Xstatic const char *S_PathSa = "/usr/adm/sa"; Xstatic const char *S_PathLsa = "/usr/adm/sa"; Xstatic const char *S_Ver = SARG_STR_VER; X Xstatic void usage( void ); X#if defined(VENIX32) Xstatic int crunchSar( int, int, time_t, int, time_t ); X#endif Xstatic int crunchSarg( int, int, time_t, int, time_t ); Xstatic time_t timeCalc( const char* ); X/* Compiler won't deal with pointers to functions! */ Xstatic void *ctabFunc( unsigned ); Xstatic const char *ctabName( unsigned ); X Xstruct crunchEntry X{ X unsigned c_type; X int (*c_crunch)(int,struct sargHdr*); X const char *c_name; X int (*c_init)(void); X}; X Xstruct crunchEntry crunchTable[] = X{ X { SARG_RTYP_BASIC1, crunchBasic1, "Basic1", basic1Init }, X { SARG_RTYP_REBOOT, crunchReboot, "Reboot", NULL }, X { SARG_RTYP_PROC, crunchProc, "Proc", procInit }, X#ifdef WOLLONG32 X { SARG_RTYP_WOLLONG, crunchWollong, "Wollong", NULL }, X#endif X { SARG_RTYP_NETSTAT, crunchNetstat, "Netstat", NULL }, X { SARG_RTYP_MOUNT, crunchMount, "Mount", NULL }, X { SARG_RTYP_PS, crunchPs, "Ps", NULL }, X { SARG_RTYP_IPCS, crunchIpcs, "Ipcs", NULL }, X { SARG_RTYP_TTY, crunchTty, "TTY", ttyInit }, X { SARG_RTYP_STREAMS, crunchStreams, "STREAMS", NULL }, X { SARG_RTYP_MEMSYS, crunchMemsys, "Memsys", NULL }, X { SARG_RTYP_MODULE, crunchModule, "Module", NULL }, X { SARG_RTYP_DISK, crunchDisk, "Disk", NULL }, X#ifdef VENIX32 X { SARG_RTYP_VENIX, crunchVenix, "Venix", NULL }, X#endif X { SARG_RTYP_NULL, NULL, "", NULL } X}; X Xextern int errno; Xextern char *sys_errlist[]; X Xstatic int flagSar; /* 1=sar data. 0=Sargent data. */ X Xint globalDebug; X X/* X** Per process data held across sargProc records. X** This is global because both reboot and process X** records use it. X*/ Xstruct proctracks globalProcs[SARREP_MAX_PROCS]; X Xmain( int argc, char *argv[] ) X{ X char *strTimeBegin, *strTimeEnd; X char filename[1023+1]; X int fd; X int i; X int mday; X time_t timeBegin, timeEnd; X X filename[0] = '\0'; X strTimeBegin = NULL; X strTimeEnd = NULL; X mday = -1; X X for( i=1; i= argc ) X { X fputs( "Need argument to \"-s\".\n", stdout ); X usage(); X exit( 1 ); X } X strTimeBegin = argv[i]; X continue; X } X if( !strcmp(argv[i],"-e") ) X { X ++i; X if( i >= argc ) X { X fputs( "Need argument to \"-e\".\n", stdout ); X usage(); X exit( 1 ); X } X strTimeEnd = argv[i]; X continue; X } X if( !strcmp(argv[i],"-f") ) X { X ++i; X if( i >= argc ) X { X fputs( "Need argument to \"-f\".\n", stdout ); X usage(); X exit( 1 ); X } X strcpy( filename, argv[i] ); X continue; X } X if( !strcmp("-sar",argv[i]) ) X { X ++flagSar; X continue; X } X if( !strcmp("-v",argv[i]) ) X { X ++globalDebug; X continue; X } X if( !strcmp("-ver",argv[i]) ) X { X fprintf( stdout, "Lsar version is %s.\n", S_Ver ); X exit( 0 ); X } X if( !strcmp("-?",argv[i]) ) X { X usage(); X exit( 1 ); X } X if( argv[i][0] == '-' ) X { X fprintf( stdout, "Unrecognized option, \"%s\".\n", X argv[i] ); X usage(); X exit( 1 ); X } X if( mday != -1 ) X { X fputs( "Only one day of month may be given.\n", stdout ); X usage(); X exit( 1 ); X } X if( (mday=atoi(argv[i])) < 1 ) X { X fprintf( stdout, "Invalid day of month, \"%s\".\n", X argv[i] ); X usage(); X exit( 1 ); X } X } X X /* X ** If a filename is not given, use the standard file for X ** today's data. X */ X if( filename[0] == '\0' ) X { X time_t timeCurr; X struct tm *recTimeCurr; X X timeCurr = time( NULL ); X recTimeCurr = localtime( &timeCurr ); X sprintf( filename, "%s/%s%.2d", X flagSar?S_PathSa:S_PathLsa, X flagSar?S_PrefixSa:S_PrefixLsa, X recTimeCurr->tm_mday ); X } X X /* X */ X timeBegin = timeEnd = 0; X if( strTimeBegin != NULL ) X { X timeBegin = timeCalc( strTimeBegin ); X } X if( strTimeEnd != NULL ) X { X timeEnd = timeCalc( strTimeEnd ); X } X if( strTimeBegin!=NULL && strTimeEnd!=NULL ) X { X if( timeEnd < timeBegin ) X { X fputs( "End time must be later than begin time.\n", stdout ); X exit( 1 ); X } X } X X if( (fd=open(filename,O_RDONLY)) == -1 ) X { X fprintf( stdout, "Bad open(2) on \"%s\". %s.\n", X filename, sys_errlist[errno] ); X exit( 1 ); X } X X { X int i; X X for( i=0; crunchTable[i].c_type; ++i ) X { X if( crunchTable[i].c_init != NULL ) X (void*)crunchTable[i].c_init(); X } X } X X fprintf( stdout, X "Reading %s data from file \"%s\".\n", X flagSar?"sar":"Sargent", X filename ); X#if defined(VENIX32) X if( flagSar ) X { X (void)crunchSar( fd, strTimeBegin!=NULL, timeBegin, X strTimeEnd!=NULL, timeEnd ); X } X else X#endif X { X (void)crunchSarg( fd, strTimeBegin!=NULL, timeBegin, X strTimeEnd!=NULL, timeEnd ); X } X X close( fd ); X X exit( 0 ); X} X X#if defined(VENIX32) Xstatic int crunchSar( int fd, int flagBeginTime, time_t timeBegin, X int flagEndTime, time_t timeEnd ) X{ X char strTime[15+1]; X int rc; X int flagDone; X struct tm *recTime; X struct sa recSar, orecSar; X struct recSave recSave, orecSave; X X flagDone = 0; X orecSave.flagMarker = 1; X while( !flagDone ) X { X if( (rc=read(fd,&recSar,sizeof(recSar))) == -1 ) X { X fputs( "Could not read record from sar file.\n", stdout ); X fprintf( stdout, "Bad read(2). %s.\n", X sys_errlist[errno] ); X close( fd ); X exit( 1 ); X } X if( rc == 0 ) X break; X if( rc != sizeof(recSar) ) X { X fprintf( stdout, X "Bad record in sar file. Only read %d bytes.\n", X rc ); X close( fd ); X exit( 1 ); X } X X if( (recTime=localtime(&(recSar.ts))) == NULL ) X { X fputs( "Bad value in \"ts\" field of sar record.\n", stdout ); X close( fd ); X exit( 1 ); X } X X /* X ** Stay within the begin and end times. X */ X { X time_t timeNow; X X timeNow = recTime->tm_sec + (recTime->tm_min*60) + X (recTime->tm_hour*60*60); X if( flagBeginTime && timeNowtimeEnd ) X break; X } X X ascftime( strTime, S_FormatTime, recTime ); X X if( (recSar.si.cpu[CPU_IDLE]+recSar.si.cpu[CPU_WAIT]+ X recSar.si.cpu[CPU_USER]) < 0L ) X { X recSave.flagMarker = 1; X } X else X { X int i; X time_t timeCurr; X time_t timeLast; X float timeDelta, wtimeDelta; X X /* X ** Calculate the number of seconds which have passed. X */ X recSave.timeInterval = recSar.ts - orecSar.ts; X X /* X ** Calculate the amount of CPU time that has passed. X */ X timeLast = 0; X timeCurr = 0; X for( i=0; i 0 ) X { X recSave.cpuIo = X (float)(recSar.si.wait[W_IO]-orecSar.si.wait[W_IO]) / X wtimeDelta*100; X recSave.cpuSwap = X (float)(recSar.si.wait[W_SWAP]-orecSar.si.wait[W_SWAP]) / X wtimeDelta*100; X recSave.cpuPio = X (float)(recSar.si.wait[W_PIO]-orecSar.si.wait[W_PIO]) / X wtimeDelta*100; X } X X if( recSave.timeInterval > 0 ) X { X recSave.rateMemVfault = (recSar.mi.vfault-orecSar.mi.vfault) X / recSave.timeInterval; X recSave.rateMemSwapIn = (recSar.si.swapin-orecSar.si.swapin) X / recSave.timeInterval; X recSave.rateMemSwapOut = (recSar.si.swapout-orecSar.si.swapout) X / recSave.timeInterval; X recSave.rateProcSwitch = (recSar.si.pswitch-orecSar.si.pswitch) X / recSave.timeInterval; X recSave.rateSysTotal = (recSar.si.syscall-orecSar.si.syscall) X / recSave.timeInterval; X recSave.rateSysRead = (recSar.si.sysread-orecSar.si.sysread) X / recSave.timeInterval; X recSave.rateSysWrite = (recSar.si.syswrite-orecSar.si.syswrite) X / recSave.timeInterval; X recSave.countSysFork = recSar.si.sysfork - orecSar.si.sysfork; X recSave.rateSysFork = recSave.countSysFork / X recSave.timeInterval; X recSave.countSysExec = recSar.si.sysexec - orecSar.si.sysexec; X recSave.rateSysExec = recSave.countSysExec / X recSave.timeInterval; X recSave.countIpcMsg = recSar.si.msg - orecSar.si.msg; X recSave.rateIpcMsg = recSave.countIpcMsg / recSave.timeInterval; X recSave.countIpcSem = recSar.si.sema - orecSar.si.sema; X recSave.rateIpcSem = recSave.countIpcSem / recSave.timeInterval; X X recSave.rateIoBRead = (recSar.si.bread-orecSar.si.bread) X / recSave.timeInterval; X recSave.rateIoBWrite = (recSar.si.bwrite-orecSar.si.bwrite) X / recSave.timeInterval; X recSave.rateIoRRead = (recSar.si.phread-orecSar.si.phread) X / recSave.timeInterval; X recSave.rateIoRWrite = (recSar.si.phwrite-orecSar.si.phwrite) X / recSave.timeInterval; X X recSave.countTtyRaw = recSar.si.rawch - orecSar.si.rawch; X recSave.rateTtyRaw = recSave.countTtyRaw / recSave.timeInterval; X recSave.countTtyOut = recSar.si.outch - orecSar.si.outch; X recSave.rateTtyOut = recSave.countTtyOut / recSave.timeInterval; X recSave.countTtyCan = recSar.si.canch - orecSar.si.canch; X recSave.rateTtyCan = recSave.countTtyCan / recSave.timeInterval; X recSave.rateTtyModem = (recSar.si.mdmint-orecSar.si.mdmint) X / recSave.timeInterval; X recSave.rateTtyTx = (recSar.si.xmtint-orecSar.si.xmtint) X / recSave.timeInterval; X recSave.rateTtyRx = (recSar.si.rcvint-orecSar.si.rcvint) X / recSave.timeInterval; X } X else X { X recSave.countSysFork = -1; X recSave.countSysExec = -1; X recSave.countIpcMsg = -1; X recSave.countIpcSem = -1; X recSave.countTtyOut = -1; X recSave.countTtyRaw = -1; X recSave.countTtyCan = -1; X X recSave.rateMemVfault = 0; X recSave.rateMemSwapIn = 0; X recSave.rateMemSwapOut = 0; X recSave.rateProcSwitch = 0; X recSave.rateSysTotal = 0; X recSave.rateSysRead = 0; X recSave.rateSysWrite = 0; X recSave.rateSysFork = 0; X recSave.rateSysExec = 0; X recSave.rateIpcMsg = 0; X recSave.rateIpcSem = 0; X recSave.rateTtyRaw = 0; X recSave.rateTtyOut = 0; X recSave.rateTtyModem = 0; X recSave.rateTtyTx = 0; X recSave.rateTtyRx = 0; X } X X recSave.perProcTab = (recSar.szproc*100) / recSar.mszproc; X recSave.perFileFile = (recSar.szfile*100) / recSar.mszfile; X recSave.perFileInode = (recSar.szinode*100) / recSar.mszinode; X recSave.perFileFlock = (recSar.szlckr*100) / recSar.mszlckr; X recSave.perIoRead = X (float)( 1 - X ( (float)(recSar.si.bread-orecSar.si.bread) / X (float)(recSar.si.lread-orecSar.si.lread) ) X ) * 100; X recSave.perIoWrite = X (float)( 1 - X ( (float)(recSar.si.bwrite-orecSar.si.bwrite) / X (float)(recSar.si.lwrite-orecSar.si.lwrite) ) X ) * 100; X recSave.countProcOv = recSar.procovf - orecSar.procovf; X recSave.countFileOvFile = recSar.fileovf - orecSar.fileovf; X recSave.countFileOvInode = recSar.inodeovf - orecSar.inodeovf; X } X X if( orecSave.flagMarker && !recSave.flagMarker ) X { X orecSar = recSar; X orecSave = recSave; X continue; X } X X fprintf( stdout, X "%s\n", X strTime ); X X if( recSave.flagMarker ) X { X fputs( "\tSar marker.\n", stdout ); X orecSar = recSar; X orecSave = recSave; X continue; X } X X fprintf( stdout, X "\tSeconds since last sample: %u.\n", X (unsigned)recSave.timeInterval ); X fputs( "\tCPU Processing.\n", stdout ); X fprintf( stdout, X "\t\tTotal: Idle %.1f%%, User %.1f%%," X " Wait %.1f%%, Kernel %.1f%%.\n", X recSave.cpuIdle, recSave.cpuUser, X recSave.cpuWait, recSave.cpuKernel ); X if( recSave.cpuWait > 0 ) X { X fprintf( stdout, X "\t\tWait: IO %.1f%%, Swap %.1f%%, PIO %.1f%%.\n", X recSave.cpuIo, recSave.cpuSwap, recSave.cpuPio ); X } X X /* X ** Processes. X */ X fputs( "\tProcesses Management Subsystem.\n", stdout ); X fprintf( stdout, X "\t\tProcess entries: %d\n", recSar.szproc ); X fprintf( stdout, X "\t\tProcess table: %d%% full\n", X recSave.perProcTab ); X fprintf( stdout, X "\t\tContext switches: %d switch/s\n", X recSave.rateProcSwitch ); X fprintf( stdout, X "\t\tProcess table overflows: %d\n", X recSave.countProcOv ); X X /* X ** Memory Management Subsystem. X */ X fputs( "\tMemory Management Subsystem.\n", stdout ); X fprintf( stdout, X "\t\tSwap ins: %d swap/s\n", X recSave.rateMemSwapIn ); X fprintf( stdout, X "\t\tSwap outs: %d swap/s\n", X recSave.rateMemSwapOut ); X fprintf( stdout, X "\t\tFree swap: %d blocks\n", X recSar.mi.freeswap ); X fprintf( stdout, X "\t\tFree core: %lx,%lx pages\n", X recSar.mi.freemem[1], recSar.mi.freemem[0] ); X fprintf( stdout, X "\t\tAddress faults: %.2f fault/s\n", X recSave.rateMemVfault ); X X /* X ** File Management Subsystem. X */ X fputs( "\tFile Management Subsystem.\n", stdout ); X fprintf( stdout, X "\t\tFile entries: %d\n", recSar.szfile ); X fprintf( stdout, X "\t\tFile table: %d%% full\n", X recSave.perFileFile ); X fprintf( stdout, X "\t\tInode entries: %d\n", recSar.szinode ); X fprintf( stdout, X "\t\tInode table: %d%% full\n", X recSave.perFileInode ); X fprintf( stdout, X "\t\tFlock table: %d%% full\n", X recSave.perFileFlock ); X fprintf( stdout, X "\t\tInode table overflows: %d\n", X recSave.countFileOvFile ); X fprintf( stdout, X "\t\tFile table overflows: %d\n", X recSave.countFileOvInode ); X X /* X ** I/O Subsystem. X */ X fputs( "\tI/O Subsystem.\n", stdout ); X fprintf( stdout, X "\t\tBlock I/O reads: %.2f op/s\n", X recSave.rateIoBRead ); X fprintf( stdout, X "\t\tBlock I/O writes: %.2f op/s\n", X recSave.rateIoBWrite ); X fprintf( stdout, X "\t\tRaw I/O reads: %.2f op/s\n", X recSave.rateIoRRead ); X fprintf( stdout, X "\t\tRaw I/O writes: %.2f op/s\n", X recSave.rateIoRWrite ); X fprintf( stdout, X "\t\tBuffer read hits: %.2f%%\n", X recSave.perIoRead ); X fprintf( stdout, X "\t\tBuffer write hits: %.2f%%\n", X recSave.perIoWrite ); X X /* X ** TTY Subsystem. X */ X fputs( "\tTTY Subsystem.\n", stdout ); X if( recSave.countTtyOut>0 && recSave.countTtyOut<1000 ) X { X fprintf( stdout, "\t\tOutput: %d ch/s (%d ch)\n", X recSave.rateTtyOut, (int)recSave.countTtyOut ); X } X else X { X fprintf( stdout, "\t\tOutput: %d ch/s\n", X (int)recSave.rateTtyOut ); X } X if( recSave.countTtyRaw>0 && recSave.countTtyRaw < 1000 ) X { X fprintf( stdout, "\t\tRaw: %d ch/s (%d ch)\n", X recSave.rateTtyRaw, (int)recSave.countTtyRaw ); X } X else X { X fprintf( stdout, "\t\tRaw: %d ch/s\n", X (int)recSave.rateTtyRaw ); X } X if( recSave.countTtyCan>0 && recSave.countTtyCan<1000 ) X { X fprintf( stdout, "\t\tCanonical: %d ch/s (%d ch)\n", X recSave.rateTtyCan, (int)recSave.countTtyCan ); X } X else X { X fprintf( stdout, "\t\tCanonical: %d ch/s\n", X (int)recSave.rateTtyCan ); X } X fprintf( stdout, "\t\tModem: %d intr/s.\n", X recSave.rateTtyModem ); X fprintf( stdout, "\t\tTransmit: %d intr/s.\n", X recSave.rateTtyTx ); X fprintf( stdout, "\t\tReceive: %d intr/s.\n", X recSave.rateTtyRx ); X X /* X ** IPC facilities. X */ X fputs( "\tIPC facilities.\n", stdout ); X if( recSave.countIpcMsg>0 && recSave.countIpcMsg<100 ) X { X fprintf( stdout, "\t\tMessage queue: %d op (%d op/s)\n", X recSave.countIpcMsg, (int)recSave.rateIpcMsg ); X } X else X { X fprintf( stdout, "\t\tMessage queue: %d op/s\n", X (int)recSave.rateIpcMsg ); X } X if( recSave.countIpcSem>0 && recSave.countIpcSem<100 ) X { X fprintf( stdout, "\t\tSemaphore: %d op (%dop/s)\n", X recSave.countIpcSem, (int)recSave.rateIpcSem ); X } X else X { X fprintf( stdout, "\t\tSemaphore: %d op/s\n", X (int)recSave.rateIpcSem ); X } X X /* X ** System calls. X */ X fputs( "\tSystem calls.\n", stdout ); X fprintf( stdout, "\t\tTotal: %d call/s\n", X recSave.rateSysTotal ); X if( recSave.countSysFork>0 && recSave.countSysFork<50 ) X { X fprintf( stdout, "\t\tFork: %d call/s (%d calls)\n", X recSave.rateSysFork, recSave.countSysFork ); X } X else X { X fprintf( stdout, "\t\tFork: %d call/s\n", X recSave.rateSysFork ); X } X if( recSave.countSysExec>0 && recSave.countSysExec<50 ) X { X fprintf( stdout, "\t\tExec: %d call/s (%d calls)\n", X recSave.rateSysExec, recSave.countSysExec ); X } X else X { X fprintf( stdout, "\t\tExec: %d call/s\n", X recSave.rateSysExec ); X } X fprintf( stdout, "\t\tRead: %d call/s\n", X recSave.rateSysRead ); X fprintf( stdout, "\t\tWrite: %d call/s\n", X recSave.rateSysWrite ); X X orecSar = recSar; X orecSave = recSave; X } X X return 1; X} X#endif X Xstatic int crunchSarg( int fd, int flagBeginTime, time_t timeBegin, X int flagEndTime, time_t timeEnd ) X{ X int rc; X int flagDone; X int (*crunch)(int,struct sargHdr*); X struct tm *recTime; X struct sargHdr recHdr; X X flagDone = 0; X X while( !flagDone ) X { X if( (rc=read(fd,&recHdr,sizeof(recHdr))) == -1 ) X { X fputs( "Could not read header from Sargent file.\n", stdout ); X fprintf( stdout, "Bad read(2). %s.\n", X sys_errlist[errno] ); X close( fd ); X exit( 1 ); X } X if( globalDebug ) X { X fprintf( stdout, "Record header for type %d; len %d.\n", X recHdr.h_type, recHdr.h_len ); X } X if( rc == 0 ) X { X if( globalDebug ) X fputs( "End of file.\n", stdout ); X break; X } X if( rc != sizeof(recHdr) ) X { X fprintf( stdout, X "Bad header in Sargent file. Only read %d bytes.\n", X rc ); X close( fd ); X exit( 1 ); X } X X if( (recTime=localtime(&(recHdr.h_ts))) == NULL ) X fputs( "Bad value in \"ts\" field of header.\n", stdout ); X X /* X ** Stay within the begin and end times. X */ X { X time_t timeNow; X X timeNow = recTime->tm_sec + (recTime->tm_min*60) + X (recTime->tm_hour*60*60); X if( flagBeginTime && timeNowtimeEnd ) X break; X } X X if( (crunch=(int(*)(int,struct sargHdr*))ctabFunc(recHdr.h_type)) X == NULL ) X { X fprintf( stdout, X "Unrecognized Sargent record type, 0x%02x (len %d).\n", X recHdr.h_type, recHdr.h_len ); X if( lseek(fd,recHdr.h_len,SEEK_CUR) == -1 ) X { X fprintf( stdout, "Bad lseek(). %s.\n", sys_errlist[errno] ); X break; X } X continue; X } X if( (*crunch)(fd,&recHdr) != 1 ) X { X if( globalDebug ) X { X fprintf( stdout, X "End of file. Expecting %s record.\n", X ctabName(recHdr.h_type) ); X } X ++flagDone; X } X } X X return 1; X} X Xstatic void usage( void ) X{ X fputs( "usage: sarry [-s