Skip to content

Commit c38392a

Browse files
committed
Little improvements
1 parent ada332a commit c38392a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

LibreNMS/Alert/RunAlerts.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
use App\Facades\DeviceCache;
3535
use App\Facades\LibrenmsConfig;
3636
use App\Facades\Rrd;
37-
use App\Models\Alert;
3837
use App\Models\AlertTransport;
3938
use App\Models\ApplicationMetric;
4039
use App\Models\Eventlog;
40+
use Illuminate\Support\Facades\DB;
41+
use Illuminate\Support\Facades\Log;
4142
use LibreNMS\Alerting\QueryBuilderParser;
4243
use LibreNMS\Enum\AlertState;
4344
use LibreNMS\Enum\MaintenanceStatus;
@@ -510,11 +511,17 @@ public function runAlerts()
510511
$alert['details']['count'] = 0;
511512
}
512513

513-
$status_check = Alert::where('alerts.device_id', $alert['device_id'])
514+
$status_check = DB::table('alerts')
514515
->where('alerts.rule_id', $alert['rule_id'])
515-
->join('devices', 'alerts.device_id', '=', 'devices.device_id')
516+
->leftJoin('devices', 'alerts.device_id', '=', 'devices.device_id')
516517
->first(['alerts.alerted', 'devices.ignore', 'devices.disabled']);
517518

519+
if ($status_check === null) {
520+
Log::error('Alert rule not found');
521+
522+
return;
523+
}
524+
518525
if ($status_check->alerted == $alert['state']) {
519526
$noiss = true;
520527
}

0 commit comments

Comments
 (0)