Skip to content

Commit b323e37

Browse files
authored
Always write value for apt_upgrades_pending and apt_upgrades_held (#237)
Always write value for apt_upgrades_pending and apt_upgrades_held to ensure monitoring works. If there are no held packages or no pending upgrades, nothing is written to apt.prom, resulting in monitoring dashboards not picking up on these values. This patch fixes that by ensuring there's always a value for apt_upgrades_pending and apt_upgrades_held . --------- Signed-off-by: Maarten Kossen (mpkossen) <[email protected]>
1 parent b0ae28d commit b323e37

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

apt_info.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ def _write_pending_upgrades(registry, cache):
5959
}
6060
upgrade_list = _convert_candidates_to_upgrade_infos(candidates)
6161

62+
g = Gauge('apt_upgrades_pending', "Apt packages pending updates by origin",
63+
['origin', 'arch'], registry=registry)
6264
if upgrade_list:
63-
g = Gauge('apt_upgrades_pending', "Apt packages pending updates by origin",
64-
['origin', 'arch'], registry=registry)
6565
for change in upgrade_list:
6666
g.labels(change.labels['origin'], change.labels['arch']).set(change.count)
67+
else:
68+
g.labels("", "").set(0)
6769

6870

6971
def _write_held_upgrades(registry, cache):
@@ -73,11 +75,13 @@ def _write_held_upgrades(registry, cache):
7375
}
7476
upgrade_list = _convert_candidates_to_upgrade_infos(held_candidates)
7577

78+
g = Gauge('apt_upgrades_held', "Apt packages pending updates but held back.",
79+
['origin', 'arch'], registry=registry)
7680
if upgrade_list:
77-
g = Gauge('apt_upgrades_held', "Apt packages pending updates but held back.",
78-
['origin', 'arch'], registry=registry)
7981
for change in upgrade_list:
8082
g.labels(change.labels['origin'], change.labels['arch']).set(change.count)
83+
else:
84+
g.labels("", "").set(0)
8185

8286

8387
def _write_autoremove_pending(registry, cache):

0 commit comments

Comments
 (0)