Last active
December 18, 2015 02:09
-
-
Save tystr/5709192 to your computer and use it in GitHub Desktop.
init script for mongodb mms agent (http://mms.mongodb.com/help/monitoring/install/)
This file contains 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 | |
# | |
# /etc/rc.d/init.d/mms-agent | |
# | |
# 10Gen Mongod montiroing service | |
# must edit the settings.py first and edit this file with the location of agent.py | |
# | |
# description: 10Gen monitoring service - need ot fix pid so we can shut it down | |
# chkconfig: - 90 10 | |
# Source function library. | |
. /etc/init.d/functions | |
prog="mms-agent" | |
python="/usr/bin/python" | |
agent="/usr/local/lib/mms-agent/agent.py" | |
logfile="/var/log/mongo/$prog.log" | |
pidfile="/var/run/mongodb/$prog.pid" | |
user="mongod" | |
start() { | |
echo -n "Starting $prog: " | |
daemon --user=$user "$python $agent > $logfile 2>&1 &" | |
retval=$? | |
pid=$$ | |
echo $pid > $pidfile | |
chown $user:$user $pidfile | |
[ $retval -eq 0 ] && touch /var/lock/subsys/$prog | |
return $retval | |
} | |
stop() { | |
echo -n "Shutting down $prog: " | |
#echo "pkill -TERM -f '$python $agent'" | |
pkill -TERM -f -u $user '$python $agent' | |
retval=$? | |
echo $retval | |
[ $retval -eq 0 ] && rm -f /var/lock/subsys/$prog | |
return $retval | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart|reload) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: <servicename> {start|stop|reload|restart}" | |
exit 1 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment