Skip to content

Commit

Permalink
Merge pull request #14 from S-Bryce/patch-1
Browse files Browse the repository at this point in the history
Add missing "connection" JSON property
  • Loading branch information
pyToshka authored Dec 28, 2023
2 parents 2a970a8 + 31686b5 commit b50a66f
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,37 @@ def collect():
yield metric
metric = Metric("wazuh_agent_status", "Total Wazuh agents by status", "summary")

# Wazuh >= v4.4
if "connection" in agents["agent_status"]:
agents_path = agents["agent_status"]["connection"]
# Legacy Wazuh support (< v4.4)
else:
agents_path = agents["agent_status"]

metric.add_sample(
"wazuh_active_agents", value=agents["agent_status"]["active"], labels={}
"wazuh_active_agents",
value=agents_path["active"],
labels={}
)
metric.add_sample(
"wazuh_disconnected_agents",
value=agents["agent_status"]["disconnected"],
"wazuh_disconnected_agents",
value=agents_path["disconnected"],
labels={},
)
metric.add_sample(
"wazuh_never_connected_agents",
value=agents["agent_status"]["never_connected"],
value=agents_path["never_connected"],
labels={},
)
metric.add_sample(
"wazuh_pending_agents", value=agents["agent_status"]["pending"], labels={}
"wazuh_pending_agents",
value=agents_path["pending"],
labels={}
)
metric.add_sample(
"wazuh_total_agents", value=agents["agent_status"]["total"], labels={}
"wazuh_total_agents",
value=agents_path["total"],
labels={}
)
yield metric
metric = InfoMetricFamily("wazuh_agent_version", "Wazuh agent versions")
Expand Down

0 comments on commit b50a66f

Please sign in to comment.