From 04b667e7c4b13b894ad1d2b8231b31345349da92 Mon Sep 17 00:00:00 2001 From: CN-JS-HuiBai Date: Sat, 28 Feb 2026 15:12:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eblackbox=5Fexporter=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC=20=E4=B8=BAcAdvisor=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=9E=B6=E6=9E=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Prometheus/install_blackbox_exporter.sh | 42 +++++++++++++++++++++++++ Prometheus/install_cAdvisor.sh | 18 +++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 Prometheus/install_blackbox_exporter.sh diff --git a/Prometheus/install_blackbox_exporter.sh b/Prometheus/install_blackbox_exporter.sh new file mode 100644 index 0000000..1e2fccf --- /dev/null +++ b/Prometheus/install_blackbox_exporter.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -e +#Detect Operation System + +if command -v apt >/dev/null 2>&1; then + echo "Detected apt-based system" + sudo apt update + sudo apt install -y wget curl tar + +elif command -v dnf >/dev/null 2>&1; then + echo "Detected dnf-based system" + sudo dnf install -y wget curl tar + +else + echo "Unsupported package manager" + exit 1 +fi + +# Download Node Exporter +CN_URL="https://s3.cloudyun.top/downloads/cadvisor-v0.55.1-linux-amd64" +GLOBAL_URL="https://github.com/prometheus/blackbox_exporter/releases/download/v0.28.0/blackbox_exporter-0.28.0.linux-amd64.tar.gz" +TARGET=/tmp/cAdvisor +is_cn=false + +echo "Detecting geographic location..." +COUNTRY=$(curl -s --max-time 3 https://ipinfo.littlediary.cn/country || true) +if [ "$COUNTRY" = "CN" ]; then + is_cn=true +fi + + +if [ "$is_cn" = true ]; then + echo "Geolocation: China mainland detected" + DOWNLOAD_URL="$CN_URL" +else + echo "Geolocation: non-China region detected" + DOWNLOAD_URL="$GLOBAL_URL" +fi + +echo "Downloading from: $DOWNLOAD_URL" +curl -fL -o "$TARGET" "$DOWNLOAD_URL" + diff --git a/Prometheus/install_cAdvisor.sh b/Prometheus/install_cAdvisor.sh index b073888..3cb3a87 100644 --- a/Prometheus/install_cAdvisor.sh +++ b/Prometheus/install_cAdvisor.sh @@ -16,10 +16,22 @@ else echo "Unsupported package manager" exit 1 fi +# 架构判断 +ARCH=$(uname -m) +if [ "$ARCH" = "x86_64" ]; then + echo "Detected x86_64 architecture" + ARCH="amd64" +elif [ "$ARCH" = "aarch64" ]; then + echo "Detected aarch64 architecture" + ARCH="arm64" +else + echo "Unsupported architecture: $ARCH" + exit 1 +fi -# Download Node Exporter -CN_URL="https://s3.cloudyun.top/downloads/cadvisor-v0.55.1-linux-amd64" -GLOBAL_URL="https://github.com/google/cadvisor/releases/download/v0.55.1/cadvisor-v0.55.1-linux-amd64" +# Download Node Exporter +CN_URL="https://s3.cloudyun.top/downloads/cadvisor-v0.55.1-linux-$ARCH" +GLOBAL_URL="https://github.com/google/cadvisor/releases/download/v0.55.1/cadvisor-v0.55.1-linux-$ARCH" TARGET=/tmp/cAdvisor is_cn=false