lots of progress
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\CheckBrokenLinks;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
|
||||
class MonitorLinksCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'monitor:links';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check for broken links on all enabled sites';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Starting broken link monitoring...');
|
||||
|
||||
// Fetch all sites with monitoring enabled
|
||||
$sites = Site::where('monitoring_enabled', true)->get();
|
||||
|
||||
if ($sites->isEmpty()) {
|
||||
$this->warn('No enabled sites found for broken link monitoring.');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info("Found {$sites->count()} enabled site(s) for broken link monitoring.");
|
||||
|
||||
// Create a batch of jobs to dispatch in parallel
|
||||
$jobs = $sites->map(function (Site $site) {
|
||||
return new CheckBrokenLinks($site);
|
||||
});
|
||||
|
||||
// Dispatch jobs using Laravel's bus with batch processing
|
||||
Bus::chain([
|
||||
function () use ($jobs) {
|
||||
Bus::batch($jobs->toArray())
|
||||
->name('Broken Link Monitoring')
|
||||
->allowFailures()
|
||||
->onQueue('monitoring')
|
||||
->dispatch();
|
||||
}
|
||||
])->dispatch();
|
||||
|
||||
$this->info("Dispatched {$jobs->count()} broken link check job(s).");
|
||||
$this->comment('Jobs are being processed in the queue...');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\CheckSslCertificate;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
|
||||
class MonitorSslCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'monitor:ssl';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check SSL certificates for all enabled sites';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Starting SSL certificate monitoring...');
|
||||
|
||||
// Fetch all sites with monitoring enabled
|
||||
$sites = Site::where('monitoring_enabled', true)->get();
|
||||
|
||||
if ($sites->isEmpty()) {
|
||||
$this->warn('No enabled sites found for SSL monitoring.');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info("Found {$sites->count()} enabled site(s) for SSL monitoring.");
|
||||
|
||||
// Create a batch of jobs to dispatch in parallel
|
||||
$jobs = $sites->map(function (Site $site) {
|
||||
return new CheckSslCertificate($site);
|
||||
});
|
||||
|
||||
// Dispatch jobs using Laravel's bus with batch processing
|
||||
Bus::chain([
|
||||
function () use ($jobs) {
|
||||
Bus::batch($jobs->toArray())
|
||||
->name('SSL Certificate Monitoring')
|
||||
->allowFailures()
|
||||
->onQueue('monitoring')
|
||||
->dispatch();
|
||||
}
|
||||
])->dispatch();
|
||||
|
||||
$this->info("Dispatched {$jobs->count()} SSL certificate check job(s).");
|
||||
$this->comment('Jobs are being processed in the queue...');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\CheckUptime;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
|
||||
class MonitorUptimeCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'monitor:uptime';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check uptime for all enabled sites';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Starting uptime monitoring...');
|
||||
|
||||
// Fetch all sites with monitoring enabled
|
||||
$sites = Site::where('monitoring_enabled', true)->get();
|
||||
|
||||
if ($sites->isEmpty()) {
|
||||
$this->warn('No enabled sites found for monitoring.');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info("Found {$sites->count()} enabled site(s) to monitor.");
|
||||
|
||||
// Create a batch of jobs to dispatch in parallel
|
||||
$jobs = $sites->map(function (Site $site) {
|
||||
return new CheckUptime($site);
|
||||
});
|
||||
|
||||
// Dispatch jobs using Laravel's bus with concurrency limit
|
||||
Bus::chain([
|
||||
function () use ($jobs) {
|
||||
// Using bus batch for parallel processing
|
||||
Bus::batch($jobs->toArray())
|
||||
->name('Uptime Monitoring')
|
||||
->allowFailures()
|
||||
->onQueue('monitoring')
|
||||
->dispatch();
|
||||
}
|
||||
])->dispatch();
|
||||
|
||||
$this->info("Dispatched {$jobs->count()} uptime check job(s).");
|
||||
$this->comment('Jobs are being processed in the queue...');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user