PassioniInformaticaLinux

Guida: Monitoraggio server con Prometheus + Grafana

23/02/2026

Stack di monitoraggio per infrastruttura Linux

Installazione e configurazione di Prometheus + Node Exporter + Grafana per monitorare CPU, RAM, disco e rete.

1. Installazione Node Exporter (su ogni server da monitorare)

wget https://github.com/prometheus/node_exporter/releases/latest/download/node_exporter-*linux-amd64.tar.gz
tar xzf node_exporter-*.tar.gz
cp node_exporter-*/node_exporter /usr/local/bin/

Crea il servizio systemd:

cat > /etc/systemd/system/node_exporter.service <<EOF
[Unit]
Description=Node Exporter
After=network.target

[Service]
User=nobody
ExecStart=/usr/local/bin/node_exporter
Restart=always

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now node_exporter

Verifica: curl http://localhost:9100/metrics

2. Installazione Prometheus (sul server di monitoraggio)

useradd --no-create-home --shell /bin/false prometheus
mkdir -p /etc/prometheus /var/lib/prometheus
wget https://github.com/prometheus/prometheus/releases/latest/download/prometheus-*linux-amd64.tar.gz
tar xzf prometheus-*.tar.gz
cp prometheus-*/prometheus /usr/local/bin/

3. Configurazione Prometheus

cat > /etc/prometheus/prometheus.yml <<EOF
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "servers"
    static_configs:
      - targets:
        - "192.168.1.81:9100"
        - "192.168.1.90:9100"
        - "192.168.1.92:9100"
        - "192.168.1.108:9100"
        labels:
          env: "homelab"
EOF

4. Installazione Grafana

apt install -y apt-transport-https software-properties-common
wget -qO- https://apt.grafana.com/gpg.key | gpg --dearmor > /etc/apt/keyrings/grafana.gpg
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" > /etc/apt/sources.list.d/grafana.list
apt update && apt install -y grafana
systemctl enable --now grafana-server

Accedi a http://IP:3000 (admin/admin).

5. Collegare Grafana a Prometheus

In Grafana: Configuration > Data Sources > Add Prometheus con URL http://localhost:9090.

Importa la dashboard Node Exporter Full (ID: 1860) per avere subito metriche complete.

Risultato: Monitoraggio completo dell'infrastruttura con metriche real-time e dashboard grafiche.

← Guida: Backup automatici con rsync + cron Guida: WireGuard VPN — collegare server remoti ... →
← Torna all'elenco