#!/bin/bash # # swapmon Swap monitoring daemon # # chkconfig: 2345 98 2 # # description: Resets memory hogs when swap is running low # # $Id$ # PATH=/sbin:/bin:/usr/bin:/usr/sbin # Source function library. . /etc/init.d/functions # Source configuration if [ -f /etc/sysconfig/swapmon ] ; then . /etc/sysconfig/swapmon fi pidfile=/var/run/swapmon.pid lockfile=/var/lock/subsys/swapmon RETVAL=0 start () { echo -n $"Starting swap monitor: " daemon --check=swapmon /usr/share/pl_mom/swapmon.py $SWAPMON_OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } stop () { echo -n $"Stopping swap monitor: " killproc swapmon RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } case "$1" in start) start ;; stop) stop ;; restart|reload) stop start ;; condrestart) if [ -f ${lockfile} ] ; then stop start fi ;; status) status swapmon.py ;; *) echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" RETVAL=1 ;; esac exit $RETVAL