-
Notifications
You must be signed in to change notification settings - Fork 0
/
linux.sh
35 lines (33 loc) · 1.18 KB
/
linux.sh
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
#!/bin/bash
#Downloading
wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz # Replace on new verison
tar -xvzf node_exporter-1.1.2.linux-amd64.tar.gz
cp node_exporter-1.1.2.linux-amd64/node_exporter /usr/local/bin/
/usr/sbin/useradd --no-create-home --shell /bin/false node_exporter
chown node_exporter:node_exporter /usr/local/bin/node_exporter
#Add
tee /etc/systemd/system/node_exporter.service <<"EOF"
[Unit]
Description=Node Exporter
[Service]
User=node_exporter
Group=node_exporter
EnvironmentFile=-/etc/sysconfig/node_exporter
ExecStart=/usr/local/bin/node_exporter $OPTIONS
[Install]
WantedBy=multi-user.target
EOF
#Create
mkdir /etc/sysconfig
tee /etc/sysconfig/node_exporter <<"EOF"
OPTIONS="--collector.disable-defaults --collector.cpu --collector.cpufreq --collector.diskstats --collector.meminfo --collector.filesystem --collector.netdev"
EOF
chown node_exporter:node_exporter /etc/sysconfig/node_exporter
#Delete
rm node_exporter-1.1.2.linux-amd64.tar.gz
rm -rf node_exporter-1.1.2.linux-amd64
#Run
systemctl daemon-reload && \
systemctl enable node_exporter && \
systemctl start node_exporter && \
systemctl status node_exporter