Fix Fast Ping (#12509)

Recent Laravel version update broke ping.php by now serializing the PingCheck job.
Store process parameters instead of process object.
This commit is contained in:
Tony Murray 2021-02-08 10:18:02 -06:00 committed by GitHub
parent ee1606d799
commit aa7fa09c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -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) {