A supply nobody could read is unknown, not empty
This commit is contained in:
@@ -68,19 +68,34 @@ def derivecolor(name: str, tagcolor: Optional[str] = None) -> str:
|
||||
return "none"
|
||||
|
||||
|
||||
def classifysupply(level: float, name: str, vendor: Optional[str]) -> Dict:
|
||||
"""Classify one supply item into ok/low/critical.
|
||||
def classifysupply(level: Optional[float], name: str,
|
||||
vendor: Optional[str]) -> Dict:
|
||||
"""Classify one supply item into ok/low/critical, or unknown.
|
||||
|
||||
Waste cartridge fill is inverted vs a toner level: a full waste cartridge
|
||||
is bad. Standard vendors report waste as percent FULL (high = bad). Xerox
|
||||
EC/AltaLink series report waste as percent capacity REMAINING (low = bad),
|
||||
same direction as toner. Normalise everything to percent remaining first.
|
||||
|
||||
A level of None means Zabbix has no usable reading; the status is 'unknown'
|
||||
and remaining is None. Callers must not treat that as a low supply.
|
||||
"""
|
||||
lowername = (name or "").lower()
|
||||
iswaste = "waste" in lowername
|
||||
isdrum = "drum" in lowername or "imaging" in lowername
|
||||
isxerox = bool(vendor) and "xerox" in vendor.lower()
|
||||
|
||||
# No reading is its own answer, not a level. It cannot be classified ok,
|
||||
# low or critical without asserting something nobody measured - and every
|
||||
# one of those three is a claim the reader would act on.
|
||||
if level is None:
|
||||
return {
|
||||
"status": "unknown",
|
||||
"remaining": None,
|
||||
"iswaste": iswaste,
|
||||
"isdrum": isdrum,
|
||||
}
|
||||
|
||||
if iswaste and not isxerox:
|
||||
remaining = 100 - level
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user