addArgument('device spec', InputArgument::REQUIRED); } /** * Execute the console command. * * @return int */ public function handle(): int { $spec = $this->argument('device spec'); $devices = Device::query()->when($spec !== 'all', function (Builder $query) use ($spec) { /** @phpstan-var Builder $query */ return $query->where('device_id', $spec) ->orWhere('hostname', $spec) ->limit(1); })->get(); if ($devices->isEmpty()) { $devices = [new Device(['hostname' => $spec])]; } Config::set('icmp_check', true); // ignore icmp disabled, this is an explicit user action /** @var Device $device */ foreach ($devices as $device) { $helper = new ConnectivityHelper($device); $response = $helper->isPingable(); $this->line($device->displayName() . ' : ' . ($response->wasSkipped() ? 'skipped' : $response)); } return 0; } }