fix: replace monitor.parseToNumberOrNull with inline logic in SNMP monitor type

This commit is contained in:
circlecrystalin 2026-01-19 09:13:25 +01:00
parent bdeea53142
commit f1a5f1ac31

View File

@ -71,7 +71,17 @@ class SNMPMonitorType extends MonitorType {
heartbeat.status = UP;
heartbeat.msg = `JSON query passes (comparing ${response} ${monitor.jsonPathOperator} ${monitor.expectedValue})`;
// Extract numeric value for aggregation (will be passed to uptime calculator)
heartbeat.numeric_value = monitor.parseToNumberOrNull(response);
let numericValue = null;
if (typeof response === "number") {
numericValue = response;
} else if (typeof response === "string") {
// Try to parse as number
const parsed = parseFloat(response);
if (!isNaN(parsed) && isFinite(parsed)) {
numericValue = parsed;
}
}
heartbeat.numeric_value = numericValue;
} else {
throw new Error(
`JSON query does not pass (comparing ${response} ${monitor.jsonPathOperator} ${monitor.expectedValue})`