mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
parent
0054e78a58
commit
f73d69691b
@ -319,6 +319,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
|
|||||||
Service::OnNotificationSendStart(this, checkable, allUsers, type, cr, author, text);
|
Service::OnNotificationSendStart(this, checkable, allUsers, type, cr, author, text);
|
||||||
|
|
||||||
std::set<User::Ptr> allNotifiedUsers;
|
std::set<User::Ptr> allNotifiedUsers;
|
||||||
|
Array::Ptr notifiedUsers = GetNotifiedUsers();
|
||||||
|
|
||||||
BOOST_FOREACH(const User::Ptr& user, allUsers) {
|
BOOST_FOREACH(const User::Ptr& user, allUsers) {
|
||||||
String userName = user->GetName();
|
String userName = user->GetName();
|
||||||
@ -337,7 +338,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
|
|||||||
|
|
||||||
/* on recovery, check if user was notified before */
|
/* on recovery, check if user was notified before */
|
||||||
if (type == NotificationRecovery) {
|
if (type == NotificationRecovery) {
|
||||||
if (m_NotifiedUsers.find(userName) == m_NotifiedUsers.end()) {
|
if (!notifiedUsers->Contains(userName)) {
|
||||||
Log(LogNotice, "Notification")
|
Log(LogNotice, "Notification")
|
||||||
<< "We did not notify user '" << userName << "' before. Not sending recovery notification.";
|
<< "We did not notify user '" << userName << "' before. Not sending recovery notification.";
|
||||||
continue;
|
continue;
|
||||||
@ -353,12 +354,13 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
|
|||||||
allNotifiedUsers.insert(user);
|
allNotifiedUsers.insert(user);
|
||||||
|
|
||||||
/* store all notified users for later recovery checks */
|
/* store all notified users for later recovery checks */
|
||||||
m_NotifiedUsers.insert(userName);
|
if (!notifiedUsers->Contains(userName))
|
||||||
|
notifiedUsers->Add(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if this was a recovery notification, reset all notified users */
|
/* if this was a recovery notification, reset all notified users */
|
||||||
if (type == NotificationRecovery)
|
if (type == NotificationRecovery)
|
||||||
ResetNotifiedUsers();
|
notifiedUsers->Clear();
|
||||||
|
|
||||||
/* used in db_ido for notification history */
|
/* used in db_ido for notification history */
|
||||||
Service::OnNotificationSentToAllUsers(this, checkable, allNotifiedUsers, type, cr, author, text);
|
Service::OnNotificationSentToAllUsers(this, checkable, allNotifiedUsers, type, cr, author, text);
|
||||||
@ -446,11 +448,6 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::ResetNotifiedUsers(void)
|
|
||||||
{
|
|
||||||
m_NotifiedUsers.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
int icinga::ServiceStateToFilter(ServiceState state)
|
int icinga::ServiceStateToFilter(ServiceState state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -98,7 +98,6 @@ public:
|
|||||||
|
|
||||||
bool CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force);
|
bool CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force);
|
||||||
|
|
||||||
void ResetNotifiedUsers(void);
|
|
||||||
Endpoint::Ptr GetCommandEndpoint(void) const;
|
Endpoint::Ptr GetCommandEndpoint(void) const;
|
||||||
|
|
||||||
static String NotificationTypeToString(NotificationType type);
|
static String NotificationTypeToString(NotificationType type);
|
||||||
@ -115,8 +114,6 @@ protected:
|
|||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<String> m_NotifiedUsers;
|
|
||||||
|
|
||||||
void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, bool force, const String& author = "", const String& text = "");
|
void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, bool force, const String& author = "", const String& text = "");
|
||||||
|
|
||||||
static void EvaluateApplyRuleOneInstance(const intrusive_ptr<Checkable>& checkable, const String& name, const Dictionary::Ptr& locals, const ApplyRule& rule);
|
static void EvaluateApplyRuleOneInstance(const intrusive_ptr<Checkable>& checkable, const String& name, const Dictionary::Ptr& locals, const ApplyRule& rule);
|
||||||
|
@ -47,6 +47,10 @@ class Notification : CustomVarObject < NotificationNameComposer
|
|||||||
[config, protected] String host_name;
|
[config, protected] String host_name;
|
||||||
[config, protected] String service_name;
|
[config, protected] String service_name;
|
||||||
|
|
||||||
|
[state] Array::Ptr notified_users {
|
||||||
|
default {{{ return new Array(); }}}
|
||||||
|
};
|
||||||
|
|
||||||
[state] double last_notification;
|
[state] double last_notification;
|
||||||
[state, set_protected] double next_notification (NextNotificationRaw);
|
[state, set_protected] double next_notification (NextNotificationRaw);
|
||||||
[state, set_protected] Value notification_number;
|
[state, set_protected] Value notification_number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user