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