Watchflare docs
Sur cette page

Installer l'Agent Watchflare sous Linux

Installez l'agent Watchflare sur un hôte Linux avec systemd. Installeur en une commande pour Ubuntu, Debian, RHEL, Fedora, Amazon Linux et Arch Linux.

Prérequis : un hôte Linux avec systemd, curl ou wget, et un accès sudo. Testé sur Ubuntu 18.04+, Debian 10+, RHEL/CentOS 7+, Fedora 30+, Amazon Linux 2+, Arch Linux.

Avant de commencer, créez l’hôte dans le tableau de bord Watchflare (Hosts → Add host) et copiez le jeton d’enrôlement.


Installation en une commande (recommandée)

Cette commande installe l’agent, l’enrôle auprès du Hub et démarre le service systemd en une seule étape :

bash
curl -sSL https://get.watchflare.io | sudo bash -s -- \
  --token wf_reg_YOUR_TOKEN \
  --host YOUR_HUB_IP \
  --port 50051

Remplacez YOUR_HUB_IP par l’IP ou le nom d’hôte de votre Hub et wf_reg_YOUR_TOKEN par le jeton complet copié depuis le tableau de bord.

L’installeur :

  1. Vérifie les permissions (nécessite root)
  2. Crée l’utilisateur système watchflare
  3. Crée les dossiers de données et de config
  4. Copie le binaire vers /usr/local/bin/
  5. Installe le service systemd
  6. Enrôle l’agent auprès du Hub
  7. Active et démarre le service
bash
Downloading latest release from GitHub...
→ Downloaded and extracted
[1/5] Checking for existing installation...
→ Systemd detected
[2/5] Creating system user 'watchflare'...
→ Created group 'watchflare'
→ Created user 'watchflare'
[3/5] Creating directories...
→ Created /etc/watchflare, /var/lib/watchflare
[4/5] Installing binary...
→ Installed to /usr/local/bin/watchflare-agent
[5/5] Installing service and registering...
=== Watchflare Agent Installation ===

[1/7] Checking permissions...
→ Running as root

[2/7] Creating system user...
→ User 'watchflare' already exists

[3/7] Creating directories...
→ Created /etc/watchflare
→ Created /var/lib/watchflare
→ Created /var/lib/watchflare/wal

[4/7] Installing binary...
→ Already installed at /usr/local/bin/watchflare-agent
→ Created log file /var/log/watchflare-agent.log

[5/7] Installing service...
→ Installed to /etc/systemd/system/watchflare-agent.service
→ Installed to /etc/systemd/system/watchflare-agent-update.service
→ Installed to /etc/systemd/system/watchflare-agent-update.path
→ Systemd daemon reloaded
→ Enabled watchflare-agent-update.path

[6/7] Agent registration...
→ Registering agent with the Hub...
→ Registration successful

[7/7] Starting service...
→ Service enabled (will start on boot)
→ Service started
→ Checking agent health... ✓

=== Installation Complete ===

Installation successful!

L’hôte passe de pending à online dans le tableau de bord dans les 5 secondes.

Attention

Les jetons d’enrôlement expirent au bout de 24 heures. Lancez la commande d’installation avant que le jeton n’expire.

Astuce

Vous faites tourner Docker ou Podman sur cet hôte ? Ajoutez --containers pour collecter les métriques CPU, mémoire et réseau par conteneur. Voir Métriques de conteneurs Docker/Podman.


Installation en deux étapes

Si vous voulez installer le binaire d’abord et l’enrôler plus tard :

Étape 1 : Installer sans enrôler

bash
curl -sSL https://get.watchflare.io | sudo bash

Étape 2 : Enrôler quand vous êtes prêt

bash
sudo watchflare-agent register \
  --token wf_reg_YOUR_TOKEN \
  --host YOUR_HUB_IP \
  --port 50051

Étape 3 : Activer et démarrer le service

bash
sudo systemctl enable --now watchflare-agent

Gestion du service

bash
sudo systemctl status watchflare-agent     # état
sudo systemctl start watchflare-agent      # démarrer
sudo systemctl stop watchflare-agent       # arrêter
sudo systemctl restart watchflare-agent    # redémarrer
sudo systemctl enable watchflare-agent     # activer au démarrage
sudo systemctl disable watchflare-agent    # désactiver au démarrage
journalctl -u watchflare-agent -f          # suivre les journaux

Emplacement des fichiers

CheminRôlePropriétaireMode
/usr/local/bin/watchflare-agentBinaireroot:root755
/etc/watchflare/agent.confConfig (identifiants)root:watchflare640
/etc/watchflare/ca.pemCertificat CA du Hubroot:watchflare640
/var/lib/watchflare/Dossier de donnéeswatchflare:watchflare750
/var/lib/watchflare/metrics.walWrite-Ahead Logwatchflare:watchflare640
/var/lib/watchflare/packages.state.jsonÉtat de l’inventaire des paquetswatchflare:watchflare640
/etc/systemd/system/watchflare-agent.serviceDéfinition du serviceroot:root644
/var/log/watchflare-agent.logJournauxwatchflare:watchflare644

Réenrôler

Pour connecter l’agent à un autre Hub, ou après avoir supprimé puis recréé un hôte :

bash
sudo systemctl stop watchflare-agent
sudo rm /etc/watchflare/agent.conf /etc/watchflare/ca.pem
sudo watchflare-agent register --token wf_reg_YOUR_TOKEN --host YOUR_HUB_IP
sudo systemctl start watchflare-agent

SELinux

Sur RHEL, CentOS et Fedora, restaurez les contextes SELinux après l’installation :

bash
sudo restorecon -Rv /usr/local/bin/watchflare-agent
sudo restorecon -Rv /etc/watchflare
sudo restorecon -Rv /var/lib/watchflare

Dépannage

SymptômeCauseCorrectif
configuration error (fichier de config introuvable)Pas enrôléExécutez sudo watchflare-agent register ...
permission deniedMauvais propriétaire des fichiersVérifiez ls -la /etc/watchflare/
connection refusedMauvais hôte/port ou pare-feuVérifiez que le port 50051 est joignable depuis cet hôte
Invalid agent credentialsClé qui ne correspond pasRéenrôlez l’agent
L’hôte reste offline après le démarrageHorloge désynchroniséeAssurez-vous que NTP tourne, car le Hub refuse les horodatages décalés de ±5 min

Consultez les journaux pour plus de détails :

bash
journalctl -u watchflare-agent -n 50
# ou
tail -50 /var/log/watchflare-agent.log

Un agent en bon état produit des lignes de ce type au démarrage :

2026/01/02 15:04:05 INFO   Watchflare Agent starting  version=v0.40.1
2026/01/02 15:04:05 INFO   environment detected  type="Physical Host"
2026/01/02 15:04:05 INFO   heartbeat started  interval_sec=5
2026/01/02 15:04:05 INFO   package collector started
2026/01/02 15:04:05 INFO   waiting before initial package collection  delay_sec=60

Motifs d’erreur fréquents :

2026/01/02 15:04:05 WARN   heartbeat failed  error="Heartbeat failed: dial tcp 1.2.3.4:50051: connect: connection refused"
2026/01/02 15:04:05 WARN   heartbeat failed  error="Heartbeat failed: rpc error: code = Unauthenticated desc = Invalid agent credentials"
2026/01/02 15:04:05 ERROR  send failed: clock out of sync with Hub