mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
notifications: Add OnNotificationSentToAllUsers signal.
This commit is contained in:
parent
83a06b4378
commit
d4295cb3a4
@ -52,7 +52,7 @@ void CompatLog::Start(void)
|
|||||||
DynamicObject::Start();
|
DynamicObject::Start();
|
||||||
|
|
||||||
Service::OnNewCheckResult.connect(bind(&CompatLog::CheckResultHandler, this, _1, _2));
|
Service::OnNewCheckResult.connect(bind(&CompatLog::CheckResultHandler, this, _1, _2));
|
||||||
Service::OnNotificationSentChanged.connect(bind(&CompatLog::NotificationSentHandler, this, _1, _2, _3, _4, _5, _6));
|
Service::OnNotificationSentToUser.connect(bind(&CompatLog::NotificationSentHandler, this, _1, _2, _3, _4, _5, _6));
|
||||||
Service::OnFlappingChanged.connect(bind(&CompatLog::FlappingHandler, this, _1, _2));
|
Service::OnFlappingChanged.connect(bind(&CompatLog::FlappingHandler, this, _1, _2));
|
||||||
Service::OnDowntimeTriggered.connect(boost::bind(&CompatLog::TriggerDowntimeHandler, this, _1, _2));
|
Service::OnDowntimeTriggered.connect(boost::bind(&CompatLog::TriggerDowntimeHandler, this, _1, _2));
|
||||||
Service::OnDowntimeRemoved.connect(boost::bind(&CompatLog::RemoveDowntimeHandler, this, _1, _2));
|
Service::OnDowntimeRemoved.connect(boost::bind(&CompatLog::RemoveDowntimeHandler, this, _1, _2));
|
||||||
|
@ -296,10 +296,14 @@ void Notification::BeginExecuteNotification(NotificationType type, const Diction
|
|||||||
std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin()));
|
std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long notified_users = 0;
|
||||||
BOOST_FOREACH(const User::Ptr& user, allUsers) {
|
BOOST_FOREACH(const User::Ptr& user, allUsers) {
|
||||||
Log(LogDebug, "icinga", "Sending notification for user '" + user->GetName() + "'");
|
Log(LogDebug, "icinga", "Sending notification for user '" + user->GetName() + "'");
|
||||||
Utility::QueueAsyncCallback(boost::bind(&Notification::ExecuteNotificationHelper, this, type, user, cr, force, author, text));
|
Utility::QueueAsyncCallback(boost::bind(&Notification::ExecuteNotificationHelper, this, type, user, cr, force, author, text));
|
||||||
|
notified_users++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Service::OnNotificationSentToAllUsers(GetService(), allUsers, type, cr, author, text, notified_users);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const Dictionary::Ptr& cr, bool force, const String& author, const String& text)
|
void Notification::ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const Dictionary::Ptr& cr, bool force, const String& author, const String& text)
|
||||||
@ -333,6 +337,11 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
NotificationCommand::Ptr notificationCommand = GetNotificationCommand();
|
||||||
|
|
||||||
|
if (!notificationCommand)
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Notification command for notification object '" + GetName() + " and user '" + user->GetName() + "' does not exist."));
|
||||||
|
|
||||||
GetNotificationCommand()->Execute(GetSelf(), user, cr, type);
|
GetNotificationCommand()->Execute(GetSelf(), user, cr, type);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -341,7 +350,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
|
|||||||
SetLastNotification(Utility::GetTime());
|
SetLastNotification(Utility::GetTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
Service::OnNotificationSentChanged(GetService(), user, type, cr, author, text);
|
Service::OnNotificationSentToUser(GetService(), user, type, cr, author, text);
|
||||||
|
|
||||||
Log(LogInformation, "icinga", "Completed sending notification for service '" + GetService()->GetName() + "'");
|
Log(LogInformation, "icinga", "Completed sending notification for service '" + GetService()->GetName() + "'");
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
boost::signals2::signal<void (const Service::Ptr&, const User::Ptr&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationSentChanged;
|
boost::signals2::signal<void (const Service::Ptr&, const std::set<User::Ptr>&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&, unsigned long)> Service::OnNotificationSentToAllUsers;
|
||||||
|
boost::signals2::signal<void (const Service::Ptr&, const User::Ptr&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationSentToUser;
|
||||||
|
|
||||||
Dictionary::Ptr Service::GetNotificationDescriptions(void) const
|
Dictionary::Ptr Service::GetNotificationDescriptions(void) const
|
||||||
{
|
{
|
||||||
|
@ -239,7 +239,8 @@ public:
|
|||||||
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnableFlappingChanged;
|
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnableFlappingChanged;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnNewCheckResult;
|
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnNewCheckResult;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, NotificationType, const Dictionary::Ptr&, const String&, const String&)> OnNotificationsRequested;
|
static boost::signals2::signal<void (const Service::Ptr&, NotificationType, const Dictionary::Ptr&, const String&, const String&)> OnNotificationsRequested;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const User::Ptr&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> OnNotificationSentChanged;
|
static boost::signals2::signal<void (const Service::Ptr&, const User::Ptr&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> OnNotificationSentToUser;
|
||||||
|
static boost::signals2::signal<void (const Service::Ptr&, const std::set<User::Ptr>&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&, unsigned long)> OnNotificationSentToAllUsers;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnCommentAdded;
|
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnCommentAdded;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnCommentRemoved;
|
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnCommentRemoved;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnDowntimeAdded;
|
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnDowntimeAdded;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user