Skip to content

Commit c5f17b3

Browse files
authored
Fix alerts in app/Jobs/PingCheck.php (librenms#18666)
1 parent 40d5f90 commit c5f17b3

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

app/Jobs/PingCheck.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
namespace App\Jobs;
2828

29+
use App\Action;
30+
use App\Actions\Alerts\RunAlertRulesAction;
2931
use App\Actions\Device\SetDeviceAvailability;
3032
use App\Models\Device;
3133
use Illuminate\Bus\Queueable;
@@ -35,7 +37,6 @@
3537
use Illuminate\Queue\SerializesModels;
3638
use Illuminate\Support\Collection;
3739
use Illuminate\Support\Facades\Log;
38-
use LibreNMS\Alert\AlertRules;
3940
use LibreNMS\Data\Source\Fping;
4041
use LibreNMS\Data\Source\FpingResponse;
4142
use 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

Comments
 (0)