-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_exporter.sh
More file actions
59 lines (45 loc) · 1.84 KB
/
Copy pathnode_exporter.sh
File metadata and controls
59 lines (45 loc) · 1.84 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
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# -----------------------------------------------------------------------------
# Linux Node Exporter Installation Script
# Version: v1.0.0
# Credits and Author: Prashant Sultania (https://github.com/psultania)
# -----------------------------------------------------------------------------
#script for auto installation of node exporter
#download node exporter
echo "Open the NodeExporter URL (https://github.com/prometheus/node_exporter/releases), identify the version and paste it below" ;
echo "For example 2.41.0" ;
echo "Which node_exporter version ?" ;
read -r NodeVersion ;
echo "Version "$NodeVersion" NODE EXPORTER for Linux --- Downloaded starting"
wget https://github.com/prometheus/node_exporter/releases/download/v"$NodeVersion"/node_exporter-"$NodeVersion".linux-amd64.tar.gz ;
tar xvfz node_exporter-"$NodeVersion".linux-amd64.tar.gz
ln -s node_exporter-"$NodeVersion".linux-amd64 current
#create system script
echo "*****************creating system script***********" ;
#cd /etc/systemd/system
#sudo vi alm-node.service
#echo "Put the IP Address below:" ;
#echo "what is th IP Address ?" ;
#read -r ipaddress ;
host=`hostname -I | awk '{ print $1 }'`
echo "$host" ;
#echo "Writes a systemd unit file"
cat << EOF > /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=service_account_name
Group=service_group_name
ExecStart=/opt/platform/nodeexporter/current/node_exporter --web.listen-address="$host:9100"
[Install]
WantedBy=default.target
EOF
chmod a+x /etc/systemd/system/node_exporter.service
echo "**********Node Exporter installed successfully**********"
# node_exporter in systemctl
sudo systemctl daemon-reload
sudo systemctl status node_exporter.service
sudo systemctl start node_exporter.service
sudo systemctl status node_exporter.service