-
Notifications
You must be signed in to change notification settings - Fork 28
/
setup_monitoring_gcp.sh
52 lines (40 loc) · 1.43 KB
/
setup_monitoring_gcp.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
#!/bin/bash
if [[ "$#" -lt 2 ]]; then
printf "Usage: bash setup_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <GCP Username>\n"
printf "Example: bash setup_monitoring_gcp.sh dev gcp_user\n"
printf "\n"
exit
fi
printf "\n[[[[[ setup_monitoring_gcp.sh ]]]]]\n\n"
if [[ "$1" != 'dev' ]] && [[ "$1" != 'staging' ]] && [[ "$1" != 'sandbox' ]] && [[ "$1" != 'exp' ]] && [[ "$1" != 'spring' ]] && [[ "$1" != 'summer' ]] && [[ "$1" != 'mainnet' ]]; then
printf "Invalid season argument: $1\n"
exit
fi
SEASON="$1"
GCP_USER="$2"
printf "SEASON=$SEASON\n"
printf "GCP_USER=$GCP_USER\n"
printf "\n"
printf 'Killing old jobs..\n'
killall prometheus
killall grafana-server
printf 'Setting up working directory..\n'
sudo rm -rf /home/ain-blockchain
cd ~
sudo mv ain-blockchain /home
sudo chmod -R 777 /home/ain-blockchain
sudo chown -R $GCP_USER:$GCP_USER /home/ain-blockchain
cd /home/ain-blockchain
printf 'Installing Prometheus..\n'
curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest \
| grep browser_download_url \
| grep linux-amd64 \
| cut -d '"' -f 4 \
| wget -qi -
tar xvf prometheus*.tar.gz
printf 'Renaming Prometheus folder..\n'
mv prometheus*/ prometheus
printf 'Copying Prometheus yml file..\n'
PROMETHEUS_CONFIG_FILE="prometheus-${SEASON}.yml"
printf "PROMETHEUS_CONFIG_FILE=${PROMETHEUS_CONFIG_FILE}\n"
cp -f monitoring/${PROMETHEUS_CONFIG_FILE} prometheus/prometheus.yml