From 01f0cf99a6e6b5bf46edd54fc5e8d417952db8e5 Mon Sep 17 00:00:00 2001 From: sylvain Date: Sat, 7 Mar 2026 16:55:54 +0000 Subject: [PATCH] =?UTF-8?q?D=C3=A9claration=20=C3=A0=20agent1=20via=20MQTT?= =?UTF-8?q?=20(agents/register)=20au=20d=C3=A9marrage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- agent2_debian13.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/agent2_debian13.py b/agent2_debian13.py index 865ec78..ce8c70e 100644 --- a/agent2_debian13.py +++ b/agent2_debian13.py @@ -85,6 +85,18 @@ def mqtt_publish(topic: str, message: str): if mqtt_publish_client: mqtt_publish_client.publish(topic, message) +def register_to_agent1(): + """Publie une déclaration de mise en ligne sur agents/register.""" + import json as _json + payload = _json.dumps({ + "agent" : MQTT_CLIENT, + "jid" : XMPP_JID, + "mqtt_inbox": MQTT_INBOX, + "speciality": "Administration Debian : apt, dpkg, systemd, conteneurs LXC/Docker, KVM, réseau, sécurité système", + }) + mqtt_publish("agents/register", payload) + print("[REGISTER] Déclaration envoyée à agent1.") + def on_mqtt_message(client, userdata, msg): task = msg.payload.decode(errors="replace") print(f"[MQTT] Tâche reçue d'agent1 : {task[:100]}") @@ -102,6 +114,7 @@ def start_mqtt_listener(): client_id=MQTT_CLIENT + "_pub") mqtt_publish_client.connect(MQTT_HOST, MQTT_PORT) mqtt_publish_client.loop_start() + register_to_agent1() # Client dédié à la souscription sub_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2,