Merge pull request #3533 from Icinga/feature/command-audit

Add command audit
This commit is contained in:
Johannes Meyer 2018-07-19 09:03:13 +02:00 committed by GitHub
commit 0464bc4fde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Monitoring\Command\Transport; namespace Icinga\Module\Monitoring\Command\Transport;
use Icinga\Application\Hook\AuditHook;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Exception\Json\JsonDecodeException; use Icinga\Exception\Json\JsonDecodeException;
use Icinga\Module\Monitoring\Command\IcingaApiCommand; use Icinga\Module\Monitoring\Command\IcingaApiCommand;
@ -196,6 +197,18 @@ class ApiCommandTransport implements CommandTransportInterface
$this->getPort() $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 { try {
$response = RestRequest::post($this->getUriFor($command->getEndpoint())) $response = RestRequest::post($this->getUriFor($command->getEndpoint()))
->authenticateWith($this->getUsername(), $this->getPassword()) ->authenticateWith($this->getUsername(), $this->getPassword())