Skip to content

Commit ada332a

Browse files
committed
Fix alert check null
Basically when device is non-existent
1 parent bee970a commit ada332a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

LibreNMS/Alert/RunAlerts.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use App\Facades\DeviceCache;
3535
use App\Facades\LibrenmsConfig;
3636
use App\Facades\Rrd;
37+
use App\Models\Alert;
3738
use App\Models\AlertTransport;
3839
use App\Models\ApplicationMetric;
3940
use App\Models\Eventlog;
@@ -509,9 +510,12 @@ public function runAlerts()
509510
$alert['details']['count'] = 0;
510511
}
511512

512-
$chk = dbFetchRow('SELECT alerts.alerted,devices.ignore,devices.disabled FROM alerts,devices WHERE alerts.device_id = ? && devices.device_id = alerts.device_id && alerts.rule_id = ?', [$alert['device_id'], $alert['rule_id']]);
513+
$status_check = Alert::where('alerts.device_id', $alert['device_id'])
514+
->where('alerts.rule_id', $alert['rule_id'])
515+
->join('devices', 'alerts.device_id', '=', 'devices.device_id')
516+
->first(['alerts.alerted', 'devices.ignore', 'devices.disabled']);
513517

514-
if ($chk['alerted'] == $alert['state']) {
518+
if ($status_check->alerted == $alert['state']) {
515519
$noiss = true;
516520
}
517521

@@ -561,7 +565,7 @@ public function runAlerts()
561565
$noiss = false;
562566
}
563567
}
564-
if ($chk['ignore'] == 1 || $chk['disabled'] == 1) {
568+
if ($status_check->ignore || $status_check->disabled) {
565569
$noiss = true;
566570
$updet = false;
567571
$noacc = false;

0 commit comments

Comments
 (0)