Files
caliverse_doc/04. 서버설정/Shell Script/FluentD 설정/fluentdConf.sh
2025-05-01 07:27:54 +09:00

21 lines
689 B
Bash

#!/bin/bash
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -s -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
SERVER_NAME=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/local-ipv4)
# 서버 IP 대역 추출
IP_PREFIX=$(echo "$SERVER_NAME" | cut -d'.' -f1-2)
if [ "$IP_PREFIX" == "172.20" ]; then
FLUENTD_CONF="/etc/fluent/fluentdLive.conf"
elif [ "$IP_PREFIX" == "172.30" ]; then
FLUENTD_CONF="/etc/fluent/fluentdStage.conf"
elif [ "$IP_PREFIX" == "172.40" ]; then
FLUENTD_CONF="/etc/fluent/fluentdQA.conf"
else
echo "This is neither a live, stage, nor QA environment."
exit 1
fi
echo $FLUENTD_CONF