-
Notifications
You must be signed in to change notification settings - Fork 0
/
CentOS-6 Node Exporter Installation
81 lines (77 loc) · 1.96 KB
/
CentOS-6 Node Exporter Installation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
tar xvfz node_exporter-*.*-amd64.tar.gz
cp node_exporter-1.7.0.linux-amd64/node_exporter /usr/local/bin/
## Add /etc/init.d/node_exporter filw with contents below
useradd -M -s /bin/false node_exporter
touch /var/log/node_exporter.log /var/run/node_exporter.pid
chown node_exporter:node_exporter /var/log/node_exporter.log /var/run/node_exporter.pid
mkdir -p /var/lib/node_exporter/textfile_collector/
chmod 775 /var/lib/node_exporter/textfile_collector/
chmod 755 /etc/init.d/node_exporter
chkconfig node_exporter --add
chown node_exporter:node_exporter /var/node_exporter
service node_exporter start
/etc/init.d/node_exporter
#!/bin/bash
#
# node_exporter Export statistics to be consumed by a remote Prometheus server
#
# chkconfig: 345 70 30
# description: Prometheus node exporter
# processname: node_exporter
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
### END INIT INFO
#
#
# Prometheus node exporter
# /etc/init.d/node_exporter
#
#
# Source function library.
. /etc/init.d/functions
PROGNAME=node_exporter
PROG=/usr/local/bin/$PROGNAME
USER=node_exporter
LOGFILE=/var/log/node_exporter.log
LOCKFILE=/var/run/$PROGNAME.pid
start() {
echo -n "Starting $PROGNAME: "
cd /var/lib/node_exporter/textfile_collector/
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 node_exporter {start|stop|status|reload|restart}"
exit 1
;;
esac