forked from scylladb/scylla-monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kill-all.sh
executable file
·53 lines (48 loc) · 1.23 KB
/
kill-all.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
#!/usr/bin/env bash
usage="$(basename "$0") [-h] [-g grafana port ] [ -p prometheus port ] [-m alertmanager port] -- kills existing Grafana and Prometheus Docker instances at given ports"
GRAFANA_PORT=""
PROMETHEUS_PORT=""
ALERTMANAGER_PORT=""
PROMETHEUS_NAME="aprom"
while getopts ':hg:p:m:' option; do
case "$option" in
h) echo "$usage"
exit
;;
g) GRAFANA_PORT="-p $OPTARG"
;;
p) PROMETHEUS_PORT="-p $OPTARG"
PROMETHEUS_NAME="aprom-$OPTARG"
;;
m) ALERTMANAGER_PORT="-p $OPTARG"
;;
:) printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
docker exec $PROMETHEUS_NAME kill 1
TRIES=0
OK=0
until [ $OK -eq 1 ] || [ $TRIES -eq 120 ]; do
if VAL=`docker logs aprom|&tail -1 |grep 'See you next time'`; then
if [ -z "$VAL" ]; then
printf '.'
((TRIES=TRIES+1))
sleep 1
else
OK=1
fi
else
OK=1
fi
done
sleep 2
./kill-container.sh $PROMETHEUS_PORT -b aprom
./kill-container.sh $GRAFANA_PORT -b agraf
./kill-container.sh $ALERTMANAGER_PORT -b aalert