Files
Distributed-Prometheus/edge-agent/config/update-configs.sh
Super User 95a09fd9d8 完善中央与边缘部署、远程写入与监控文档
- 增加中央与边缘完整配置和部署脚本
- 引入 VictoriaMetrics 数据源与 remote_write 故障排查说明
- 新增 edge-agent 配置脚本、ONVIF 自建 exporter 与 ping 监控示例

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-25 04:24:40 -05:00

69 lines
2.1 KiB
Bash
Executable File
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
# 更新配置文件脚本 - 从CSV生成所有JSON配置文件
# 使用方法: ./update-configs.sh
set -e
echo "=== 更新Prometheus监控配置文件 ==="
echo ""
# 检查jq是否安装
if ! command -v jq &> /dev/null; then
echo "❌ jq未安装请先安装jq:"
echo " Ubuntu/Debian: sudo apt-get install jq"
echo " CentOS/RHEL: sudo yum install jq"
echo " Alpine: apk add jq"
exit 1
fi
# 进入脚本目录
cd "$(dirname "$0")"
echo "🔄 正在从CSV文件生成JSON配置..."
# 优先使用统一的 targets.csv
if [ -f "targets.csv" ]; then
echo "📋 使用统一配置文件 targets.csv..."
chmod +x csv-to-targets.sh 2>/dev/null || true
./csv-to-targets.sh targets.csv
else
echo "⚠️ targets.csv 不存在,使用旧格式配置文件..."
echo ""
# 兼容旧格式生成ONVIF设备配置
if [ -f "devices.csv" ]; then
echo "📱 生成ONVIF设备配置从 devices.csv..."
chmod +x csv-to-json.sh 2>/dev/null || true
./csv-to-json.sh devices.csv onvif-targets.json
else
echo "⚠️ devices.csv 不存在跳过ONVIF设备配置生成"
echo "[]" > onvif-targets.json
fi
# 兼容旧格式生成Ping目标配置
if [ -f "ping-targets.csv" ]; then
echo "🌐 生成Ping目标配置从 ping-targets.csv..."
chmod +x csv-to-ping-json.sh 2>/dev/null || true
./csv-to-ping-json.sh ping-targets.csv ping-targets.json
else
echo "⚠️ ping-targets.csv 不存在跳过Ping目标配置生成"
echo "[]" > ping-targets.json
fi
fi
echo ""
echo "✅ 所有配置文件已更新!"
echo ""
echo "📋 生成的文件:"
ls -la *.json 2>/dev/null || echo " (无JSON文件生成)"
echo ""
echo "🔄 配置热重载:"
echo " - Prometheus会在5分钟内自动检测并重载配置"
echo " - 无需重启Docker容器"
echo ""
echo "⚡ 强制立即重载 (可选)"
echo " docker-compose restart prometheus-edge"
echo ""
echo "📝 编辑CSV文件后重新运行此脚本即可更新配置"