2626
2727namespace App \Jobs ;
2828
29+ use App \Action ;
30+ use App \Actions \Alerts \RunAlertRulesAction ;
2931use App \Actions \Device \SetDeviceAvailability ;
3032use App \Models \Device ;
3133use Illuminate \Bus \Queueable ;
3537use Illuminate \Queue \SerializesModels ;
3638use Illuminate \Support \Collection ;
3739use Illuminate \Support \Facades \Log ;
38- use LibreNMS \Alert \AlertRules ;
3940use LibreNMS \Data \Source \Fping ;
4041use LibreNMS \Data \Source \FpingResponse ;
4142use LibreNMS \Enum \AvailabilitySource ;
@@ -191,7 +192,7 @@ public function handleResponse(FpingResponse $response): void
191192 Log::debug ("Device $ device ->hostname changed status to $ type, running alerts " );
192193
193194 if (count ($ waiting_on ) === 0 ) {
194- $ this -> runAlerts ( $ device-> device_id );
195+ Action:: execute (RunAlertRulesAction::class, $ device );
195196 } else {
196197 Log::debug ('Alerts Deferred ' );
197198
@@ -240,7 +241,7 @@ private function runDeferredAlerts(int $device_id): void
240241 if ($ alert_child ) {
241242 Log::debug ("Deferred device $ child_id triggered by $ device_id " );
242243
243- $ this ->runAlerts ($ child_id );
244+ Action:: execute (RunAlertRulesAction::class, $ this ->devices -> get ($ child_id) );
244245 $ this ->deferred ->pull ($ child_id );
245246 }
246247 }
@@ -249,13 +250,4 @@ private function runDeferredAlerts(int $device_id): void
249250
250251 $ this ->waiting_on ->pull ($ device_id );
251252 }
252-
253- /**
254- * run alerts for a device
255- */
256- private function runAlerts (int $ device_id ): void
257- {
258- $ rules = new AlertRules ;
259- $ rules ->runRules ($ device_id );
260- }
261253}
0 commit comments