monitoring: Reduce error output when transporting a command to a local command file failed

refs #8006
This commit is contained in:
Eric Lippmann 2015-05-28 13:36:00 +02:00
parent 1a51368a76
commit a4a1a296d1
1 changed files with 8 additions and 3 deletions

View File

@ -4,6 +4,7 @@
namespace Icinga\Module\Monitoring\Command\Transport; namespace Icinga\Module\Monitoring\Command\Transport;
use Exception; use Exception;
use RuntimeException;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;
use Icinga\Module\Monitoring\Command\Exception\TransportException; use Icinga\Module\Monitoring\Command\Exception\TransportException;
@ -123,11 +124,15 @@ class LocalCommandFile implements CommandTransportInterface
$file->fwrite($commandString . "\n"); $file->fwrite($commandString . "\n");
$file->fflush(); $file->fflush();
} catch (Exception $e) { } catch (Exception $e) {
$message = $e->getMessage();
if ($e instanceof RuntimeException && ($pos = strrpos($message, ':')) !== false) {
// Assume RuntimeException thrown by SplFileObject in the format: __METHOD__ . "({$filename}): Message"
$message = substr($message, $pos + 1);
}
throw new TransportException( throw new TransportException(
'Can\'t send external Icinga command "%s" to the local command file "%s": %s', 'Can\'t send external Icinga command to the local command file "%s": %s',
$commandString,
$this->path, $this->path,
$e $message
); );
} }
} }