-
Notifications
You must be signed in to change notification settings - Fork 1
/
installation.sh
74 lines (61 loc) · 2.68 KB
/
installation.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Create a directory for monitoring
mkdir monitor
cd monitor
#Download curl
sudo apt install curl
if [ ! -d "prometheus-2.44.0-rc.1.linux-amd64" ]; then
curl -LO https://github.com/prometheus/prometheus/releases/download/v2.44.0-rc.1/prometheus-2.44.0-rc.1.linux-amd64.tar.gz
tar xvfz prometheus-2.44.0-rc.1.linux-amd64.tar.gz
rm -rf prometheus-2.44.0-rc.1.linux-amd64.tar.gz
fi
# Download Node Exporter if it doesn't exist
if [ ! -d "node_exporter-1.5.0.linux-amd64" ]; then
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
tar xvfz node_exporter-1.5.0.linux-amd64.tar.gz
rm -rf node_exporter-1.5.0.linux-amd64.tar.gz
fi
echo "Which Ethereum client are you using?"
echo "1. Nethermind"
echo "2. Geth"
echo "3. Besu"
echo "4. Erigon"
read -p "Enter your choice: " client_choice
if [ $client_choice == 1 ]; then
client_name="Nethermind"
elif [ $client_choice == 2 ]; then
client_name="Geth"
elif [ $client_choice == 3 ]; then
client_name="Besu"
elif [ $client_choice == 4 ]; then
client_name="Erigon"
else
echo "Invalid choice"
exit 1
fi
read -p "Do you want to provide custom config details? (y/n): " custom_choice
if [[ $custom_choice == "y" || $custom_choice == "Y" ]]; then
read -p "Enter metrics path (default is /metrics): " metrics_path
if [[ -z "$metrics_path" ]]; then
metrics_path="/metrics"
fi
read -p "Enter metrics address : " metrics_address
read -p "Enter remote write URL: " remote_write_url
read -p "Enter remote write username: " remote_write_username
read -p "Enter remote write password: " remote_write_password
cd ..
cat ./Monitor/Other/prometheus.yml | sed "s/\${metrics_path}/$metrics_path/g;s/\${metrics_address}/$metrics_address/g;s/\${remote_write_url}/$remote_write_url/g;s/\${remote_write_username}/$remote_write_username/g;s/\${remote_write_password}/$remote_write_password/g" > ./monitor/prometheus-2.44.0-rc.1.linux-amd64/prometheus.yml
elif [[ $custom_choice == "n" || $custom_choice == "N" ]]; then
read -p "Enter remote write URL: " remote_write_url
read -p "Enter remote write username: " remote_write_username
read -p "Enter remote write password: " remote_write_password
cd ..
cat ./Monitor/$client_name/prometheus.yml | sed "s/\${remote_write_url}/$remote_write_url/g;s/\${remote_write_username}/$remote_write_username/g;s/\${remote_write_password}/$remote_write_password/g" > ./monitor/prometheus-2.44.0-rc.1.linux-amd64/prometheus.yml
fi
sleep 5
# Start Prometheus and Node Exporter
cd monitor/prometheus-2.44.0-rc.1.linux-amd64
./prometheus &
cd ..
./node_exporter-1.5.0.linux-amd64/node_exporter &
echo "Prometheus and Node Exporter have been started."