Minor script refactoring/refinement

This commit is contained in:
Michael Vines 2019-06-13 08:28:31 -07:00
parent fc34687687
commit efe676bc94
4 changed files with 19 additions and 16 deletions

6
metrics/scripts/enable.sh Executable file → Normal file
View File

@ -1,10 +1,8 @@
#!/usr/bin/env bash
SOLANA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. || exit 1; pwd)"
# |source| this file to enable metrics in the current shell
export SOLANA_METRICS_CONFIG="host=http://localhost:8086,db=testnet,u=write,p=write"
# shellcheck source=scripts/configure-metrics.sh
source "$SOLANA_ROOT"/scripts/configure-metrics.sh
source "$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. || exit 1; pwd)"/scripts/configure-metrics.sh
echo Local metrics enabled

View File

@ -1,13 +1,16 @@
#!/bin/bash -ex
#!/usr/bin/env bash
#
# (Re)starts the local metrics
#
set -e
cd "$(dirname "$0")"
# Stop if already running
./stop.sh
set -x
: "${INFLUXDB_IMAGE:=influxdb:1.6}"
: "${GRAFANA_IMAGE:=solanalabs/grafana:stable}"
: "${GRAFANA_IMAGE:=grafana/grafana:5.2.3}"
@ -48,5 +51,3 @@ docker run \
sleep 5
./status.sh
exit 0

View File

@ -1,8 +1,9 @@
#!/bin/bash -e
#!/usr/bin/env bash
#
# Checks the status of lcoal metrics
# Checks the status of local metrics
#
set -e
cd "$(dirname "$0")"
(
@ -20,8 +21,12 @@ if ! timeout 10s curl -v --head http://localhost:3000; then
exit 1
fi
echo Local metrics up and running
echo - Enable local metric collection per shell by running \'source ./enable.sh\'
echo - View dashboard at http://localhost:3000/d/local/local-monitor
exit 0
cat <<EOF
=========================================================================
* Grafana dashboards are available at http://localhost:3000/dashboards
* Enable local metric collection per shell by running the command:
source $PWD/enable.sh
EOF

View File

@ -1,9 +1,9 @@
#!/bin/bash -e
#!/usr/bin/env bash
#
# Stops local metrics
#
cd "$(dirname "$0")"
set -e
for container in influxdb grafana; do
if [ "$(docker ps -q -a -f name=$container)" ]; then
@ -16,4 +16,3 @@ for container in influxdb grafana; do
done
echo Local metrics stopped
exit 0