Files
Distributed-Prometheus/edge-agent/deploy.sh
User 650e5145f1 refactor: 边缘节点与配置精简
- 边缘: Prometheus 改为 vmagent,统一 docker-compose.yml,内存+磁盘缓存
- 边缘脚本: 合并为 deploy.sh [--local],删除 run-edge-local、quick-setup、run-edge-with-cache
- 配置: 合并为 update-configs.sh,统一 targets.csv,生成 target-onvif/target-ping/target-topology
- 删除 topology-editor、旧格式 devices.csv/ping-targets.csv、setup-remote-write、test-connection
- 文档: 更新 EDGE_CACHE、TIANDITU(瓦片改 4090 直连 tile-cache)

Made-with: Cursor
2026-02-28 19:44:46 -05:00

45 lines
1.8 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 边缘节点部署vmagent + 内存/磁盘缓存
# 用法: ./deploy.sh [--local] --local = 本机同机(中央与边缘同机)
set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
# --local: 中央与边缘同机,使用 host.docker.internal
if [ "$1" = "--local" ]; then
[ ! -f .env ] && [ -f env.example ] && cp env.example .env
sed -i 's/^CENTRAL_SERVER_HOST=.*/CENTRAL_SERVER_HOST=host.docker.internal/' .env 2>/dev/null || \
echo 'CENTRAL_SERVER_HOST=host.docker.internal' >> .env
grep -q '^CENTRAL_SERVER_PORT=' .env || echo 'CENTRAL_SERVER_PORT=8428' >> .env
fi
# Docker 环境
DOCKER_CMD="docker compose"
docker compose version &>/dev/null || DOCKER_CMD="docker-compose"
command -v docker &>/dev/null || { echo "❌ 需要 Docker"; exit 1; }
$DOCKER_CMD version &>/dev/null || { echo "❌ 需要 Docker Compose"; exit 1; }
command -v jq &>/dev/null || { echo "❌ 需要 jq"; exit 1; }
# 配置文件
[ -f config/targets.csv ] && (cd config && ./update-configs.sh) || true
[ ! -f config/target-onvif.json ] && echo '[]' > config/target-onvif.json
[ ! -f config/target-ping.json ] && echo '[]' > config/target-ping.json
[ ! -f prometheus-edge/vmagent-scrape.yml.template ] && { echo "❌ 缺少 vmagent-scrape.yml.template"; exit 1; }
# .env
[ ! -f .env ] && cp env.example .env
# targets.csv无则建最小示例
[ ! -f config/targets.csv ] && \
printf '%s\n' "type,ip,name,role,parent,uplink_type,network,device_type,model,location,username,password,onvif_port,lat,lon" \
"ping,8.8.8.8,google_dns,dns,,,external,,,,,,,,," \
"ping,1.1.1.1,cloudflare_dns,dns,,,external,,,,,,,,," > config/targets.csv
# 启动
$DOCKER_CMD down 2>/dev/null || true
$DOCKER_CMD up -d
sleep 5
$DOCKER_CMD ps
echo ""
echo "✅ 边缘已启动 http://localhost:9092 (Grafana 数据源选 VictoriaMetrics)"