2020-03-21 2020-03-21 约 300 字 预计阅读 1 分钟
安装node_exporter并配置为系统服务
安装安装node_exporter
1
2
3
4
cd /opt
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz
mv node_exporter-0.18.1.linux-amd64 node_exporter
设置系统服务
vim /etc/init.d/node_exporter
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
#!/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 = root
LOGFILE = /var/log/prometheus.log
LOCKFILE = /var/run/$PROGNAME .pid
start() {
echo -n "Starting $PROGNAME : "
cd /opt/node_exporter/
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
1
chmod +x /etc/init.d/node_exporter
1
2
3
/etc/init.d/node_exporter start
或
service node_exporter start
1
2
3
ps -ef | grep node_exporter
lsof -i:9100
#或web端访问:http://<ip>:9100