Skip to content

Commit 47a6540

Browse files
authored
Create an eventlog on maintenance failure (librenms#18611)
1 parent 5e3e876 commit 47a6540

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

routes/console.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
use App\Console\Commands\MaintenanceFetchOuis;
66
use App\Console\Commands\MaintenanceFetchRSS;
77
use App\Jobs\PingCheck;
8+
use App\Models\Eventlog;
89
use Illuminate\Support\Facades\Artisan;
910
use Illuminate\Support\Facades\Cache;
11+
use Illuminate\Support\Facades\Config;
1012
use Illuminate\Support\Facades\Schedule;
13+
use LibreNMS\Enum\Severity;
1114
use LibreNMS\Util\Time;
1215
use Symfony\Component\Process\Process;
1316

@@ -178,19 +181,23 @@
178181
Schedule::command(MaintenanceFetchOuis::class)
179182
->weeklyOn(0, Time::pseudoRandomBetween('01:00', '01:59'))
180183
->onOneServer()
181-
->appendOutputTo($maintenance_log_file);
184+
->appendOutputTo($maintenance_log_file)
185+
->onFailure(fn () => Eventlog::log('The scheduled command maintenance:fetch-ouis failed to run. Check the maintenance.log for details.', null, 'maintenance', Severity::Error));
182186

183187
Schedule::command(MaintenanceCleanupNetworks::class)
184188
->weeklyOn(0, Time::pseudoRandomBetween('02:00', '02:59'))
185189
->onOneServer()
186-
->appendOutputTo($maintenance_log_file);
190+
->appendOutputTo($maintenance_log_file)
191+
->onFailure(fn () => Eventlog::log('The scheduled command maintenance:cleanup-networks failed to run. Check the maintenance.log for details.', null, 'maintenance', Severity::Error));
187192

188193
Schedule::command(MaintenanceFetchRSS::class)
189194
->dailyAt(Time::pseudoRandomBetween('03:00', '03:59'))
190195
->onOneServer()
191-
->appendOutputTo($maintenance_log_file);
196+
->appendOutputTo($maintenance_log_file)
197+
->onFailure(fn () => Eventlog::log('The scheduled command maintenance:fetch-rss failed to run. Check the maintenance.log for details.', null, 'maintenance', Severity::Error));
192198

193199
Schedule::command(MaintenanceCleanupSyslog::class)
194200
->dailyAt('03:30')
195201
->onOneServer()
196-
->appendOutputTo($maintenance_log_file);
202+
->appendOutputTo($maintenance_log_file)
203+
->onFailure(fn () => Eventlog::log('The scheduled command maintenance:cleanup-syslog failed to run. Check the maintenance.log for details.', null, 'maintenance', Severity::Error));

0 commit comments

Comments
 (0)