dev_1.0.0_sundp 完成Metric模块及模块e2e测试 #18

Merged
sundapeng merged 19 commits from dev_1.0.0_sundp into dev_1.0.0 2025-10-11 17:15:07 +08:00
2 changed files with 20 additions and 9 deletions
Showing only changes of commit d514283cda - Show all commits

View File

@ -13,10 +13,8 @@ RUN if [ "$USE_INTRANET" = "true" ]; then \
echo 'Acquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/99disable-ssl-check; \
else \
echo "Configuring fast apt sources for external network..." && \
# 查找并替换sources.list文件
find /etc/apt -name "sources.list*" -exec sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' {} \; && \
find /etc/apt -name "sources.list*" -exec sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' {} \; && \
# 使用阿里云源
echo "deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse" > /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list; \
@ -74,23 +72,25 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# 启动脚本
COPY start-prometheus-supervised.sh /usr/local/bin/start-prometheus-supervised.sh
RUN chmod +x /usr/local/bin/start-prometheus-supervised.sh
RUN chmod +x /usr/local/bin/start-prometheus-supervised.sh && \
chown nobody:nogroup /usr/local/bin/start-prometheus-supervised.sh
# targets 更新脚本
COPY start-targets-updater.sh /usr/local/bin/start-targets-updater.sh
RUN chmod +x /usr/local/bin/start-targets-updater.sh
RUN chmod +x /usr/local/bin/start-targets-updater.sh && \
chown nobody:nogroup /usr/local/bin/start-targets-updater.sh
# targets 更新 Python 脚本
COPY update_targets.py /usr/local/bin/update_targets.py
RUN chmod +x /usr/local/bin/update_targets.py
RUN chmod +x /usr/local/bin/update_targets.py && \
chown nobody:nogroup /usr/local/bin/update_targets.py
# exporter 配置文件
COPY exporter_config.json ${PROMETHEUS_BASE_PATH}/exporter_config.json
# exporter 配置文件 - 复制到内部目录
COPY exporter_config.json /usr/local/bin/exporter_config.json
# 自定义 prometheus 配置文件
COPY prometheus.yml /etc/prometheus/prometheus.yml
RUN chown nobody:nogroup ${PROMETHEUS_BASE_PATH}/exporter_config.json /etc/prometheus/prometheus.yml
RUN chown nobody:nogroup /usr/local/bin/exporter_config.json /etc/prometheus/prometheus.yml
USER root

View File

@ -18,8 +18,19 @@ echo "[INFO] Exporter config file: ${EXPORTER_CONFIG_FILE}"
echo "[INFO] Check interval: ${CHECK_INTERVAL}s"
echo "[INFO] Log level: ${LOG_LEVEL}"
# 确保目录存在
mkdir -p "${TARGETS_DIR}"
# 检查 EXPORTER_CONFIG_FILE 是否存在,没有则从内部复制
if [ ! -f "${EXPORTER_CONFIG_FILE}" ]; then
echo "[INFO] exporter_config.json not found at ${EXPORTER_CONFIG_FILE}, copying from internal location..."
cp /usr/local/bin/exporter_config.json "${EXPORTER_CONFIG_FILE}"
chown nobody:nogroup "${EXPORTER_CONFIG_FILE}"
echo "[INFO] Successfully copied exporter_config.json to ${EXPORTER_CONFIG_FILE}"
else
echo "[INFO] exporter_config.json already exists at ${EXPORTER_CONFIG_FILE}, skipping copy"
fi
exec python3 /usr/local/bin/update_targets.py \
--config "${NODES_CONFIG_FILE}" \
--targets-dir "${TARGETS_DIR}" \