mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Alert rule delay/interval empty = 0 (#12804)
The alert rule delay was falling back to the default delay of 300s if the input box was empty. Most people would assume empty = 0, so make it match user's expectations.
This commit is contained in:
@@ -21,7 +21,6 @@ use LibreNMS\Fping;
|
|||||||
use LibreNMS\Modules\Core;
|
use LibreNMS\Modules\Core;
|
||||||
use LibreNMS\Util\IPv4;
|
use LibreNMS\Util\IPv4;
|
||||||
use LibreNMS\Util\IPv6;
|
use LibreNMS\Util\IPv6;
|
||||||
use LibreNMS\Util\Time;
|
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
@@ -1098,20 +1097,19 @@ function validate_device_id($id)
|
|||||||
|
|
||||||
function convert_delay($delay)
|
function convert_delay($delay)
|
||||||
{
|
{
|
||||||
$delay = preg_replace('/\s/', '', $delay);
|
if (preg_match('/(\d+)([mhd]?)/', $delay, $matches)) {
|
||||||
if (strstr($delay, 'm', true)) {
|
$multipliers = [
|
||||||
$delay_sec = $delay * 60;
|
'm' => 60,
|
||||||
} elseif (strstr($delay, 'h', true)) {
|
'h' => 3600,
|
||||||
$delay_sec = $delay * 3600;
|
'd' => 86400,
|
||||||
} elseif (strstr($delay, 'd', true)) {
|
];
|
||||||
$delay_sec = $delay * 86400;
|
|
||||||
} elseif (is_numeric($delay)) {
|
$multiplier = $multipliers[$matches[2]] ?? 1;
|
||||||
$delay_sec = $delay;
|
|
||||||
} else {
|
return $matches[1] * $multiplier;
|
||||||
$delay_sec = 300;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $delay_sec;
|
return $delay === '' ? 0 : 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalize_snmp_ip_address($data)
|
function normalize_snmp_ip_address($data)
|
||||||
|
|||||||
Reference in New Issue
Block a user