Created
June 13, 2015 07:44
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 |
In case anyone comes across this in the future, the: unknown short flag '-c' is actually an issue with how switches are handled in Prometheus 2.0.
The new argument is --config.file $CONFIG_FILE
Also these arguments have to be removed: -storage.local.path $DATADIR -alertmanager.url $ALERT_MGR_URL &>$LOGFILE
As Storage and Alertmanager are handled differently in Prometheus 2.0 or greater.
Documented information here: https://prometheus.io/docs/prometheus/2.0/migration/
Thanks for publishing. It helped me run prometheus in old EC2 Linux AMI
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi, man. i get a error like the follow with your init file.
Error parsing commandline arguments: unknown short flag '-c'
prometheus: error: unknown short flag '-c'