printers low-toner alerts; geenforce display readiness + token scope-binding; air-gap docker deploy kit
This commit is contained in:
@@ -10,10 +10,34 @@ and reading the matching part numbers out of the database.
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
|
||||
# alert thresholds (percent remaining)
|
||||
# display thresholds (percent remaining) for the ok/low/critical report badge
|
||||
CRITICAL_THRESHOLD = 5
|
||||
LOW_THRESHOLD = 10
|
||||
|
||||
# toner email-alert tiers (percent remaining). Distinct from the display
|
||||
# badge above: a warning email fires at or below TONER_WARNING_THRESHOLD, a
|
||||
# critical email at or below TONER_CRITICAL_THRESHOLD (empty).
|
||||
TONER_WARNING_THRESHOLD = 5
|
||||
TONER_CRITICAL_THRESHOLD = 0
|
||||
|
||||
|
||||
def alerttier(remaining: float, warning: float = TONER_WARNING_THRESHOLD,
|
||||
critical: float = TONER_CRITICAL_THRESHOLD) -> str:
|
||||
"""Map a toner percent-remaining to an email-alert tier.
|
||||
|
||||
critical at or below the critical threshold (default 0 = empty), warning at
|
||||
or below the warning threshold (default 5), else ok. Both are configurable
|
||||
(printers_alert_critical_threshold / printers_alert_warning_threshold)."""
|
||||
if remaining <= critical:
|
||||
return 'critical'
|
||||
if remaining <= warning:
|
||||
return 'warning'
|
||||
return 'ok'
|
||||
|
||||
|
||||
# tier severity rank; an alert fires only when the rank increases (worsens)
|
||||
TIER_RANK = {'ok': 0, 'warning': 1, 'critical': 2}
|
||||
|
||||
|
||||
def derivesupplytype(name: str) -> str:
|
||||
"""Map a Zabbix item name to a supply type."""
|
||||
|
||||
Reference in New Issue
Block a user