添加aarch64架构安装脚本
This commit is contained in:
83
Prometheus/install_node_exporter_arm64.sh
Normal file
83
Prometheus/install_node_exporter_arm64.sh
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
#!/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/node_exporter-1.10.2.linux-arm64.tar.gz"
|
||||||
|
GLOBAL_URL="https://github.com/prometheus/node_exporter/releases/download/v1.10.2/node_exporter-1.10.2.linux-arm64.tar.gz"
|
||||||
|
TARGET="/tmp/node_exporter.tar.gz"
|
||||||
|
|
||||||
|
is_cn=false
|
||||||
|
|
||||||
|
echo "Detecting geographic location..."
|
||||||
|
|
||||||
|
COUNTRY=$(curl -s --max-time 3 https://ipinfo.io/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"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Extract
|
||||||
|
echo "Extracting Node Exporter..."
|
||||||
|
tar -zxvf /tmp/node_exporter.tar.gz -C /tmp
|
||||||
|
|
||||||
|
# Copy to /node_exporter
|
||||||
|
echo "Copying Node Exporter to /node_exporter..."
|
||||||
|
sudo cp -r /tmp/node_exporter-1.10.2.linux-arm64 /node_exporter
|
||||||
|
|
||||||
|
# Create systemd service file
|
||||||
|
SERVICE_FILE="/etc/systemd/system/node_exporter.service"
|
||||||
|
|
||||||
|
echo "Creating systemd service file..."
|
||||||
|
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Node Exporter
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
ExecStart=/node_exporter/node_exporter --web.listen-address=":9100"
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Reload systemd, enable and start service
|
||||||
|
echo "Enabling and starting node_exporter service..."
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable --now node_exporter.service
|
||||||
|
|
||||||
|
echo "Node Exporter installation completed, listening on port 9100"
|
||||||
Reference in New Issue
Block a user