Nuevo script para Prometheus
parent
b6f939cc9f
commit
cc1475e152
|
|
@ -0,0 +1,86 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# === VARIABLES ===
|
||||||
|
NODE_EXPORTER_VERSION="1.8.1"
|
||||||
|
EXPORTERS_DIR="/opt/proxmox-exporters"
|
||||||
|
PROXMOX_API_USER="root@pam" # CAMBIA ESTO si usas otro usuario
|
||||||
|
PROXMOX_API_PASSWORD="Goleador28092310" # CAMBIA ESTO
|
||||||
|
PROXMOX_API_HOST="https://localhost:8006"
|
||||||
|
|
||||||
|
# === Node Exporter ===
|
||||||
|
echo "[*] Instalando node_exporter..."
|
||||||
|
|
||||||
|
mkdir -p $EXPORTERS_DIR
|
||||||
|
cd $EXPORTERS_DIR
|
||||||
|
|
||||||
|
wget -q https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
|
||||||
|
tar -xzf node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
|
||||||
|
cp -f node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64/node_exporter /usr/local/bin/
|
||||||
|
|
||||||
|
cat <<EOF >/etc/systemd/system/node_exporter.service
|
||||||
|
[Unit]
|
||||||
|
Description=Prometheus Node Exporter
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=nobody
|
||||||
|
ExecStart=/usr/local/bin/node_exporter
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl daemon-reexec
|
||||||
|
systemctl enable --now node_exporter
|
||||||
|
echo "[✔] node_exporter instalado en el puerto 9100"
|
||||||
|
|
||||||
|
# === Proxmox Exporter ===
|
||||||
|
echo "[*] Instalando prometheus-pve-exporter..."
|
||||||
|
|
||||||
|
apt update -qq && apt install -y python3-venv git
|
||||||
|
|
||||||
|
cd $EXPORTERS_DIR
|
||||||
|
git clone https://github.com/prometheus-pve/prometheus-pve-exporter.git
|
||||||
|
cd prometheus-pve-exporter
|
||||||
|
python3 -m venv venv
|
||||||
|
source venv/bin/activate
|
||||||
|
pip install .
|
||||||
|
|
||||||
|
cat <<EOF >config.yaml
|
||||||
|
proxmox:
|
||||||
|
url: "$PROXMOX_API_HOST"
|
||||||
|
user: "$PROXMOX_API_USER"
|
||||||
|
password: "$PROXMOX_API_PASSWORD"
|
||||||
|
verify_ssl: false
|
||||||
|
|
||||||
|
listen:
|
||||||
|
address: "0.0.0.0"
|
||||||
|
port: 9221
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF >/etc/systemd/system/prometheus-pve-exporter.service
|
||||||
|
[Unit]
|
||||||
|
Description=Proxmox VE Exporter
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=$EXPORTERS_DIR/prometheus-pve-exporter
|
||||||
|
ExecStart=$EXPORTERS_DIR/prometheus-pve-exporter/venv/bin/prometheus-pve-exporter -c config.yaml
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl daemon-reexec
|
||||||
|
systemctl enable --now prometheus-pve-exporter
|
||||||
|
echo "[✔] prometheus-pve-exporter instalado en el puerto 9221"
|
||||||
|
|
||||||
|
# === Fin ===
|
||||||
|
echo ""
|
||||||
|
echo "✅ Exporters desplegados:"
|
||||||
|
echo " - http://$(hostname -I | awk '{print $1}'):9100/metrics"
|
||||||
|
echo " - http://$(hostname -I | awk '{print $1}'):9221/metrics"
|
||||||
Loading…
Reference in New Issue