feat: add get_health_metrics() via HP-MIB and IF-MIB
Implements SNMP health collection for ProCurve/Aruba switches using HP-proprietary CPU/memory/uptime OIDs with IF-MIB interface counters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
d7ed4fda1f
commit
aa55eb2bb9
@@ -1091,6 +1091,68 @@ class ProcurveDriver(SwitchDriver):
|
|||||||
|
|
||||||
return {"success": success, "output": "\n".join(lines)}
|
return {"success": success, "output": "\n".join(lines)}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Health metrics (SNMP)
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
async def get_health_metrics(cls, snmp_get, snmp_walk) -> dict:
|
||||||
|
import asyncio
|
||||||
|
from napalm_device_types._ucd_metrics import build_if_metrics, ticks_to_seconds
|
||||||
|
|
||||||
|
_HP_CPU_STAT = "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0"
|
||||||
|
_HP_CPU_STAT_OLD = "1.3.6.1.4.1.11.2.3.7.8.6.1.0"
|
||||||
|
_HP_MEM_TOTAL = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.1.1.1.5.1"
|
||||||
|
_HP_MEM_USED = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.1.1.1.6.1"
|
||||||
|
_HP_UPTIME = "1.3.6.1.4.1.11.2.14.11.1.2.4.1.5.1"
|
||||||
|
_OID_IF_DESCR = "1.3.6.1.2.1.2.2.1.2"
|
||||||
|
_OID_IF_SPEED = "1.3.6.1.2.1.2.2.1.5"
|
||||||
|
_OID_IF_IN_OCT = "1.3.6.1.2.1.2.2.1.10"
|
||||||
|
_OID_IF_OUT_OCT = "1.3.6.1.2.1.2.2.1.16"
|
||||||
|
_OID_IF_IN_ERR = "1.3.6.1.2.1.2.2.1.14"
|
||||||
|
_OID_IF_OUT_ERR = "1.3.6.1.2.1.2.2.1.20"
|
||||||
|
|
||||||
|
(hp_uptime, cpu_raw, cpu_old, mem_t, mem_u,
|
||||||
|
descr, speed, in_oct, out_oct, in_err, out_err) = await asyncio.gather(
|
||||||
|
snmp_get(_HP_UPTIME),
|
||||||
|
snmp_get(_HP_CPU_STAT),
|
||||||
|
snmp_get(_HP_CPU_STAT_OLD),
|
||||||
|
snmp_get(_HP_MEM_TOTAL),
|
||||||
|
snmp_get(_HP_MEM_USED),
|
||||||
|
snmp_walk(_OID_IF_DESCR),
|
||||||
|
snmp_walk(_OID_IF_SPEED),
|
||||||
|
snmp_walk(_OID_IF_IN_OCT),
|
||||||
|
snmp_walk(_OID_IF_OUT_OCT),
|
||||||
|
snmp_walk(_OID_IF_IN_ERR),
|
||||||
|
snmp_walk(_OID_IF_OUT_ERR),
|
||||||
|
)
|
||||||
|
|
||||||
|
metrics: dict = {}
|
||||||
|
|
||||||
|
secs = ticks_to_seconds(hp_uptime)
|
||||||
|
if secs is not None:
|
||||||
|
metrics["uptime_seconds"] = secs
|
||||||
|
|
||||||
|
cpu = cpu_raw or cpu_old
|
||||||
|
if cpu is not None:
|
||||||
|
try:
|
||||||
|
metrics["cpu_percent"] = float(cpu)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if mem_t and mem_u:
|
||||||
|
try:
|
||||||
|
total = int(mem_t)
|
||||||
|
used = int(mem_u)
|
||||||
|
metrics["memory_total_bytes"] = total
|
||||||
|
metrics["memory_used_bytes"] = used
|
||||||
|
metrics["memory_percent"] = round(used / total * 100, 1) if total else 0.0
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
build_if_metrics(metrics, descr, speed, in_oct, out_oct, in_err, out_err)
|
||||||
|
return metrics
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Helpers
|
# Helpers
|
||||||
@@ -1161,3 +1223,4 @@ def _parse_ping_output(output: str, count: int) -> Dict:
|
|||||||
"results": results,
|
"results": results,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user