Add command audit

This commit is contained in:
Eric Lippmann 2018-07-19 00:35:28 +02:00
parent 424f687f5d
commit 7f21e14afc
1 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Monitoring\Command\Transport;
use Icinga\Application\Hook\AuditHook;
use Icinga\Application\Logger;
use Icinga\Exception\Json\JsonDecodeException;
use Icinga\Module\Monitoring\Command\IcingaApiCommand;
@ -196,6 +197,18 @@ class ApiCommandTransport implements CommandTransportInterface
$this->getPort()
);
$data = $command->getData();
$payload = [];
foreach ($data as $key => $value) {
$payload[] = "$key=$value";
}
$payload = implode(', ', $payload);
AuditHook::logActivity(
'monitoring/command',
"Issued command {$command->getEndpoint()} with the following payload: $payload",
$data
);
try {
$response = RestRequest::post($this->getUriFor($command->getEndpoint()))
->authenticateWith($this->getUsername(), $this->getPassword())