-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_exporter_install.sh
More file actions
45 lines (36 loc) · 1.19 KB
/
node_exporter_install.sh
File metadata and controls
45 lines (36 loc) · 1.19 KB
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
echo -e "Creating group prometheus \n"
groupadd --system prometheus
echo -e "Creating user prometheus \n"
useradd -s /sbin/nologin --system -g prometheus prometheus
wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz -P /tmp
echo -e "Extracting node exporter \n"
tar xvf /tmp/node_exporter-*linux-amd64.tar.gz -C /tmp/
cd /tmp/node_exporter*/
echo -e "Moving node exporter config in /usr/local/bin/ \n"
cp /tmp/node_exporter*/node_exporter /usr/local/bin
echo -e "Creating node_exporter.service \n"
tee /etc/systemd/system/node_exporter.service<<EOF
[Unit]
Description=Prometheus
Documentation=https://github.com/prometheus/node_exporter
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
EOF
echo -e "Reloading daemons"
systemctl daemon-reload
echo -e "Starting node service \n"
systemctl start node_exporter
echo -e "Enabling node service \n"
systemctl enable node_exporter
echo -e "Waiting for status \n"
sleep 2
systemctl status node_exporter
echo "End of configuration"