@cdmonkey
2018-12-25T20:12:45.000000Z
字数 1051
阅读 1271
Grafana
https://gist.github.com/eloo/a06d7c70ff2a841b7bb98cd322b851b9
https://gist.github.com/mancubus77/447281619be3731461b73dd4a18593c5
vim /etc/init.d/node_exporter
#!/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/node_exporter/$PROGNAME
USER=exporter
LOGFILE=/var/log/node_exporter.log
LOCKFILE=/var/run/$PROGNAME.pid
start() {
echo -n "Starting $PROGNAME: "
cd /opt/
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
chmod +x /etc/init.d/node_exporter
生产场景:
touch /var/log/node_exporter.log
chown exporter.exporter /var/log/node_exporter.log