docs/ref/modules/utils/sync-protocol/README.md
The Agent Sync Protocol is a shared module that provides a standardized interface for internal Wazuh modules (FIM, SCA, Inventory) to synchronize data with the Wazuh Manager. It implements a reliable, session-based synchronization mechanism that ensures data consistency and handles errors gracefully.
The protocol supports both full and delta synchronization modes, enabling efficient data transfer while maintaining state consistency. It uses a persistent queue backed by SQLite for durability and implements retry mechanisms with timeout controls to handle failures.
Each internal module maintains its own instance of the Agent Sync Protocol with dedicated persistent storage:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ FIM │ │ SCA │ │ Inventory │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐
│ Agent Sync │ │ Agent Sync │ │ Agent Sync │
│ Protocol │ │ Protocol │ │ Protocol │
│ (FIM) │ │ (SCA) │ │ (Inventory) │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐
│ SQLite │ │ SQLite │ │ SQLite │
│ fim_sync.db │ │ sca_sync.db │ │ inv_sync.db │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
└────────────┬────┴─────────────────┘
│
┌────────▼────────┐
│ Message Queue │
│ (MQueue) │
└────────┬────────┘
│
▼
Wazuh Manager
Each module instance:
To integrate the Agent Sync Protocol in your module:
Include the appropriate header based on your language:
agent_sync_protocol.hppagent_sync_protocol_c_interface.hCreate a protocol instance with your module name and database path
Persist differences using:
persistDifference() / asp_persist_diff() for database storagepersistDifferenceInMemory() / asp_persist_diff_in_memory() for in-memory recoveryProcess manager responses with parseResponseBuffer() or asp_parse_response_buffer()
Check data integrity (optional):
requiresFullSync() / asp_requires_full_sync() to verify checksumsTrigger synchronization with:
synchronizeModule() / asp_sync_module() for module datasynchronizeMetadataOrGroups() / asp_sync_metadata_or_groups() for metadata/groupsClean up in-memory data (if used):
clearInMemoryData() / asp_clear_in_memory_data() before recoverySee the Integration Guide for detailed examples.