Ignore settings from instances.ini that don't have a setter on the transport class used
fixes #8543
This commit is contained in:
parent
9f0af662a7
commit
32487e4e21
|
@ -73,7 +73,10 @@ abstract class CommandTransport
|
|||
foreach ($config as $key => $value) {
|
||||
$method = 'set' . ucfirst($key);
|
||||
if (! method_exists($transport, $method)) {
|
||||
throw new ConfigurationError();
|
||||
// Ignore settings from config that don't have a setter on the transport instead of throwing an
|
||||
// exception here because the transport should throw an exception if it's not fully set up
|
||||
// when being about to send a command
|
||||
continue;
|
||||
}
|
||||
$transport->$method($value);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
namespace Icinga\Module\Monitoring\Command\Transport;
|
||||
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Module\Monitoring\Command\Exception\TransportException;
|
||||
use Icinga\Module\Monitoring\Command\IcingaCommand;
|
||||
use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer;
|
||||
|
@ -102,13 +102,15 @@ class LocalCommandFile implements CommandTransportInterface
|
|||
* @param IcingaCommand $command
|
||||
* @param int|null $now
|
||||
*
|
||||
* @throws LogicException
|
||||
* @throws ConfigurationError
|
||||
* @throws TransportException
|
||||
*/
|
||||
public function send(IcingaCommand $command, $now = null)
|
||||
{
|
||||
if (! isset($this->path)) {
|
||||
throw new LogicException('Can\'t send external Icinga Command. Path to the local command file is missing');
|
||||
throw new ConfigurationError(
|
||||
'Can\'t send external Icinga Command. Path to the local command file is missing'
|
||||
);
|
||||
}
|
||||
$commandString = $this->renderer->render($command, $now);
|
||||
Logger::debug(
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Command\Transport;
|
||||
|
||||
use LogicException;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Module\Monitoring\Command\Exception\TransportException;
|
||||
use Icinga\Module\Monitoring\Command\IcingaCommand;
|
||||
use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer;
|
||||
|
@ -166,16 +166,18 @@ class RemoteCommandFile implements CommandTransportInterface
|
|||
* @param IcingaCommand $command
|
||||
* @param int|null $now
|
||||
*
|
||||
* @throws LogicException
|
||||
* @throws ConfigurationError
|
||||
* @throws TransportException
|
||||
*/
|
||||
public function send(IcingaCommand $command, $now = null)
|
||||
{
|
||||
if (! isset($this->path)) {
|
||||
throw new LogicException('Can\'t send external Icinga Command. Path to the remote command file is missing');
|
||||
throw new ConfigurationError(
|
||||
'Can\'t send external Icinga Command. Path to the remote command file is missing'
|
||||
);
|
||||
}
|
||||
if (! isset($this->host)) {
|
||||
throw new LogicException('Can\'t send external Icinga Command. Remote host is missing');
|
||||
throw new ConfigurationError('Can\'t send external Icinga Command. Remote host is missing');
|
||||
}
|
||||
$commandString = $this->renderer->render($command, $now);
|
||||
Logger::debug(
|
||||
|
|
Loading…
Reference in New Issue