mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -43,7 +43,8 @@ class PingCheck implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
private $process;
|
private $command;
|
||||||
|
private $wait;
|
||||||
private $rrd_tags;
|
private $rrd_tags;
|
||||||
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection List of devices keyed by hostname */
|
/** @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
|
$timeout = Config::get('fping_options.timeout', 500); // must be smaller than period
|
||||||
$retries = Config::get('fping_options.retries', 2); // how many retries on failure
|
$retries = Config::get('fping_options.retries', 2); // how many retries on failure
|
||||||
|
|
||||||
$cmd = ['fping', '-f', '-', '-e', '-t', $timeout, '-r', $retries];
|
$this->command = ['fping', '-f', '-', '-e', '-t', $timeout, '-r', $retries];
|
||||||
|
$this->wait = Config::get('rrd.step', 300) * 2;
|
||||||
$wait = Config::get('rrd.step', 300) * 2;
|
|
||||||
|
|
||||||
$this->process = new Process($cmd, null, null, null, $wait);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +96,9 @@ class PingCheck implements ShouldQueue
|
|||||||
|
|
||||||
$this->fetchDevices();
|
$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
|
// send hostnames to stdin to avoid overflowing cli length limits
|
||||||
$ordered_device_list = $this->tiered->get(1, collect())->keys()// root nodes before standalone nodes
|
$ordered_device_list = $this->tiered->get(1, collect())->keys()// root nodes before standalone nodes
|
||||||
@@ -106,10 +106,10 @@ class PingCheck implements ShouldQueue
|
|||||||
->unique()
|
->unique()
|
||||||
->implode(PHP_EOL);
|
->implode(PHP_EOL);
|
||||||
|
|
||||||
$this->process->setInput($ordered_device_list);
|
$process->setInput($ordered_device_list);
|
||||||
$this->process->start(); // start as early as possible
|
$process->start(); // start as early as possible
|
||||||
|
|
||||||
foreach ($this->process as $type => $line) {
|
foreach ($process as $type => $line) {
|
||||||
d_echo($line);
|
d_echo($line);
|
||||||
|
|
||||||
if (Process::ERR === $type) {
|
if (Process::ERR === $type) {
|
||||||
|
Reference in New Issue
Block a user