home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # Simple script to assist "aview"
- #
-
- usage="Usage: $0 [-i <secs>] [-Z] { top | ps | who | statusonly }"
-
- #
- # Parse command line options
- #
- sampleLength=3
- skipASHZero=
- while getopts "i:Z" curropt; do
- case $curropt in
- i)
- sampleLength=$OPTARG
- ;;
-
- Z)
- skipASHZero="-Z"
- ;;
-
- \?)
- echo $usage
- exit 1
- ;;
-
- *)
- echo "Unexpected results from getopts: $curropt"
- exit 2
- ;;
- esac
- shift `expr $OPTIND - 1`
- done
-
- #
- # Make sure a valid command was specified
- #
- case $1 in
- top | ps | who | statusonly )
- Cmd=$1
- ;;
-
- * )
- echo "Unrecognized command $1"
- echo $usage
- exit 1
- ;;
- esac
- shift 1
-
- #
- # Come up with two temporary files
- #
- TmpDir=${TMPDIR:-/var/tmp}
- if [ ! -w $TmpDir ]; then
- echo "Unable to write into temporary directory $TmpDir"
- exit 2
- fi
-
- TmpFile1=$TmpDir/aviewh.$$.1
- TmpFile2=$TmpDir/aviewh.$$.2
- if [ -f $TmpFile1 -o -f $TmpFile2 ]; then
- echo "One or more of these temporary files already exists:"
- echo $TmpFile1
- echo $TmpFile2
- exit 2
- fi
-
- #
- # Go ahead and fire off the first command, astat
- #
- /usr/sbin/astat -f 4 -i $sampleLength > $TmpFile1 &
-
- #
- # The other command depends on what was requested
- #
- case $Cmd in
- top )
- /usr/sbin/atop -f 1 -i $sampleLength $skipASHZero > $TmpFile2 &
- ;;
-
- ps )
- /usr/lib/array/aps localonly $skipASHZero > $TmpFile2 &
- ;;
-
- who )
- /usr/bsd/w | tail +2 > $TmpFile2 &
- ;;
-
- statusonly )
- touch $TmpFile2
- ;;
- esac
-
- #
- # Wait for the two commands to complete
- #
- wait
-
- #
- # Display the results and then delete them
- #
- cat $TmpFile1 $TmpFile2
- rm -f $TmpFile1 $TmpFile2
-