2 Star 0 Fork 0

mirrors_pingcap/tidb-insight

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
docker.sh 2.80 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/sh
SUDO=""
PWD=`pwd`
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root, it will try 'sudo' when needed."
SUDO="sudo"
fi
case $1 in
start)
echo "Starting containers..."
cd $PWD/tools/docker
if [ ! -f prometheus.yml ]; then
# use the template as default config, to start Prometheus process
cp configs/prometheus.yml.template prometheus.yml
fi
$SUDO docker-compose up -d
# if datasource "test-cluster" doesn't exist, this is a new Grafana instahce,
# and we'll going to initial its configs
echo "Wait 30s for Grafana to finish startup..."
sleep 30 # wail Grafana to startup
DATASOURCE=$(curl -s -H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
'http://localhost:3000/api/datasources/id/test-cluster')
if [[ $DATASOURCE = *"Data source not found"* ]]; then
echo "Initializing Grafana configuration..."
# add datasource
curl -s -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Basic YWRtaW46YWRtaW4=" -XPOST \
-d '{
"name": "test-cluster",
"type": "prometheus",
"access": "proxy",
"url": "http://prometheus:9090",
"basicAuth": false,
"withCredentials": false,
"isDefault": true,
"jsonData": {
"httpMethod": "GET",
"keepCookies": [
]
},
"readOnly": true
}' \
"http://localhost:3000/api/datasources"
# import dashboards
cd configs
./grafana-config-copy.py
else
echo "Using existing Grafana datasource $DATASOURCE"
fi
cd $PWD
;;
reload)
echo "Reloading Prometheus..."
$SUDO docker exec prometheus kill -HUP 1
;;
stop)
echo "Stopping containers..."
cd $PWD/tools/docker
$SUDO docker-compose down
cd $PWD
;;
clean)
echo "Stopping containers..."
cd $PWD/tools/docker
$SUDO docker-compose down
echo "Deleting all containers and data..."
$SUDO rm -rf data
;;
*)
echo "Setting InfluxDB database name to $1..."
sed "s/<DBNAME>/$1/g" $PWD/tools/docker/configs/prometheus.yml.template \
> $PWD/tools/docker/prometheus.yml
$SUDO docker exec prometheus kill -HUP 1
;;
esac
exit 0;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_pingcap/tidb-insight.git
[email protected]:mirrors_pingcap/tidb-insight.git
mirrors_pingcap
tidb-insight
tidb-insight
tiup

搜索帮助