diff --git a/app/Jobs/PingCheck.php b/app/Jobs/PingCheck.php index 78f61f5525..1ceb7fee5d 100644 --- a/app/Jobs/PingCheck.php +++ b/app/Jobs/PingCheck.php @@ -43,7 +43,8 @@ class PingCheck implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - private $process; + private $command; + private $wait; private $rrd_tags; /** @var \Illuminate\Database\Eloquent\Collection List of devices keyed by hostname */ @@ -80,11 +81,8 @@ class PingCheck implements ShouldQueue $timeout = Config::get('fping_options.timeout', 500); // must be smaller than period $retries = Config::get('fping_options.retries', 2); // how many retries on failure - $cmd = ['fping', '-f', '-', '-e', '-t', $timeout, '-r', $retries]; - - $wait = Config::get('rrd.step', 300) * 2; - - $this->process = new Process($cmd, null, null, null, $wait); + $this->command = ['fping', '-f', '-', '-e', '-t', $timeout, '-r', $retries]; + $this->wait = Config::get('rrd.step', 300) * 2; } /** @@ -98,7 +96,9 @@ class PingCheck implements ShouldQueue $this->fetchDevices(); - d_echo($this->process->getCommandLine() . PHP_EOL); + $process = new Process($this->command, null, null, null, $this->wait); + + d_echo($process->getCommandLine() . PHP_EOL); // send hostnames to stdin to avoid overflowing cli length limits $ordered_device_list = $this->tiered->get(1, collect())->keys()// root nodes before standalone nodes @@ -106,10 +106,10 @@ class PingCheck implements ShouldQueue ->unique() ->implode(PHP_EOL); - $this->process->setInput($ordered_device_list); - $this->process->start(); // start as early as possible + $process->setInput($ordered_device_list); + $process->start(); // start as early as possible - foreach ($this->process as $type => $line) { + foreach ($process as $type => $line) { d_echo($line); if (Process::ERR === $type) {