metricsService = $metricsService; } /** * Execute the console command. */ public function handle(): int { try { if ($this->option('cleanup')) { $this->info('Cleaning up old metrics...'); $deleted = $this->metricsService->cleanupOldMetrics(); $this->info("Deleted {$deleted} old metric records."); } $this->info('Collecting system metrics...'); $this->metricsService->collectMetrics(); $this->info('System metrics collected successfully.'); return Command::SUCCESS; } catch (\Exception $e) { $this->error('Failed to collect system metrics: '.$e->getMessage()); return Command::FAILURE; } } }