Setting tag mom-2.3-5
[mom.git] / swapmon.init
1 #!/bin/bash
2 #
3 # swapmon       Swap monitoring daemon
4 #
5 # chkconfig: 2345 98 2
6 #
7 # description:  Resets memory hogs when swap is running low
8 #
9
10 PATH=/sbin:/bin:/usr/bin:/usr/sbin
11
12 # Source function library.
13 . /etc/init.d/functions
14
15 # Source configuration
16 if [ -f /etc/sysconfig/swapmon ] ; then
17     . /etc/sysconfig/swapmon
18 fi
19
20 pidfile=/var/run/swapmon.pid
21 lockfile=/var/lock/subsys/swapmon
22 RETVAL=0
23
24 start ()
25 {
26     echo -n $"Starting swap monitor: "
27     daemon --check=swapmon /usr/share/pl_mom/swapmon.py $SWAPMON_OPTIONS
28     RETVAL=$?
29     echo
30     [ $RETVAL = 0 ] && touch ${lockfile}
31     return $RETVAL
32 }
33
34 stop ()
35 {
36     echo -n $"Stopping swap monitor: "
37     killproc swapmon
38     RETVAL=$?
39     echo
40     [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
41 }
42
43
44 case "$1" in
45     start)
46         start
47         ;;
48     stop)
49         stop
50         ;;
51     restart|reload)
52         stop
53         start
54         ;;
55     condrestart)
56         if [ -f ${lockfile} ] ; then
57             stop
58             start
59         fi
60         ;;
61     status)
62         status swapmon.py
63         ;;
64     *)
65         echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
66         RETVAL=1
67         ;;
68 esac
69
70 exit $RETVAL