printers low-toner alerts; geenforce display readiness + token scope-binding; air-gap docker deploy kit
This commit is contained in:
@@ -8,12 +8,14 @@ from .model_supply import ( # data-driven model -> toner/drum/waste mapping
|
||||
SUPPLY_COLORS,
|
||||
CAPACITY_TIERS,
|
||||
)
|
||||
from .supply_alert import PrinterSupplyAlert # per-printer toner alert state
|
||||
|
||||
__all__ = [
|
||||
'Printer',
|
||||
'PrinterType',
|
||||
'PrinterDriver',
|
||||
'ModelSupply',
|
||||
'PrinterSupplyAlert',
|
||||
'SUPPLY_TYPES',
|
||||
'SUPPLY_COLORS',
|
||||
'CAPACITY_TIERS',
|
||||
|
||||
40
plugins/printers/models/supply_alert.py
Normal file
40
plugins/printers/models/supply_alert.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Per-printer supply alert state.
|
||||
|
||||
The supply poller (flask printers check-toner-alerts) is stateless: it reads
|
||||
live levels from Zabbix each run. To alert once per downward crossing (and
|
||||
re-arm after a refill) it needs to remember the last tier it alerted for each
|
||||
printer + supply. One row per (printerid, supplykey); supplykey is the toner
|
||||
color (black/cyan/magenta/yellow) or the raw item name when color is unknown.
|
||||
"""
|
||||
|
||||
from shopdb.api import db, BaseModel
|
||||
|
||||
|
||||
class PrinterSupplyAlert(BaseModel):
|
||||
"""Last-alerted tier for one printer supply. lasttier in ok/warning/critical."""
|
||||
|
||||
__tablename__ = 'printersupplyalerts'
|
||||
|
||||
printersupplyalertid = db.Column(db.Integer, primary_key=True)
|
||||
printerid = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('printers.printerid', ondelete='CASCADE'),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
supplykey = db.Column(
|
||||
db.String(64),
|
||||
nullable=False,
|
||||
comment='Toner color, or Zabbix item name when color is unknown',
|
||||
)
|
||||
lasttier = db.Column(
|
||||
db.String(16),
|
||||
nullable=False,
|
||||
default='ok',
|
||||
comment='Last tier alerted: ok, warning, or critical',
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
db.UniqueConstraint('printerid', 'supplykey',
|
||||
name='uq_printersupplyalert_printer_key'),
|
||||
)
|
||||
Reference in New Issue
Block a user