#! /bin/sh
#
# start/stop the syslog performance monitor daemon
#
# set environment variables as required
#Live Rule specific thresholds:
#LR_DISK_SLOW_FD    default=10.0x   derate slow floppys
#LR_DISK_SLOW_CD    default=10.0x   derate slow CDs
#LR_DISK_FLOPPY     default=   fd0  default floppy device
#LR_DISK_CDROM      default=c0t6d0  default CD device
#Pure Rule thresholds
#DISK_BUSY_WARNING  default= 5.0%   ignore less than this
#DISK_BUSY_PROBLEM  default=20.0%   
#DISK_SVC_T_WARNING default=30.0ms    
#DISK_SVC_T_PROBLEM default=50.0ms   
#ENET_INUSE         default=50.0/s  ignore fewer output packets/s
#ENET_COLL_WARNING  default= 5.0%      
#ENET_COLL_PROBLEM  default=10.0%      
#RPCCLIENT_MINCALLS default= 0.0/s  calls per sec for idle
#RPCCLIENT_TIMEOUT  default= 5.0%   calls that timeout
#RPCCLIENT_BADXID   default= 0.0%   timeouts with badxid
#SWAP_WASTE         default=100000KB  more may be a waste
#SWAP_LOTS          default= 10000KB  more is lots
#SWAP_LOW           default=  4000KB  warning LOW to LOTS
#SWAP_NONE          default=  1000KB  danger LOW-NONE, crisis
#RESTIME_LONG       default=600s    No scanning - long res time
#RESTIME_OK         default= 40s    residence time of unref pages
#RESTIME_PROBLEM    default= 20s    pages stolen too quickly
#KMEM_FREEMEM_LOW   default= 64pg   few pages for kernel to use
#RUNQ_IDLE          default= 0.0    Spare CPU capacity
#RUNQ_BUSY          default= 3.0    OK up to this level
#RUNQ_OVERLOAD      default= 5.0    Warning up to this level
#MUTEX_BUSY         default=200.0/s OK up to this level per-CPU
#MUTEX_OVERLOAD     default=400.0/s Warning up to this level
#DNLC_ACTIVE        default=100.0/s minimum activity
#DNLC_WARNING       default=90.0%   warning missrate
#INODE_ACTIVE       default=100.0/s minimum activity
#INODE_WARNING      default=90.0%   warning missrate
#INODE_IPF          default= 0.0%   stolen inodes w/pages frac

SE=/opt/RICHPse/bin/se
ML=/opt/RICHPse/examples/monlog.se
export SE ML

case "$1" in
 
'start')
	# Start the monitor daemon
	if [ -f /opt/RICHPse/etc/start_ml ]; then
	    if [ -f $ML ] ; then
		echo "Starting performance monitor syslog daemon"
		$SE -o- $ML | $SE -t$ML &
	    fi
	fi
	;;
'stop')
	# Stop the monitor daemon
	id=`/bin/ps -ef | /bin/grep monlog.se | /bin/grep -v grep | /bin/awk '{print $2}'`
	if [ -n "$id" ]; then
		echo "Stopping performance monitor daemon"
		kill $id
	fi
	;;
esac
