Skip to content

Commit

Permalink
17041 FIX apt: Show correct value if metrics if there are no updates
Browse files Browse the repository at this point in the history
If there were no updates pending the metrics showed 'n/a' as the value.
This has now been fixed and they will show 0 as the value.

SUP-21419

Change-Id: I0596e980c54d487327c8a7eec7dd20feb656d9bc
  • Loading branch information
racicLuka committed Dec 3, 2024
1 parent 9fec0da commit 5749da5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .werks/17041.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[//]: # (werk v2)
# apt: Show correct value if metrics if there are no updates

key | value
---------- | ---
date | 2024-12-02T14:15:07+00:00
version | 2.3.0p22
class | fix
edition | cre
component | checks
level | 1
compatible | yes

If there were no updates pending the metrics showed 'n/a' as the value.
This has now been fixed and they will show 0 as the value.
2 changes: 2 additions & 0 deletions cmk/plugins/collection/agent_based/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ def check_apt(params: Mapping[str, Any], section: Section) -> CheckResult:

if section.n_updates == 0:
yield Result(state=State.OK, summary=NOTHING_PENDING_FOR_INSTALLATION)
yield Metric(name="normal_updates", value=0)
yield Metric(name="security_updates", value=0)
return

yield Result(
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/cmk/plugins/collection/agent_based/test_apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ def test_apt_discovery() -> None:
pytest.param(
DEFAULT_PARAMS,
Section([], [], []),
[Result(state=State.OK, summary="No updates pending for installation")],
[
Result(state=State.OK, summary="No updates pending for installation"),
Metric("normal_updates", 0.0),
Metric("security_updates", 0.0),
],
id="Nothing pending for installation.",
),
pytest.param(
Expand Down

0 comments on commit 5749da5

Please sign in to comment.