-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_exporter-install.sh
More file actions
36 lines (33 loc) · 1.11 KB
/
node_exporter-install.sh
File metadata and controls
36 lines (33 loc) · 1.11 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
#!/bin/bash
read -p 'Enter node_exporter version name for node (ex: 1.3.1: ' NODE_VERSION
echo Configuring for node_exporter version : $NODE_VERSION
#check is install
EXISTS_FILE=/usr/local/node_exporter-linux/node_exporter
if [ -f "$EXISTS_FILE" ]; then
echo $EXISTS_FILE exists ...
exit 1
else
echo CONTINUING ...
fi
#install node_exporter
sudo wget https://github.com/prometheus/node_exporter/releases/download/v$NODE_VERSION/node_exporter-$NODE_VERSION.linux-amd64.tar.gz
sudo tar -zxvf node_exporter-$NODE_VERSION.linux-amd64.tar.gz -C /usr/local
sudo mv /usr/local/node_exporter-$NODE_VERSION.linux-amd64 /usr/local/node_exporter-linux
#add system service
sudo bash -c 'cat > /etc/systemd/system/node_exporter.service <<EOF
[Unit]
Description=Prometheus node_exporter daemon
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/node_exporter-linux/node_exporter
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF'
sudo systemctl enable node_exporter
sudo systemctl stop node_exporter
sudo systemctl start node_exporter