Add Zabbix template with offline and last-seen triggers
- zabbix_template.yaml: importable template "Yodmon Yodeck Player"
- 5 SNMP items using {$YODECK_ID} host macro for per-host OIDs
- Trigger: offline warning after 30 minutes (yodeck.online < 1)
- Trigger: last seen > 4 hours (now() - yodeck.last_seen_ts > 14400)
- snmp/pass_persist.py: add col 7 — last_seen as Unix timestamp
- app/zabbix.py: link hosts to template, upsert {$YODECK_ID} macro;
existing hosts get template linked on next sync automatically
- app/config.py: add ZABBIX_TEMPLATE setting
Import zabbix_template.yaml once via Zabbix UI, then redeploy.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,10 +7,11 @@ Reads player data from the SQLite database and serves it over SNMP v2c.
|
||||
OID layout (base = ENTERPRISE_OID.1.1):
|
||||
base.1.<yodeck_id> STRING "yodeck-<id>"
|
||||
base.2.<yodeck_id> STRING player display name
|
||||
base.3.<yodeck_id> INTEGER online (1 = online, 0 = offline)
|
||||
base.4.<yodeck_id> STRING last_seen (ISO-8601 timestamp)
|
||||
base.5.<yodeck_id> INTEGER updating (1 = yes, 0 = no)
|
||||
base.6.<yodeck_id> INTEGER registered (1 = yes, 0 = no)
|
||||
base.3.<yodeck_id> INTEGER online (1 = online, 0 = offline)
|
||||
base.4.<yodeck_id> STRING last_seen (ISO-8601 timestamp)
|
||||
base.5.<yodeck_id> INTEGER updating (1 = yes, 0 = no)
|
||||
base.6.<yodeck_id> INTEGER registered (1 = yes, 0 = no)
|
||||
base.7.<yodeck_id> INTEGER last_seen_unix (Unix timestamp, 0 if unknown)
|
||||
|
||||
pass_persist protocol (net-snmp):
|
||||
stdin: PING | get\n<oid> | getnext\n<oid>
|
||||
@@ -25,6 +26,17 @@ DB_PATH = os.environ.get('DB_PATH', '/data/yodmon.db')
|
||||
ENTERPRISE_OID = os.environ.get('ENTERPRISE_OID', '.1.3.6.1.4.1.99999')
|
||||
BASE_OID = f"{ENTERPRISE_OID}.1.1"
|
||||
|
||||
def _iso_to_unix(iso_str):
|
||||
"""Convert ISO-8601 timestamp string to Unix epoch integer, 0 if missing."""
|
||||
if not iso_str:
|
||||
return 0
|
||||
try:
|
||||
dt = datetime.fromisoformat(iso_str.replace('Z', '+00:00'))
|
||||
return int(dt.timestamp())
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
|
||||
# (column_index, snmp_type, value_extractor)
|
||||
COLUMNS = [
|
||||
(1, 'STRING', lambda p: f"yodeck-{p['id']}"),
|
||||
@@ -33,6 +45,7 @@ COLUMNS = [
|
||||
(4, 'STRING', lambda p: p.get('last_seen') or ''),
|
||||
(5, 'INTEGER', lambda p: str(p.get('updating', 0))),
|
||||
(6, 'INTEGER', lambda p: str(p.get('registered', 0))),
|
||||
(7, 'INTEGER', lambda p: str(_iso_to_unix(p.get('last_seen')))),
|
||||
]
|
||||
|
||||
# Rate-limit SNMP transfer log entries (at most one per minute)
|
||||
|
||||
Reference in New Issue
Block a user