Skip to content

Instantly share code, notes, and snippets.

@Kozlov-V
Created June 10, 2014 13:47
Show Gist options
  • Save Kozlov-V/83b9032cb99988c8e723 to your computer and use it in GitHub Desktop.
Save Kozlov-V/83b9032cb99988c8e723 to your computer and use it in GitHub Desktop.
#!/sbin/runscript
# This script assumes that Riemann has a user and group set up, and that the
# service files have been extracted to `/var/lib/riemann/current`.
#
# Author: Greg Look ([email protected])
extra_started_commands="reload"
CFG_DIR=/etc/riemann
LIB_DIR=/var/lib/riemann
RUN_DIR=/var/run/riemann
LOG_DIR=/var/log/riemann
RIEMANN_DIR=$LIB_DIR/current
COMMAND=$RIEMANN_DIR/bin/riemann
CONFIG_FILE=$CFG_DIR/riemann.config
PIDFILE=$RUN_DIR/riemann.pid
start() {
checkpath -d -m 0755 -o riemann:riemann $RUN_DIR
checkpath -d -m 0755 -o riemann:riemann $LOG_DIR
ebegin "Starting riemann"
start-stop-daemon \
--start \
--user riemann:riemann \
--pidfile "$PIDFILE" \
--make-pidfile \
--background \
--exec "$COMMAND" \
-- "$CONFIG_FILE" \
2>&1 > /dev/null
eend $?
}
stop() {
ebegin "Stopping riemann"
start-stop-daemon \
--stop \
--pidfile $PIDFILE \
--exec $COMMAND
eend $?
}
reload() {
if [ ! -f $PIDFILE ]; then
eerror "$SVCNAME isn't running"
return 1
fi
ebegin "Reloading riemann configuration"
start-stop-daemon \
--signal HUP \
--pidfile $PIDFILE
eend $?
}
#!/sbin/runscript
# This script assumes that Riemann has a user and group set up, and that the
# system gem `riemann-dash` has been installed.
#
# Author: Greg Look ([email protected])
CFG_DIR=/etc/riemann
RUN_DIR=/var/run/riemann
LOG_DIR=/var/log/riemann
COMMAND=/usr/local/bin/riemann-dash
CONFIG_FILE=$CFG_DIR/dash.rb
PIDFILE=$RUN_DIR/dash.pid
LOGFILE=$LOG_DIR/dash.log
depend() {
use riemann net
}
start() {
checkpath -d -m 0755 -o riemann:riemann $RUN_DIR
checkpath -d -m 0755 -o riemann:riemann $LOG_DIR
ebegin "Starting riemann dashboard"
start-stop-daemon \
--start \
--user riemann:riemann \
--chdir $RUN_DIR \
--pidfile $PIDFILE \
--make-pidfile \
--background \
--stdout $LOGFILE \
--stderr $LOGFILE \
--exec $COMMAND \
-- $CONFIG_FILE
eend $?
}
stop() {
ebegin "Stopping riemann dashboard"
start-stop-daemon \
--stop \
--pidfile $PIDFILE \
--exec $COMMAND
eend $?
}
#!/sbin/runscript
# This script assumes that Riemann has a user and group set up, and that the
# system gem `riemann-tools` has been installed. This script should not be run
# directly; instead, link other scripts to this one like so:
#
# $ ln -s /etc/init.d/riemann.tool riemann.health
#
# Author: Greg Look ([email protected])
TOOL=${RC_SVCNAME:8}
COMMAND="riemann-$TOOL"
RUN_DIR=/var/run/riemann/tool
PIDFILE=$RUN_DIR/${TOOL}.pid
checktool() {
if [ 'tool' == "$TOOL" ]; then
eerror "The riemann.tool script is a meta-script!"
eerror "Instead, symlink other tool scripts to this one."
eend 1
exit
fi
}
depend() {
need riemann
}
start() {
checktool
checkpath -d -m 0755 -o riemann:riemann $RUN_DIR
ebegin "Starting Riemann $TOOL reporting"
start-stop-daemon \
--start \
--user riemann:riemann \
--pidfile $PIDFILE \
--make-pidfile \
--background \
--exec $COMMAND \
2>&1 > /dev/null
eend $?
}
stop() {
checktool
ebegin "Stopping Riemann $TOOL metrics"
start-stop-daemon \
--stop \
--pidfile $PIDFILE \
--exec $COMMAND
eend $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment