From 0a2b0c13ad0c4ecc3948766d282d4df63202db69 Mon Sep 17 00:00:00 2001 From: Vimal Kumar Date: Tue, 21 Nov 2023 15:10:22 +0530 Subject: [PATCH] minor fixes to grafana scripts Updated scripts to - use network instead of link - use podman or docker Signed-off-by: Vimal Kumar --- scripts/grafana/start-prometheus.sh | 8 ++++++-- scripts/grafana/start.sh | 9 ++++++--- scripts/grafana/stop.sh | 5 +++-- 3 files changed, 15 insertions(+), 7 deletions(-) mode change 100644 => 100755 scripts/grafana/start-prometheus.sh mode change 100644 => 100755 scripts/grafana/start.sh mode change 100644 => 100755 scripts/grafana/stop.sh diff --git a/scripts/grafana/start-prometheus.sh b/scripts/grafana/start-prometheus.sh old mode 100644 new mode 100755 index f65cf087..52359be3 --- a/scripts/grafana/start-prometheus.sh +++ b/scripts/grafana/start-prometheus.sh @@ -9,6 +9,8 @@ then exit 1 fi +CTR_RUN=${CTR_RUN:-docker} + mkdir -p grafana_volume/dashboards mkdir -p prometheus_volume @@ -36,10 +38,12 @@ else curl -o grafana_volume/dashboards/pcm-dashboard.json $1/dashboard/prometheus fi +echo "Starting prometheus network" +${CTR_RUN} network create prometheus-network echo Starting prometheus -docker run --name prometheus -d -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml -v $PWD/prometheus_volume:/prometheus prom/prometheus +${CTR_RUN} run --name prometheus --network prometheus-network -d -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml:Z -v $PWD/prometheus_volume:/prometheus:Z quay.io/prometheus/prometheus:latest echo Starting grafana -docker run -d --link=prometheus --name=grafana -p 3000:3000 -v $PWD/grafana_volume:/var/lib/grafana -v $PWD/provisioning:/etc/grafana/provisioning grafana/grafana +${CTR_RUN} run -d --network=prometheus-network --name=grafana -p 3000:3000 -v $PWD/grafana_volume:/var/lib/grafana:Z -v $PWD/provisioning:/etc/grafana/provisioning:Z docker.io/grafana/grafana:latest echo Start browser at http://localhost:3000/ and login with admin user, password admin diff --git a/scripts/grafana/start.sh b/scripts/grafana/start.sh old mode 100644 new mode 100755 index 24e5c77f..3dd2c8f5 --- a/scripts/grafana/start.sh +++ b/scripts/grafana/start.sh @@ -9,6 +9,7 @@ then exit 1 fi +CTR_RUN=${CTR_RUN:-docker} # check if argument is file, create the telegraf.conf accordingly if [ -f "$1" ]; then @@ -45,12 +46,14 @@ cp automatic_influxdb.yml provisioning/datasources/automatic.yml echo Downloading PCM dashboard curl -o grafana_volume/dashboards/pcm-dashboard.json $1/dashboard +echo "Creating influxdb network" +${CTR_RUN} network create influxdb-network echo Starting influxdb -docker run -d --name influxdb -p 8083:8083 -p 8086:8086 -v $PWD/influxdb_volume:/var/lib/influxdb influxdb:1.8.0-alpine +${CTR_RUN} run -d --name influxdb -p 8083:8083 -p 8086:8086 -v $PWD/influxdb_volume:/var/lib/influxdb influxdb:1.8.0-alpine --network influxdb-network echo Starting telegraf -docker run -d --name telegraf --link=influxdb -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro telegraf +${CTR_RUN} run -d --name telegraf --network=influxdb -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro telegraf echo Starting grafana -docker run -d --link=influxdb --name grafana -p 3000:3000 -v $PWD/provisioning:/etc/grafana/provisioning -v $PWD/grafana_volume:/var/lib/grafana grafana/grafana +${CTR_RUN} run -d --network=influxdb --name grafana -p 3000:3000 -v $PWD/provisioning:/etc/grafana/provisioning -v $PWD/grafana_volume:/var/lib/grafana grafana/grafana echo Start browser at http://localhost:3000/ and login with admin user, password admin diff --git a/scripts/grafana/stop.sh b/scripts/grafana/stop.sh old mode 100644 new mode 100755 index ba87a2de..35e84a5d --- a/scripts/grafana/stop.sh +++ b/scripts/grafana/stop.sh @@ -1,11 +1,12 @@ +CTR_RUN=${CTR_RUN:-docker} for c in grafana telegraf influxdb prometheus; do - id=`docker ps -a -q --filter="name=$c" --format="{{.ID}}"` + id=`${CTR_RUN} ps -a -q --filter="name=$c" --format="{{.ID}}"` if [ ! -z "$id" ] then echo Stopping and deleting $c - docker rm $(docker stop $id) + ${CTR_RUN} rm $(${CTR_RUN} stop $id) fi done