#! /bin/sh
#
#
# start/stop the system performance monitor daemon
#
# set these environment variables to alter thresholds
# DISK_BUSY_WARNING  default=  5%   getenv=  5%   ignore less than this
# DISK_BUSY_PROBLEM  default= 20%   getenv= 20%   
# DISK_SVC_T_WARNING default= 30ms  getenv= 30ms  
# DISK_SVC_T_PROBLEM default= 50ms  getenv= 50ms  
# ENET_INUSE         default= 10/s  getenv= 10/s  ignore fewer output packets/s
# ENET_COLL_WARNING  default=  2%   getenv=  2%   
# ENET_COLL_PROBLEM  default=  5%   getenv=  5%   
# RPCCLIENT_MINCALLS default=  0/s  getenv=  0/s  calls per sec for idle
# RPCCLIENT_TIMEOUT  default=  5%   getenv=  5%   calls that timeout
# RPCCLIENT_BADXID   default=  0%   getenv=  0%   timeouts with badxid
# SWAP_WASTE         default=100000KB  getenv=100000KB  more may be a waste
# SWAP_LOTS          default= 10000KB  getenv= 10000KB  more is lots
# SWAP_LOW           default=  4000KB  getenv=  4000KB  warning LOW to LOTS
# SWAP_NONE          default=  1000KB  getenv=  1000KB  danger LOW-NONE, crisis
# RESTIME_LONG       default=600s   getenv=600s   No scanning - long res time
# RESTIME_OK         default= 40s   getenv= 40s   residence time of unref pages
# RESTIME_PROBLEM    default= 20s   getenv= 20s   pages stolen too quickly
# KMEM_FREEMEM_LOW   default= 64pg  getenv= 64pg  no pages for kernel to use
# RUNQ_IDLE          default=  0    getenv=  0    Spare CPU capacity
# RUNQ_BUSY          default=  3    getenv=  3    OK up to this level
# RUNQ_OVERLOAD      default=  5    getenv=  5    Warning up to this level
# MUTEX_BUSY         default=200/s  getenv=200/s  OK up to this level
# MUTEX_OVERLOAD     default=400/s  getenv=400/s  Warning up to this level
# DNLC_ACTIVE        default= 50/s  getenv= 50/s  minimum activity
# DNLC_WARNING       default= 90%   getenv= 90%   warning missrate
# INODE_ACTIVE       default= 50/s  getenv= 50/s  minimum activity
# INODE_WARNING      default= 90%   getenv= 90%   warning missrate
# INODE_IPF          default=  0%   getenv=  0%   stolen inodes w/pages frac

case "$1" in
 
'start')
	# Start the monitor daemon
	if [ -f BASEDIR/RICHPse/examples/monlog.se ] ; then
		echo "Starting performance monitor syslog daemon"
		BASEDIR/RICHPse/examples/monlog.se &
	fi
	;;
'stop')
	# Stop the monitor daemon
	id=`/bin/ps -e | /bin/grep monlog | /bin/awk '{print $1}'`
	if [ -n "$id" ]; then
		echo "Stopping performance monitor daemon"
		kill $id
	fi
	;;
esac
