Skip to content

Instantly share code, notes, and snippets.

@dragonfly-net
Forked from JoergM/alertmanager
Created May 5, 2019 15:11
Show Gist options
  • Save dragonfly-net/6f34d2a2d6b78b4e96b11edc4367e739 to your computer and use it in GitHub Desktop.
Save dragonfly-net/6f34d2a2d6b78b4e96b11edc4367e739 to your computer and use it in GitHub Desktop.
Init file for Prometheus Alertmanager for RHEL 5 or 6
#!/bin/bash
#
# /etc/rc.d/init.d/alertmanager
#
# Alertmanager for Prometheus.
#
# chkconfig: 2345 20 80 Read
# description: Alertmanager for Prometheus.
# processname: alertmanager
# Source function library.
. /etc/rc.d/init.d/functions
PROGNAME=alertmanager
PROG=/usr/local/bin/$PROGNAME
USER=prometheus
LOGFILE=/var/log/prometheus/alertmanager.log
LOCKFILE=/var/run/$PROGNAME.pid
CONFIG_FILE=/etc/prometheus/alertmanager.conf
SILENCES_FILE=/var/data/alertmanager-silences.json
start() {
echo -n "Starting $PROGNAME: "
daemon --user $USER --pidfile="$LOCKFILE" "$PROG -config.file $CONFIG_FILE -silences.file $SILENCES_FILE &>$LOGFILE &"
echo $(pidofproc $PROGNAME) >$LOCKFILE
echo
}
stop() {
echo -n "Shutting down $PROGNAME: "
killproc $PROGNAME
rm -f $LOCKFILE
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $PROGNAME
;;
restart|reload)
stop
start
;;
*)
echo "Usage: <servicename> {start|stop|status|reload|restart}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment