Skip to content

Instantly share code, notes, and snippets.

@wangwenchao
Forked from JoergM/prometheus
Last active April 28, 2019 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangwenchao/7d7de21a303920c46621b7f4cd962765 to your computer and use it in GitHub Desktop.
Save wangwenchao/7d7de21a303920c46621b7f4cd962765 to your computer and use it in GitHub Desktop.
Prometheus init file for RHEL 5 or 6
#!/bin/bash
#
# /etc/rc.d/init.d/prometheus
#
# Prometheus monitoring server
#
# chkconfig: 2345 20 80 Read
# description: Prometheus monitoring server
# processname: prometheus
# Source function library.
. /etc/rc.d/init.d/functions
PROGNAME=prometheus
PROG=/usr/bin/local/$PROGNAME
USER=prometheus
LOGFILE=/var/log/prometheus/prometheus.log
DATADIR=/var/data/prometheus
LOCKFILE=/var/run/$PROGNAME.pid
CONFIG_FILE=/etc/prometheus/prometheus.yml
ALERT_MGR_URL=localhost:9093
start() {
echo -n "Starting $PROGNAME: "
daemon --user $USER --pidfile="$LOCKFILE" "$PROG -config.file $CONFIG_FILE -storage.local.path $DATADIR -alertmanager.url $ALERT_MGR_URL &>$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)
stop
start
;;
reload)
echo "Sending SIGHUP to $PROGNAME"
kill -SIGHUP $(pidofproc $PROGNAME)
;;
*)
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