API Event Streams: Add 'command' for Notification events

fixes #6824
This commit is contained in:
Michael Friedrich 2018-12-07 09:37:03 +01:00
parent 75e06e9c0b
commit ba8d79f3c5
2 changed files with 7 additions and 0 deletions

View File

@ -1333,6 +1333,7 @@ Example for all downtime events:
timestamp | Timestamp | Unix timestamp when the event happened. timestamp | Timestamp | Unix timestamp when the event happened.
host | String | [Host](09-object-types.md#objecttype-host) name. host | String | [Host](09-object-types.md#objecttype-host) name.
service | String | [Service](09-object-types.md#objecttype-service) name. Optional if this is a host notification. service | String | [Service](09-object-types.md#objecttype-service) name. Optional if this is a host notification.
command | String | [NotificationCommand](09-object-types.md#objecttype-notificationcommand) name.
users | Array | List of notified [user](09-object-types.md#objecttype-user) names. users | Array | List of notified [user](09-object-types.md#objecttype-user) names.
notification\_type | String | [$notification.type$](03-monitoring-basics.md#notification-runtime-macros) runtime macro value. notification\_type | String | [$notification.type$](03-monitoring-basics.md#notification-runtime-macros) runtime macro value.
author | String | [$notification.author$](03-monitoring-basics.md#notification-runtime-macros) runtime macro value. author | String | [$notification.author$](03-monitoring-basics.md#notification-runtime-macros) runtime macro value.

View File

@ -19,6 +19,7 @@
#include "icinga/apievents.hpp" #include "icinga/apievents.hpp"
#include "icinga/service.hpp" #include "icinga/service.hpp"
#include "icinga/notificationcommand.hpp"
#include "remote/eventqueue.hpp" #include "remote/eventqueue.hpp"
#include "base/initialize.hpp" #include "base/initialize.hpp"
#include "base/serializer.hpp" #include "base/serializer.hpp"
@ -129,6 +130,11 @@ void ApiEvents::NotificationSentToAllUsersHandler(const Notification::Ptr& notif
if (service) if (service)
result->Set("service", service->GetShortName()); result->Set("service", service->GetShortName());
NotificationCommand::Ptr command = notification->GetCommand();
if (command)
result->Set("command", command->GetName());
ArrayData userNames; ArrayData userNames;
for (const User::Ptr& user : users) { for (const User::Ptr& user : users) {