RegisterAttribute("notification_period", Attribute_Config, &m_NotificationPeriod);
RegisterAttribute("last_notification", Attribute_Replicated, &m_LastNotification);
RegisterAttribute("next_notification", Attribute_Replicated, &m_NextNotification);
+ RegisterAttribute("notification_number", Attribute_Replicated, &m_NotificationNumber);
RegisterAttribute("macros", Attribute_Config, &m_Macros);
RegisterAttribute("users", Attribute_Config, &m_Users);
RegisterAttribute("groups", Attribute_Config, &m_Groups);
Touch("next_notification");
}
+int Notification::GetNotificationNumber(void) const
+{
+ if (m_NotificationNumber.IsEmpty())
+ return 0;
+ else
+ return m_NotificationNumber;
+}
+
+void Notification::UpdateNotificationNumber(void)
+{
+ m_NotificationNumber = m_NotificationNumber + 1;
+ Touch("notification_number");
+}
+
+void Notification::ResetNotificationNumber(void)
+{
+ m_NotificationNumber = 0;
+ Touch("notification_number");
+}
+
String Notification::NotificationTypeToString(NotificationType type)
{
switch (type) {
try {
GetNotificationCommand()->Execute(GetSelf(), user, cr, type);
+ {
+ ObjectLock olock(this);
+ UpdateNotificationNumber();
+ }
+
RequestMessage rm;
rm.SetMethod("icinga::NotificationSent");
double GetNextNotification(void) const;
void SetNextNotification(double time);
+ int GetNotificationNumber(void) const;
+ void UpdateNotificationNumber(void);
+ void ResetNotificationNumber(void);
+
void BeginExecuteNotification(NotificationType type, const Dictionary::Ptr& cr, bool force, const String& author = "", const String& text = "");
static String NotificationTypeToString(NotificationType type);
Attribute<String> m_NotificationPeriod;
Attribute<double> m_LastNotification;
Attribute<double> m_NextNotification;
+ Attribute<int> m_NotificationNumber;
Attribute<Dictionary::Ptr> m_Macros;
Attribute<Array::Ptr> m_ExportMacros;
Attribute<Array::Ptr> m_Users;
Attribute<String> m_HostName;
Attribute<String> m_Service;
+
void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const Dictionary::Ptr& cr, bool force, const String& author = "", const String& text = "");
};
attempt = 1;
recovery = true;
+ ResetNotificationNumbers();
} else {
if (old_attempt >= GetMaxCheckAttempts()) {
SetStateType(StateTypeHard);
boost::signals2::signal<void (const Service::Ptr&, const String&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationSentChanged;
+void Service::ResetNotificationNumbers(void)
+{
+ BOOST_FOREACH(const Notification::Ptr& notification, GetNotifications()) {
+ ObjectLock olock(notification);
+ notification->ResetNotificationNumber();
+ }
+}
+
void Service::NotificationSentRequestHandler(const RequestMessage& request)
{
NotificationMessage params;
void SetForceNextNotification(bool force);
bool GetForceNextNotification(void) const;
+ void ResetNotificationNumbers(void);
+
static void InvalidateNotificationsCache(void);
void UpdateSlaveNotifications(void);