新增blackbox_exporter安装脚本
为cAdvisor添加架构判断
This commit is contained in:
42
Prometheus/install_blackbox_exporter.sh
Normal file
42
Prometheus/install_blackbox_exporter.sh
Normal file
@@ -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"
|
||||||
|
|
||||||
@@ -16,10 +16,22 @@ else
|
|||||||
echo "Unsupported package manager"
|
echo "Unsupported package manager"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# Download Node Exporter
|
||||||
CN_URL="https://s3.cloudyun.top/downloads/cadvisor-v0.55.1-linux-amd64"
|
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-amd64"
|
GLOBAL_URL="https://github.com/google/cadvisor/releases/download/v0.55.1/cadvisor-v0.55.1-linux-$ARCH"
|
||||||
TARGET=/tmp/cAdvisor
|
TARGET=/tmp/cAdvisor
|
||||||
is_cn=false
|
is_cn=false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user