Fix SNMP latency to exclude Slim instance creation overhead

Move time measurement to only capture the actual SNMP GET request,
excluding the Slim() context manager initialization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-26 19:44:14 +01:00
parent 06e1d683b3
commit 624e3e7633

View File

@@ -66,7 +66,6 @@ class SnmpChecker(BaseChecker):
temperature_oid = self.config.get("temperature_oid")
timeout_val = self.config.get("timeout", 5)
start = time.time()
try:
with Slim() as slim:
# Construit la liste des OIDs à interroger
@@ -74,6 +73,7 @@ class SnmpChecker(BaseChecker):
if temperature_oid:
oids.append(ObjectType(ObjectIdentity(temperature_oid)))
start = time.time()
error_indication, error_status, error_index, var_binds = await slim.get(
community,
host,
@@ -82,8 +82,7 @@ class SnmpChecker(BaseChecker):
timeout=timeout_val,
retries=1
)
response_time = (time.time() - start) * 1000 # ms
response_time = (time.time() - start) * 1000 # ms
if error_indication:
return CheckResult(