-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode-exporter.sh
More file actions
38 lines (29 loc) · 974 Bytes
/
node-exporter.sh
File metadata and controls
38 lines (29 loc) · 974 Bytes
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
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
release_os="linux"
if [[ $(uname -m) == "aarch64"* ]]; then
release_arch="arm64"
else
release_arch="amd64"
fi
else
release_os="darwin"
release_arch="arm64"
fi
rm -r /root/node-exporter
mkdir -p /root/node-exporter
cd /root/node-exporter
apt-get install tar curl -y
tag=$(curl -sL https://api.github.com/repos/prometheus/node_exporter/releases/latest | grep "tag_name" | cut -d '"' -f 4 | head -n1 | sed 's/^v//')
curl -L "https://github.com/prometheus/node_exporter/releases/download/v$tag/node_exporter-$tag.$release_os-$release_arch.tar.gz" -o node_exporter.tar.gz
tar -vxf node_exporter.tar.gz --strip-components=1 || exit
rm node_exporter.tar.gz
cat > /etc/systemd/system/node-exporter.service << EOF
[Unit]
Description=node-exporter service
[Service]
ExecStart=/root/node-exporter/node_exporter
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload