F FabGPT-FAQ

Monitoraggio e notifiche

Prometheus, Grafana, Uptime Kuma, ntfy/Gotify e gli aggiornamenti sorvegliati. Ogni comando è verificato e copiabile; in chat basta descrivere cosa vuoi fare.

9 comandi in questa pagina

# Come aggiungo un target a Prometheus?

# prometheus.yml
scrape_configs:
  - job_name: nodo-nas
    static_configs:
      - targets: ['192.168.1.10:9100']

# poi reload: curl -X POST http://localhost:9090/-/reload   (se --web.enable-lifecycle)

La pagina Status -> Targets dice subito se lo scrape funziona e perché no.

Approfondisci: Come si monitora l'hardware del homelab (Prometheus, Grafana)?

# Come installo node_exporter come servizio?

useradd -rs /bin/false nodeexp
# scarica il binario in /usr/local/bin, poi unit systemd:
[Service]
User=nodeexp
ExecStart=/usr/local/bin/node_exporter

systemctl enable --now node_exporter
curl -s localhost:9100/metrics | head

Utente di sistema dedicato, niente root: espone metriche, non deve poter fare altro.

Approfondisci: Come si monitora l'hardware del homelab (Prometheus, Grafana)?

# Come collego Grafana a Prometheus e importo una dashboard?

# UI: Connections -> Data sources -> Prometheus -> http://prometheus:9090
# Dashboards -> Import -> ID 1860 (Node Exporter Full)

La 1860 è la dashboard host standard de facto: cinque minuti dal nulla ai grafici di tutto.

Approfondisci: Come si monitora l'hardware del homelab (Prometheus, Grafana)?

# Come monitoro le metriche dei container (cAdvisor)?

docker run -d --name cadvisor -p 8081:8080 \
  -v /:/rootfs:ro -v /var/run:/var/run:ro -v /sys:/sys:ro \
  -v /var/lib/docker/:/var/lib/docker:ro \
  gcr.io/cadvisor/cadvisor

Espone per-container CPU, RAM e I/O su /metrics: Prometheus lo scrape-a come un normale target.

Approfondisci: Come si monitora l'hardware del homelab (Prometheus, Grafana)?Cos'è Docker Compose?

# Come aggiungo un monitor su Uptime Kuma?

docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma
# poi UI: Add New Monitor -> HTTP(s) / Ping / TCP Port

Il retry prima dell'alert (2-3) evita i falsi allarmi da singolo pacchetto perso.

Approfondisci: Come si monitora un sito web usando solo GitHub Actions?Come si monitora l'hardware del homelab (Prometheus, Grafana)?

# Come collego Uptime Kuma a Telegram?

# 1. @BotFather -> /newbot -> copia il token
# 2. scrivi un messaggio al bot, poi:
curl -s https://api.telegram.org/bot<TOKEN>/getUpdates   # leggi la chat_id
# 3. Kuma UI: Settings -> Notifications -> Telegram: token + chat id

La stessa coppia token+chat_id riusa il bot per qualunque script tuo via sendMessage.

Approfondisci: Come si ricevono notifiche push self-hosted (ntfy, Gotify)?Come si monitora un sito web usando solo GitHub Actions?

# Come mando una notifica push con ntfy?

curl -d 'Backup completato' ntfy.sh/mio-topic-segreto
# self-hosted: curl -d 'msg' https://ntfy.example.com/topic

Il topic È l'autenticazione sul server pubblico: rendilo lungo e impronunciabile, o self-hosta con gli utenti.

Approfondisci: Come si ricevono notifiche push self-hosted (ntfy, Gotify)?

# Come mando una notifica con Gotify?

curl -X POST 'https://gotify.example.com/message?token=<APP_TOKEN>' \
  -F title='Backup' -F message='Completato' -F priority=5

Un token per applicazione: quello del backup che finisce in un log non compromette il resto.

Approfondisci: Come si ricevono notifiche push self-hosted (ntfy, Gotify)?

# Come vedo cosa aggiornerebbe Watchtower senza rischiare?

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once --monitor-only

--monitor-only notifica senza toccare nulla: il compromesso sano tra il tutto-automatico e il non saperlo mai.

Approfondisci: Come si aggiornano automaticamente i container (Watchtower e alternative)?Cos'è Docker Compose?

Chiedi in chat