Stay quiet when a site never asked for supply monitoring
Splitting "cannot see the cartridges" from "nothing is low" was right, but it treated two unlike cases as one. isconfigured means enabled AND a URL AND a token, so its absence means the site did not ask for supply monitoring at all - and a permanent "Supply monitoring is not configured" line is a card reporting nothing wrong every day, which is how a board teaches people to stop reading it. It matters for sites adopting ShopDB without Zabbix, who would otherwise inherit a warning about a feature they declined. Not configured now returns a plain empty and the card hides. Only configured and unanswerable reports itself, because that is something meant to work that is not working. Also withdraws an unfounded inference. A dev box has no route to Zabbix by design, so "not reachable" there is the expected state and says nothing about what production can see. The value of this change is not that it revealed a production fault; it is that when production's Zabbix does go down, the board will say so instead of displaying "Low Supplies 0". Four tests pin the three cases apart: unreachable reports, unconfigured stays quiet, and a real zero from a reachable Zabbix is not flagged as blindness. The fourth holds the envelope's rows, since carrying a reason changed the response shape. Verified they are not vacuous by restoring the original branch in place - the unreachable test fails against it. Full suite 2182 passed.
This commit is contained in:
@@ -2129,9 +2129,14 @@ def _get_low_supplies_data():
|
||||
# dashboard then showed Low Supplies 0 while the monitoring was dead, which
|
||||
# is not a missing feature but a wrong statement: it reads as reassurance.
|
||||
if not service.isconfigured:
|
||||
return {'printers': [], 'unavailable': 'Supply monitoring is not configured',
|
||||
'summary': {'total_checked': 0, 'low': 0, 'critical': 0}}
|
||||
# Enabled plus a URL plus a token. Absent any of those the site has not
|
||||
# asked for supply monitoring, and a permanent "not configured" line
|
||||
# would be a card reporting nothing wrong every day - which is how a
|
||||
# board teaches people to stop reading it. Nothing to say: stay hidden.
|
||||
return {'printers': [], 'summary': {'total_checked': 0, 'low': 0, 'critical': 0}}
|
||||
if not service.isreachable:
|
||||
# Configured and unanswerable is a different thing: something meant to
|
||||
# work is not working, and the cartridges are NOT known to be fine.
|
||||
return {'printers': [], 'unavailable': 'Supply monitoring is not reachable',
|
||||
'summary': {'total_checked': 0, 'low': 0, 'critical': 0}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user