Merge pull request #3533 from Icinga/feature/command-audit
Add command audit
This commit is contained in:
commit
0464bc4fde
|
@ -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())
|
||||||
|
|
Loading…
Reference in New Issue