Skip to content

Send shutdown event from the agent to the server #585

@vikman90

Description

@vikman90

Description

The Wazuh agent should send an event to the server when performing a graceful shutdown. This event will be a stateless message sent directly, bypassing the agent's queue.

This task presents a challenge: the agent must send the message while shutting down quickly. Therefore, an independent sending mechanism with a timeout will be implemented.

Requirements

  • When the agent receives a shutdown signal, it must send to the server:
    • A stateless message indicating the shutdown.
    • A stateful message to update its status to "shut down."
  • The agent must not re-authenticate after sending these messages.

Configuration

Proposed configuration option:

agent:
  shutdown_notify_timeout: 10s

Stateless message format

Metadata

{ "module": "agent" }

Data

{
  "event": {
    "original": "The agent is shutting down.",
    "created": "2025-02-10 11:30:01.000"
  }
}

Plan

  1. Validate the stateless message format.
  2. Propose the stateful message format, involving the Server and Indexer teams.
  3. Add the shutdown_notify_timeout configuration option.
  4. Develop the functionality to send both messages during the agent's shutdown routine.
  5. Add tests for this use case.
  6. Update technical documentation.

Definition of done

  • The agent sends both stateless and stateful messages upon shutdown.
  • Messages are sent without re-authentication.
  • The shutdown_notify_timeout is configurable.
  • Tests cover normal and edge cases.
  • Documentation is updated accordingly.

Additional notes

  • The stateful message format is yet to be defined.
  • This design provides a "best effort" approach to mark the agent's status in the inventory. It does not guarantee the agent will be marked as disconnected after shutdown.
  • The agent will also send these events when shutting down due to a system reboot.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions