mgmt/configuration/deploy-telegraf-remote.sh

40 lines
1.4 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
# 使用远程 InfluxDB 2.x 配置快速部署 Telegraf 监控
echo "🚀 使用 InfluxDB 2.x 远程配置部署 Telegraf 监控..."
# 设置变量
INFLUX_TOKEN="VU_dOCVZzqEHb9jSFsDe0bJlEBaVbiG4LqfoczlnmcbfrbmklSt904HJPL4idYGvVi0c2eHkYDi2zCTni7Ay4w=="
TELEGRAF_CONFIG_URL="http://influxdb1.tailnet-68f9.ts.net:8086/api/v2/telegrafs/0f8a73496790c000"
# 检查网络连接
echo "🔍 检查 InfluxDB 连接..."
if curl -s --max-time 5 "http://influxdb1.tailnet-68f9.ts.net:8086/health" > /dev/null; then
echo "✅ InfluxDB 连接正常"
else
echo "❌ 无法连接到 InfluxDB请检查网络"
exit 1
fi
# 使用远程配置部署
echo "📦 开始部署到所有节点..."
ansible-playbook -i inventories/production/nomad-cluster.ini playbooks/setup-disk-monitoring.yml \
-e "use_remote_config=true" \
-e "telegraf_config_url=$TELEGRAF_CONFIG_URL" \
-e "influxdb_token=$INFLUX_TOKEN"
# 检查部署结果
if [[ $? -eq 0 ]]; then
echo "✅ Telegraf 监控部署完成!"
echo ""
echo "📊 配置信息:"
echo "- 使用远程配置: $TELEGRAF_CONFIG_URL"
echo "- InfluxDB 服务器: influxdb1.tailnet-68f9.ts.net:8086"
echo "- 已禁用本地日志文件"
echo ""
echo "🔧 验证部署:"
echo "ansible all -i inventories/production/nomad-cluster.ini -m shell -a 'systemctl status telegraf --no-pager'"
else
echo "❌ 部署失败,请检查错误信息"
exit 1
fi