1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "icinga/clusterevents.hpp"
4 #include "icinga/service.hpp"
5 #include "remote/apilistener.hpp"
6 #include "remote/endpoint.hpp"
7 #include "remote/messageorigin.hpp"
8 #include "remote/zone.hpp"
9 #include "remote/apifunction.hpp"
10 #include "remote/eventqueue.hpp"
11 #include "base/application.hpp"
12 #include "base/configtype.hpp"
13 #include "base/utility.hpp"
14 #include "base/perfdatavalue.hpp"
15 #include "base/exception.hpp"
16 #include "base/initialize.hpp"
17 #include "base/serializer.hpp"
18 #include "base/json.hpp"
21 using namespace icinga;
23 INITIALIZE_ONCE(&ClusterEvents::StaticInitialize);
25 REGISTER_APIFUNCTION(CheckResult, event, &ClusterEvents::CheckResultAPIHandler);
26 REGISTER_APIFUNCTION(SetNextCheck, event, &ClusterEvents::NextCheckChangedAPIHandler);
27 REGISTER_APIFUNCTION(SetNextNotification, event, &ClusterEvents::NextNotificationChangedAPIHandler);
28 REGISTER_APIFUNCTION(SetForceNextCheck, event, &ClusterEvents::ForceNextCheckChangedAPIHandler);
29 REGISTER_APIFUNCTION(SetForceNextNotification, event, &ClusterEvents::ForceNextNotificationChangedAPIHandler);
30 REGISTER_APIFUNCTION(SetAcknowledgement, event, &ClusterEvents::AcknowledgementSetAPIHandler);
31 REGISTER_APIFUNCTION(ClearAcknowledgement, event, &ClusterEvents::AcknowledgementClearedAPIHandler);
32 REGISTER_APIFUNCTION(ExecuteCommand, event, &ClusterEvents::ExecuteCommandAPIHandler);
33 REGISTER_APIFUNCTION(SendNotifications, event, &ClusterEvents::SendNotificationsAPIHandler);
34 REGISTER_APIFUNCTION(NotificationSentUser, event, &ClusterEvents::NotificationSentUserAPIHandler);
35 REGISTER_APIFUNCTION(NotificationSentToAllUsers, event, &ClusterEvents::NotificationSentToAllUsersAPIHandler);
37 void ClusterEvents::StaticInitialize()
39 Checkable::OnNewCheckResult.connect(&ClusterEvents::CheckResultHandler);
40 Checkable::OnNextCheckChanged.connect(&ClusterEvents::NextCheckChangedHandler);
41 Notification::OnNextNotificationChanged.connect(&ClusterEvents::NextNotificationChangedHandler);
42 Checkable::OnForceNextCheckChanged.connect(&ClusterEvents::ForceNextCheckChangedHandler);
43 Checkable::OnForceNextNotificationChanged.connect(&ClusterEvents::ForceNextNotificationChangedHandler);
44 Checkable::OnNotificationsRequested.connect(&ClusterEvents::SendNotificationsHandler);
45 Checkable::OnNotificationSentToUser.connect(&ClusterEvents::NotificationSentUserHandler);
46 Checkable::OnNotificationSentToAllUsers.connect(&ClusterEvents::NotificationSentToAllUsersHandler);
48 Checkable::OnAcknowledgementSet.connect(&ClusterEvents::AcknowledgementSetHandler);
49 Checkable::OnAcknowledgementCleared.connect(&ClusterEvents::AcknowledgementClearedHandler);
52 Dictionary::Ptr ClusterEvents::MakeCheckResultMessage(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr)
54 Dictionary::Ptr message = new Dictionary();
55 message->Set("jsonrpc", "2.0");
56 message->Set("method", "event::CheckResult");
60 tie(host, service) = GetHostService(checkable);
62 Dictionary::Ptr params = new Dictionary();
63 params->Set("host", host->GetName());
65 params->Set("service", service->GetShortName());
67 Value agent_service_name = checkable->GetExtension("agent_service_name");
69 if (!agent_service_name.IsEmpty())
70 params->Set("service", agent_service_name);
72 params->Set("cr", Serialize(cr));
74 message->Set("params", params);
79 void ClusterEvents::CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const MessageOrigin::Ptr& origin)
81 ApiListener::Ptr listener = ApiListener::GetInstance();
86 Dictionary::Ptr message = MakeCheckResultMessage(checkable, cr);
87 listener->RelayMessage(origin, checkable, message, true);
90 Value ClusterEvents::CheckResultAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
92 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
95 Log(LogNotice, "ClusterEvents")
96 << "Discarding 'check result' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
103 if (params->Contains("cr")) {
104 cr = new CheckResult();
105 Dictionary::Ptr vcr = params->Get("cr");
107 if (vcr && vcr->Contains("performance_data")) {
108 vperf = vcr->Get("performance_data");
111 vcr->Remove("performance_data");
113 Deserialize(cr, vcr, true);
123 ObjectLock olock(vperf);
124 for (const Value& vp : vperf) {
127 if (vp.IsObjectType<Dictionary>()) {
128 PerfdataValue::Ptr val = new PerfdataValue();
129 Deserialize(val, vp, true);
130 rperf.push_back(val);
136 cr->SetPerformanceData(new Array(std::move(rperf)));
138 Host::Ptr host = Host::GetByName(params->Get("host"));
143 Checkable::Ptr checkable;
145 if (params->Contains("service"))
146 checkable = host->GetServiceByShortName(params->Get("service"));
153 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable) && endpoint != checkable->GetCommandEndpoint()) {
154 Log(LogNotice, "ClusterEvents")
155 << "Discarding 'check result' message for checkable '" << checkable->GetName()
156 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
160 if (!checkable->IsPaused() && Zone::GetLocalZone() == checkable->GetZone() && endpoint == checkable->GetCommandEndpoint())
161 checkable->ProcessCheckResult(cr);
163 checkable->ProcessCheckResult(cr, origin);
168 void ClusterEvents::NextCheckChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
170 ApiListener::Ptr listener = ApiListener::GetInstance();
176 Service::Ptr service;
177 tie(host, service) = GetHostService(checkable);
179 Dictionary::Ptr params = new Dictionary();
180 params->Set("host", host->GetName());
182 params->Set("service", service->GetShortName());
183 params->Set("next_check", checkable->GetNextCheck());
185 Dictionary::Ptr message = new Dictionary();
186 message->Set("jsonrpc", "2.0");
187 message->Set("method", "event::SetNextCheck");
188 message->Set("params", params);
190 listener->RelayMessage(origin, checkable, message, true);
193 Value ClusterEvents::NextCheckChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
195 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
198 Log(LogNotice, "ClusterEvents")
199 << "Discarding 'next check changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
203 Host::Ptr host = Host::GetByName(params->Get("host"));
208 Checkable::Ptr checkable;
210 if (params->Contains("service"))
211 checkable = host->GetServiceByShortName(params->Get("service"));
218 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
219 Log(LogNotice, "ClusterEvents")
220 << "Discarding 'next check changed' message for checkable '" << checkable->GetName()
221 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
225 double nextCheck = params->Get("next_check");
227 if (nextCheck < Application::GetStartTime() + 60)
230 checkable->SetNextCheck(params->Get("next_check"), false, origin);
235 void ClusterEvents::NextNotificationChangedHandler(const Notification::Ptr& notification, const MessageOrigin::Ptr& origin)
237 ApiListener::Ptr listener = ApiListener::GetInstance();
242 Dictionary::Ptr params = new Dictionary();
243 params->Set("notification", notification->GetName());
244 params->Set("next_notification", notification->GetNextNotification());
246 Dictionary::Ptr message = new Dictionary();
247 message->Set("jsonrpc", "2.0");
248 message->Set("method", "event::SetNextNotification");
249 message->Set("params", params);
251 listener->RelayMessage(origin, notification, message, true);
254 Value ClusterEvents::NextNotificationChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
256 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
259 Log(LogNotice, "ClusterEvents")
260 << "Discarding 'next notification changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
264 Notification::Ptr notification = Notification::GetByName(params->Get("notification"));
269 if (origin->FromZone && !origin->FromZone->CanAccessObject(notification)) {
270 Log(LogNotice, "ClusterEvents")
271 << "Discarding 'next notification changed' message for notification '" << notification->GetName()
272 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
276 double nextNotification = params->Get("next_notification");
278 if (nextNotification < Utility::GetTime())
281 notification->SetNextNotification(nextNotification, false, origin);
286 void ClusterEvents::ForceNextCheckChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
288 ApiListener::Ptr listener = ApiListener::GetInstance();
294 Service::Ptr service;
295 tie(host, service) = GetHostService(checkable);
297 Dictionary::Ptr params = new Dictionary();
298 params->Set("host", host->GetName());
300 params->Set("service", service->GetShortName());
301 params->Set("forced", checkable->GetForceNextCheck());
303 Dictionary::Ptr message = new Dictionary();
304 message->Set("jsonrpc", "2.0");
305 message->Set("method", "event::SetForceNextCheck");
306 message->Set("params", params);
308 listener->RelayMessage(origin, checkable, message, true);
311 Value ClusterEvents::ForceNextCheckChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
313 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
316 Log(LogNotice, "ClusterEvents")
317 << "Discarding 'force next check changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
321 Host::Ptr host = Host::GetByName(params->Get("host"));
326 Checkable::Ptr checkable;
328 if (params->Contains("service"))
329 checkable = host->GetServiceByShortName(params->Get("service"));
336 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
337 Log(LogNotice, "ClusterEvents")
338 << "Discarding 'force next check' message for checkable '" << checkable->GetName()
339 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
343 checkable->SetForceNextCheck(params->Get("forced"), false, origin);
348 void ClusterEvents::ForceNextNotificationChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
350 ApiListener::Ptr listener = ApiListener::GetInstance();
356 Service::Ptr service;
357 tie(host, service) = GetHostService(checkable);
359 Dictionary::Ptr params = new Dictionary();
360 params->Set("host", host->GetName());
362 params->Set("service", service->GetShortName());
363 params->Set("forced", checkable->GetForceNextNotification());
365 Dictionary::Ptr message = new Dictionary();
366 message->Set("jsonrpc", "2.0");
367 message->Set("method", "event::SetForceNextNotification");
368 message->Set("params", params);
370 listener->RelayMessage(origin, checkable, message, true);
373 Value ClusterEvents::ForceNextNotificationChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
375 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
378 Log(LogNotice, "ClusterEvents")
379 << "Discarding 'force next notification changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
383 Host::Ptr host = Host::GetByName(params->Get("host"));
388 Checkable::Ptr checkable;
390 if (params->Contains("service"))
391 checkable = host->GetServiceByShortName(params->Get("service"));
398 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
399 Log(LogNotice, "ClusterEvents")
400 << "Discarding 'force next notification' message for checkable '" << checkable->GetName()
401 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
405 checkable->SetForceNextNotification(params->Get("forced"), false, origin);
410 void ClusterEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable,
411 const String& author, const String& comment, AcknowledgementType type,
412 bool notify, bool persistent, double expiry, const MessageOrigin::Ptr& origin)
414 ApiListener::Ptr listener = ApiListener::GetInstance();
420 Service::Ptr service;
421 tie(host, service) = GetHostService(checkable);
423 Dictionary::Ptr params = new Dictionary();
424 params->Set("host", host->GetName());
426 params->Set("service", service->GetShortName());
427 params->Set("author", author);
428 params->Set("comment", comment);
429 params->Set("acktype", type);
430 params->Set("notify", notify);
431 params->Set("persistent", persistent);
432 params->Set("expiry", expiry);
434 Dictionary::Ptr message = new Dictionary();
435 message->Set("jsonrpc", "2.0");
436 message->Set("method", "event::SetAcknowledgement");
437 message->Set("params", params);
439 listener->RelayMessage(origin, checkable, message, true);
442 Value ClusterEvents::AcknowledgementSetAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
444 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
447 Log(LogNotice, "ClusterEvents")
448 << "Discarding 'acknowledgement set' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
452 Host::Ptr host = Host::GetByName(params->Get("host"));
457 Checkable::Ptr checkable;
459 if (params->Contains("service"))
460 checkable = host->GetServiceByShortName(params->Get("service"));
467 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
468 Log(LogNotice, "ClusterEvents")
469 << "Discarding 'acknowledgement set' message for checkable '" << checkable->GetName()
470 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
474 checkable->AcknowledgeProblem(params->Get("author"), params->Get("comment"),
475 static_cast<AcknowledgementType>(static_cast<int>(params->Get("acktype"))),
476 params->Get("notify"), params->Get("persistent"), params->Get("expiry"), origin);
481 void ClusterEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
483 ApiListener::Ptr listener = ApiListener::GetInstance();
489 Service::Ptr service;
490 tie(host, service) = GetHostService(checkable);
492 Dictionary::Ptr params = new Dictionary();
493 params->Set("host", host->GetName());
495 params->Set("service", service->GetShortName());
497 Dictionary::Ptr message = new Dictionary();
498 message->Set("jsonrpc", "2.0");
499 message->Set("method", "event::ClearAcknowledgement");
500 message->Set("params", params);
502 listener->RelayMessage(origin, checkable, message, true);
505 Value ClusterEvents::AcknowledgementClearedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
507 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
510 Log(LogNotice, "ClusterEvents")
511 << "Discarding 'acknowledgement cleared' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
515 Host::Ptr host = Host::GetByName(params->Get("host"));
520 Checkable::Ptr checkable;
522 if (params->Contains("service"))
523 checkable = host->GetServiceByShortName(params->Get("service"));
530 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
531 Log(LogNotice, "ClusterEvents")
532 << "Discarding 'acknowledgement cleared' message for checkable '" << checkable->GetName()
533 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
537 checkable->ClearAcknowledgement(origin);
542 Value ClusterEvents::ExecuteCommandAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
544 EnqueueCheck(origin, params);
549 void ClusterEvents::SendNotificationsHandler(const Checkable::Ptr& checkable, NotificationType type,
550 const CheckResult::Ptr& cr, const String& author, const String& text, const MessageOrigin::Ptr& origin)
552 ApiListener::Ptr listener = ApiListener::GetInstance();
557 Dictionary::Ptr message = MakeCheckResultMessage(checkable, cr);
558 message->Set("method", "event::SendNotifications");
560 Dictionary::Ptr params = message->Get("params");
561 params->Set("type", type);
562 params->Set("author", author);
563 params->Set("text", text);
565 listener->RelayMessage(origin, nullptr, message, true);
568 Value ClusterEvents::SendNotificationsAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
570 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
573 Log(LogNotice, "ClusterEvents")
574 << "Discarding 'send notification' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
578 Host::Ptr host = Host::GetByName(params->Get("host"));
583 Checkable::Ptr checkable;
585 if (params->Contains("service"))
586 checkable = host->GetServiceByShortName(params->Get("service"));
593 if (origin->FromZone && origin->FromZone != Zone::GetLocalZone()) {
594 Log(LogNotice, "ClusterEvents")
595 << "Discarding 'send custom notification' message for checkable '" << checkable->GetName()
596 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
603 if (params->Contains("cr")) {
604 cr = new CheckResult();
605 Dictionary::Ptr vcr = params->Get("cr");
607 if (vcr && vcr->Contains("performance_data")) {
608 vperf = vcr->Get("performance_data");
611 vcr->Remove("performance_data");
613 Deserialize(cr, vcr, true);
617 NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
618 String author = params->Get("author");
619 String text = params->Get("text");
621 Checkable::OnNotificationsRequested(checkable, type, cr, author, text, origin);
626 void ClusterEvents::NotificationSentUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
627 NotificationType notificationType, const CheckResult::Ptr& cr, const String& author, const String& commentText, const String& command,
628 const MessageOrigin::Ptr& origin)
630 ApiListener::Ptr listener = ApiListener::GetInstance();
636 Service::Ptr service;
637 tie(host, service) = GetHostService(checkable);
639 Dictionary::Ptr params = new Dictionary();
640 params->Set("host", host->GetName());
642 params->Set("service", service->GetShortName());
643 params->Set("notification", notification->GetName());
644 params->Set("user", user->GetName());
645 params->Set("type", notificationType);
646 params->Set("cr", Serialize(cr));
647 params->Set("author", author);
648 params->Set("text", commentText);
649 params->Set("command", command);
651 Dictionary::Ptr message = new Dictionary();
652 message->Set("jsonrpc", "2.0");
653 message->Set("method", "event::NotificationSentUser");
654 message->Set("params", params);
656 listener->RelayMessage(origin, nullptr, message, true);
659 Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
661 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
664 Log(LogNotice, "ClusterEvents")
665 << "Discarding 'sent notification to user' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
669 Host::Ptr host = Host::GetByName(params->Get("host"));
674 Checkable::Ptr checkable;
676 if (params->Contains("service"))
677 checkable = host->GetServiceByShortName(params->Get("service"));
684 if (origin->FromZone && origin->FromZone != Zone::GetLocalZone()) {
685 Log(LogNotice, "ClusterEvents")
686 << "Discarding 'send notification to user' message for checkable '" << checkable->GetName()
687 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
694 if (params->Contains("cr")) {
695 cr = new CheckResult();
696 Dictionary::Ptr vcr = params->Get("cr");
698 if (vcr && vcr->Contains("performance_data")) {
699 vperf = vcr->Get("performance_data");
702 vcr->Remove("performance_data");
704 Deserialize(cr, vcr, true);
708 NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
709 String author = params->Get("author");
710 String text = params->Get("text");
712 Notification::Ptr notification = Notification::GetByName(params->Get("notification"));
717 User::Ptr user = User::GetByName(params->Get("user"));
722 String command = params->Get("command");
724 Checkable::OnNotificationSentToUser(notification, checkable, user, type, cr, author, text, command, origin);
729 void ClusterEvents::NotificationSentToAllUsersHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
730 NotificationType notificationType, const CheckResult::Ptr& cr, const String& author, const String& commentText, const MessageOrigin::Ptr& origin)
732 ApiListener::Ptr listener = ApiListener::GetInstance();
738 Service::Ptr service;
739 tie(host, service) = GetHostService(checkable);
741 Dictionary::Ptr params = new Dictionary();
742 params->Set("host", host->GetName());
744 params->Set("service", service->GetShortName());
745 params->Set("notification", notification->GetName());
748 for (const User::Ptr& user : users) {
749 ausers.push_back(user->GetName());
751 params->Set("users", new Array(std::move(ausers)));
753 params->Set("type", notificationType);
754 params->Set("cr", Serialize(cr));
755 params->Set("author", author);
756 params->Set("text", commentText);
758 params->Set("last_notification", notification->GetLastNotification());
759 params->Set("next_notification", notification->GetNextNotification());
760 params->Set("notification_number", notification->GetNotificationNumber());
761 params->Set("last_problem_notification", notification->GetLastProblemNotification());
762 params->Set("no_more_notifications", notification->GetNoMoreNotifications());
764 Dictionary::Ptr message = new Dictionary();
765 message->Set("jsonrpc", "2.0");
766 message->Set("method", "event::NotificationSentToAllUsers");
767 message->Set("params", params);
769 listener->RelayMessage(origin, nullptr, message, true);
772 Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
774 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
777 Log(LogNotice, "ClusterEvents")
778 << "Discarding 'sent notification to all users' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
782 Host::Ptr host = Host::GetByName(params->Get("host"));
787 Checkable::Ptr checkable;
789 if (params->Contains("service"))
790 checkable = host->GetServiceByShortName(params->Get("service"));
797 if (origin->FromZone && origin->FromZone != Zone::GetLocalZone()) {
798 Log(LogNotice, "ClusterEvents")
799 << "Discarding 'sent notification to all users' message for checkable '" << checkable->GetName()
800 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
807 if (params->Contains("cr")) {
808 cr = new CheckResult();
809 Dictionary::Ptr vcr = params->Get("cr");
811 if (vcr && vcr->Contains("performance_data")) {
812 vperf = vcr->Get("performance_data");
815 vcr->Remove("performance_data");
817 Deserialize(cr, vcr, true);
821 NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
822 String author = params->Get("author");
823 String text = params->Get("text");
825 Notification::Ptr notification = Notification::GetByName(params->Get("notification"));
830 Array::Ptr ausers = params->Get("users");
835 std::set<User::Ptr> users;
838 ObjectLock olock(ausers);
839 for (const String& auser : ausers) {
840 User::Ptr user = User::GetByName(auser);
849 notification->SetLastNotification(params->Get("last_notification"));
850 notification->SetNextNotification(params->Get("next_notification"));
851 notification->SetNotificationNumber(params->Get("notification_number"));
852 notification->SetLastProblemNotification(params->Get("last_problem_notification"));
853 notification->SetNoMoreNotifications(params->Get("no_more_notifications"));
855 ArrayData notifiedProblemUsers;
856 for (const User::Ptr& user : users) {
857 notifiedProblemUsers.push_back(user->GetName());
860 notification->SetNotifiedProblemUsers(new Array(std::move(notifiedProblemUsers)));
862 Checkable::OnNotificationSentToAllUsers(notification, checkable, users, type, cr, author, text, origin);