Last active
August 29, 2015 14:18
-
-
Save tingletech/686b0753cbae2c75631a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Init file for Monit system monitor | |
# Written by Stewart Adam <[email protected]> | |
# based on script by Dag Wieers <[email protected]>. | |
# | |
# chkconfig: - 98 02 | |
# description: Utility for monitoring services on a Unix system | |
# | |
# processname: monit | |
# config: /apps/dsc/.monitrc | |
# pidfile: /apps/dsc/.monit.pid | |
# Short-Description: Monit is a system monitor | |
# Source function library. | |
. /etc/init.d/functions | |
### Default variables | |
CONFIG="/apps/dsc/.monitrc" | |
prog="monit" | |
# Check if requirements are met | |
[ -x /usr/bin/monit ] || exit 1 | |
[ -r "$CONFIG" ] || exit 1 | |
RETVAL=0 | |
start() { | |
echo -n $"Starting dsc: " | |
/bin/su dsc -c '/usr/bin/monit -c /apps/dsc/.monitrc && /usr/bin/monit -c /apps/dsc/.monitrc start all' | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Shutting down dsc: " | |
/bin/su dsc -c '/usr/bin/monit -c /apps/dsc/.monitrc stop all' | |
/bin/su dsc -c '/usr/bin/monit -c /apps/dsc/.monitrc quit' | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog | |
return $RETVAL | |
} | |
restart() { | |
stop | |
start | |
} | |
reload() { | |
echo -n $"Reloading $prog: " | |
/usr/bin/monit -Ic "$CONFIG" reload | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
reload) | |
reload | |
;; | |
condrestart) | |
[ -e /var/lock/subsys/$prog ] && restart | |
RETVAL=$? | |
;; | |
status) | |
status $prog | |
RETVAL=$? | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" | |
RETVAL=1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment