Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent avoids delays shutdown during scanning #384

Conversation

LucioDonda
Copy link
Member

@LucioDonda LucioDonda commented Dec 3, 2024

Related issue
Closes #358

Description

While the agent performs the inventory scanning the signal acknowledge gets lock. This was caused by the mutex used for protecting the concurrent access to the DBsync.
In order to avoid this it was perform a more specific use of it.

Configuration options

For interval scan check:

agent:
  server_url: https://localhost:27000
  registration_url: https://localhost:55000
  path.data: /tmp/wazuh-agent-data
  retry_interval: 30s
inventory:
  enabled: true
  interval: 10s
  scan_on_start: false
  hardware: true
  system: true
  networks: true
  packages: true
  ports: true
  ports_all: true
  processes: true
  hotfixes: true
logcollector:
  enabled: false
  localfiles:
    - /var/log/auth.log
  reload_interval: 1m
  file_wait: 500ms

For scan on start check

agent:
  server_url: https://localhost:27000
  registration_url: https://localhost:55000
  path.data: /tmp/wazuh-agent-data
  retry_interval: 30s
inventory:
  enabled: true
  interval: 10s
  scan_on_start: true
  hardware: true
  system: true
  networks: true
  packages: true
  ports: true
  ports_all: true
  processes: true
  hotfixes: true
logcollector:
  enabled: false
  localfiles:
    - /var/log/auth.log
  reload_interval: 1m
  file_wait: 500ms

Logs/Alerts example

After ctrl + C

[2024-12-03 15:23:37.322] [wazuh-agent] [trace] [TRACE] [inventoryImp.cpp:894] [ScanProcesses] Ending processes scan
[2024-12-03 15:23:37.322] [wazuh-agent] [trace] [TRACE] [inventoryImp.cpp:779] [ScanHotfixes] Starting hotfixes scan
[2024-12-03 15:23:37.322] [wazuh-agent] [trace] [TRACE] [inventoryImp.cpp:787] [ScanHotfixes] Ending hotfixes scan
[2024-12-03 15:23:37.322] [wazuh-agent] [trace] [TRACE] [inventoryImp.cpp:855] [ScanPorts] Starting ports scan
[2024-12-03 15:23:37.322] [wazuh-agent] [info] [INFO] [logcollector.cpp:51] [Stop] Logcollector stopped
[2024-12-03 15:23:37.325] [wazuh-agent] [trace] [TRACE] [inventoryImp.cpp:858] [ScanPorts] Ending ports scan
[2024-12-03 15:23:37.325] [wazuh-agent] [trace] [TRACE] [inventoryImp.cpp:382] [TryCatchTask] No Scanning during stopping
[2024-12-03 15:23:37.325] [wazuh-agent] [info] [INFO] [inventoryImp.cpp:912] [Scan] Evaluation finished.
[2024-12-03 15:23:37.325] [wazuh-agent] [info] [INFO] [inventory.cpp:36] [Start] Module finished.

Tests

  • Compilation without warnings in every supported platform
    • Linux

Copy link
Member

@cborla cborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cborla cborla merged commit 527d17d into master Dec 3, 2024
5 checks passed
@cborla cborla deleted the fix/358-agent-hangs-during-a-connection-attempt-and-delays-shutdown branch December 3, 2024 21:59
@cborla cborla changed the title Agent delays shutdown while Scanning Agent avoids delays shutdown during scanning Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent hangs during a connection attempt and delays shutdown
2 participants