From fe1416bef745c10a30e7995d0c54bf39f35186f2 Mon Sep 17 00:00:00 2001 From: platfowner Date: Fri, 13 Sep 2024 13:09:23 +0900 Subject: [PATCH 1/2] Rename config template files for monitoring --- monitoring/{grafana.json => grafana-template.json} | 0 monitoring/{prometheus.yml => prometheus-template.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename monitoring/{grafana.json => grafana-template.json} (100%) rename monitoring/{prometheus.yml => prometheus-template.yml} (100%) diff --git a/monitoring/grafana.json b/monitoring/grafana-template.json similarity index 100% rename from monitoring/grafana.json rename to monitoring/grafana-template.json diff --git a/monitoring/prometheus.yml b/monitoring/prometheus-template.yml similarity index 100% rename from monitoring/prometheus.yml rename to monitoring/prometheus-template.yml From eb136008660e8f7b506eecacc77608fb5ef070b4 Mon Sep 17 00:00:00 2001 From: platfowner Date: Fri, 13 Sep 2024 13:53:12 +0900 Subject: [PATCH 2/2] Extend monitoring deploy scripts to onprem hosting --- deploy_monitoring_gcp.sh | 31 +++++++++++++++++++++++-------- setup_monitoring_gcp.sh | 21 ++++++++++++++++----- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/deploy_monitoring_gcp.sh b/deploy_monitoring_gcp.sh index c86e3f60a..cba614a06 100644 --- a/deploy_monitoring_gcp.sh +++ b/deploy_monitoring_gcp.sh @@ -1,12 +1,19 @@ #!/bin/bash -if [[ "$#" -lt 1 ]]; then - printf "Usage: bash deploy_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [--setup]\n" - printf "Example: bash deploy_monitoring_gcp.sh dev --setup\n" - printf "Example: bash deploy_monitoring_gcp.sh dev\n" +function usage() { + printf "Usage: bash deploy_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [gcp|onprem} [--setup]\n" + printf "Example: bash deploy_monitoring_gcp.sh staging gcp \n" + printf "Example: bash deploy_monitoring_gcp.sh staging gcp --setup\n" + printf "Example: bash deploy_monitoring_gcp.sh staging onprem \n" + printf "Example: bash deploy_monitoring_gcp.sh staging onprem --setup\n" printf "\n" exit +} + +if [[ $# -lt 2 ]] || [[ $# -gt 3 ]]; then + usage fi + printf "\n[[[[[ deploy_monitoring_gcp.sh ]]]]]\n\n" if [[ "$1" = 'dev' ]] || [[ "$1" = 'staging' ]] || [[ "$1" = 'sandbox' ]] || [[ "$1" = 'exp' ]] || [[ "$1" = 'spring' ]] || [[ "$1" = 'summer' ]] || [[ "$1" = 'mainnet' ]]; then @@ -25,12 +32,20 @@ fi printf "SEASON=$SEASON\n" printf "PROJECT_ID=$PROJECT_ID\n" -GCP_USER="runner" -printf "GCP_USER=$GCP_USER\n" +if [[ "$2" = 'gcp' ]] || [[ "$2" = 'onprem' ]]; then + BLOCKCHAIN_HOSTING="$2" +else + printf "Invalid blockchain hosting argument: $2\n" + exit +fi +printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n" -OPTIONS="$2" +OPTIONS="$3" printf "OPTIONS=$OPTIONS\n" +GCP_USER="runner" +printf "GCP_USER=$GCP_USER\n" + # Get confirmation. printf "\n" read -p "Do you want to proceed for $SEASON? [y/N]: " -n 1 -r @@ -62,4 +77,4 @@ fi # ssh into each instance, install packages and start up the server printf "\n\n############################\n# Running monitoring #\n############################\n\n" -gcloud compute ssh $MONITORING_TARGET_ADDR --command "cd ./ain-blockchain; . setup_monitoring_gcp.sh $SEASON $GCP_USER && . start_monitoring_gcp.sh" --project $PROJECT_ID --zone $MONITORING_ZONE +gcloud compute ssh $MONITORING_TARGET_ADDR --command "cd ./ain-blockchain; . setup_monitoring_gcp.sh $SEASON $GCP_USER $BLOCKCHAIN_HOSTING && . start_monitoring_gcp.sh" --project $PROJECT_ID --zone $MONITORING_ZONE diff --git a/setup_monitoring_gcp.sh b/setup_monitoring_gcp.sh index 039445369..3c281a322 100644 --- a/setup_monitoring_gcp.sh +++ b/setup_monitoring_gcp.sh @@ -1,23 +1,34 @@ #!/bin/bash -if [[ "$#" -lt 2 ]]; then - printf "Usage: bash setup_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] \n" - printf "Example: bash setup_monitoring_gcp.sh dev gcp_user\n" +function usage() { + printf "Usage: bash setup_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [gcp|onprem]\n" + printf "Example: bash setup_monitoring_gcp.sh staging gcp_user gcp\n" + printf "Example: bash setup_monitoring_gcp.sh staging gcp_user onprem\n" printf "\n" exit +} + +if [[ $# -lt 3 ]] || [[ $# -gt 3 ]]; then + usage 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 +if [[ "$3" != 'gcp' ]] && [[ "$3" != 'onprem' ]]; then + printf "Invalid blockchain hosting argument: $3\n" + exit +fi SEASON="$1" GCP_USER="$2" - +BLOCKCHAIN_HOSTING="$3" printf "SEASON=$SEASON\n" printf "GCP_USER=$GCP_USER\n" +printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n" printf "\n" printf 'Killing old jobs..\n' @@ -47,6 +58,6 @@ mv prometheus*/ prometheus printf 'Copying Prometheus yml file..\n' -PROMETHEUS_CONFIG_FILE="prometheus-${SEASON}.yml" +PROMETHEUS_CONFIG_FILE="prometheus-${SEASON}-${BLOCKCHAIN_HOSTING}.yml" printf "PROMETHEUS_CONFIG_FILE=${PROMETHEUS_CONFIG_FILE}\n" cp -f monitoring/${PROMETHEUS_CONFIG_FILE} prometheus/prometheus.yml