Last active
July 31, 2023 08:40
-
-
Save mancubus77/447281619be3731461b73dd4a18593c5 to your computer and use it in GitHub Desktop.
Prometheus node exporter init.d (Centos6/RHEL6)
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/node_exporter | |
# | |
# Prometheus node exporter | |
# | |
# description: Prometheus node exporter | |
# processname: node_exporter | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
PROGNAME=node_exporter | |
PROG=/opt/prometheus/$PROGNAME | |
USER=root | |
LOGFILE=/var/log/prometheus.log | |
LOCKFILE=/var/run/$PROGNAME.pid | |
start() { | |
echo -n "Starting $PROGNAME: " | |
cd /opt/prometheus/ | |
daemon --user $USER --pidfile="$LOCKFILE" "$PROG &>$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)#!/bin/bash | |
;; | |
*) | |
echo "Usage: service prometheus {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
kill -SIGHUP $(pidofproc $PROGNAME)#!/bin/bash
#!/bin/bash
should not be here.