docs/ref/modules/agent_info/architecture.md
The agent_info module is designed to be the definitive source of agent identity and group information. It implements a robust architecture to collect, persist, and synchronize this data, coordinating with other modules to ensure system-wide consistency.
AgentInfoImpl)The core C++ class that orchestrates all module operations.
Key responsibilities:
SysInfo and file readers to gather agent data.DBSync to persist information and detect changes.AgentSyncProtocol for reliable communication with the manager.The module gathers information from several sources:
client.keys file: Reads the agent's unique ID and name.merged.mg file: Reads the agent's group memberships.Leverages the shared DBSync component for local SQLite database operations.
Key responsibilities:
agent_metadata table.agent_groups table.db_metadata table.A critical feature that ensures data consistency across the agent. When a change in agent groups or other critical metadata is detected, agent_info orchestrates a synchronization process with other modules.
Coordinated Modules:
FIM (File Integrity Monitoring)SCA (Security Configuration Assessment)Syscollector (System Inventory)Coordination Steps:
agent_info sends its changes to the manager, associated with the new version and the list of affected module indices.This protocol guarantees that configuration changes tied to agent groups are applied atomically across the system.
wm_agent_info_main() loads the agent_info shared library and sets up C-style callbacks.agent_info_start() creates and configures the AgentInfoImpl instance.DBSync, and loadSyncFlags() reads the last operational state from the db_metadata table.AgentInfoImpl::start() begins the main execution loop.start() method periodically calls populateAgentMetadata().populateAgentMetadata() reads data from SysInfo, client.keys, and merged.mg.updateChanges(), which uses a DBSync transaction to compare it with the database content.DBSync detects any difference, it invokes the processEvent() callback with the change type (INSERTED, MODIFIED, DELETED).Metadata Change Detected
│
▼
populateAgentMetadata()
│
▼
updateChanges() ──────────────► DBSync transaction compares data
│ │
▼ ▼
processEvent() callback (If a change is found)
│
├─► Generate Stateless Event ─────► report_callback() ─────► Manager (immediate alert)
│
└─► Set Synchronization Flag ───────► setSyncFlag(true)
(e.g., m_shouldSyncGroups) │
▼
Main loop in start() detects flag ◄───────────────┘
│
▼
performDeltaSync()
│
▼
coordinateModules()
│
├─► Pause, Flush, Versioning of FIM, SCA, Syscollector
│
└─► synchronizeMetadataOrGroups() ───► AgentSyncProtocol ───► Manager (reliable delivery)
The agent_info module operates in a single main thread. The start() method contains a loop that sleeps for the configured interval and wakes up to perform its tasks. Asynchronous operations are handled by the module coordination protocol, which queries other modules and can poll for completion (e.g., waiting for FIM to finish flushing).