Created
June 13, 2015 07:44
-
-
Save JoergM/489b21d903134db5d3c2 to your computer and use it in GitHub Desktop.
Prometheus init file for RHEL 5 or 6
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/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
Thanks for publishing. It helped me run prometheus in old EC2 Linux AMI