- standard initscript for swapmon
authorMark Huang <mlhuang@cs.princeton.edu>
Fri, 28 Apr 2006 19:29:16 +0000 (19:29 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Fri, 28 Apr 2006 19:29:16 +0000 (19:29 +0000)
swapmon.init [new file with mode: 0755]

diff --git a/swapmon.init b/swapmon.init
new file mode 100755 (executable)
index 0000000..d99530d
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+# swapmon      Swap monitoring daemon
+#
+# chkconfig: 2345 98 2
+#
+# description: Resets memory hogs when swap is running low
+#
+# $Id: host.init,v 1.6 2006/04/20 09:01:00 thierry Exp $
+#
+
+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