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 :
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 :
- Vérifie les permissions (nécessite root)
- Crée l’utilisateur système
watchflare - Crée les dossiers de données et de config
- Copie le binaire vers
/usr/local/bin/ - Installe le service systemd
- Enrôle l’agent auprès du Hub
- Active et démarre le service
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
curl -sSL https://get.watchflare.io | sudo bash Étape 2 : Enrôler quand vous êtes prêt
sudo watchflare-agent register \
--token wf_reg_YOUR_TOKEN \
--host YOUR_HUB_IP \
--port 50051 Étape 3 : Activer et démarrer le service
sudo systemctl enable --now watchflare-agent Gestion du service
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
| Chemin | Rôle | Propriétaire | Mode |
|---|---|---|---|
/usr/local/bin/watchflare-agent | Binaire | root:root | 755 |
/etc/watchflare/agent.conf | Config (identifiants) | root:watchflare | 640 |
/etc/watchflare/ca.pem | Certificat CA du Hub | root:watchflare | 640 |
/var/lib/watchflare/ | Dossier de données | watchflare:watchflare | 750 |
/var/lib/watchflare/metrics.wal | Write-Ahead Log | watchflare:watchflare | 640 |
/var/lib/watchflare/packages.state.json | État de l’inventaire des paquets | watchflare:watchflare | 640 |
/etc/systemd/system/watchflare-agent.service | Définition du service | root:root | 644 |
/var/log/watchflare-agent.log | Journaux | watchflare:watchflare | 644 |
Réenrôler
Pour connecter l’agent à un autre Hub, ou après avoir supprimé puis recréé un hôte :
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 :
sudo restorecon -Rv /usr/local/bin/watchflare-agent
sudo restorecon -Rv /etc/watchflare
sudo restorecon -Rv /var/lib/watchflare Dépannage
| Symptôme | Cause | Correctif |
|---|---|---|
configuration error (fichier de config introuvable) | Pas enrôlé | Exécutez sudo watchflare-agent register ... |
permission denied | Mauvais propriétaire des fichiers | Vérifiez ls -la /etc/watchflare/ |
connection refused | Mauvais hôte/port ou pare-feu | Vérifiez que le port 50051 est joignable depuis cet hôte |
Invalid agent credentials | Clé qui ne correspond pas | Réenrôlez l’agent |
| L’hôte reste offline après le démarrage | Horloge désynchronisée | Assurez-vous que NTP tourne, car le Hub refuse les horodatages décalés de ±5 min |
Consultez les journaux pour plus de détails :
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