Notification::Ptr notification = arguments[0];
Dictionary::Ptr macros = arguments[1];
-// NotificationType type = static_cast<NotificationType>(static_cast<int>(arguments[2]));
+ NotificationType type = static_cast<NotificationType>(static_cast<int>(arguments[2]));
Value raw_command = notification->GetNotificationCommand();
if (service)
service_name = service->GetName();
- Value command = MacroProcessor::ResolveMacros(raw_command, macros);
+ Dictionary::Ptr notificationMacros = boost::make_shared<Dictionary>();
+ notificationMacros->Set("NOTIFICATIONTYPE", Notification::NotificationTypeToString(type));
+
+ std::vector<Dictionary::Ptr> macroDicts;
+ macroDicts.push_back(notificationMacros);
+ macroDicts.push_back(macros);
+
+ Dictionary::Ptr allMacros = MacroProcessor::MergeMacroDicts(macroDicts);
+
+ Value command = MacroProcessor::ResolveMacros(raw_command, allMacros);
Process::Ptr process = boost::make_shared<Process>(Process::SplitCommand(command), macros);
Service::UpdateStatistics(cr);
- bool send_notification = hardChange && reachable && !IsInDowntime() && !IsAcknowledged();
+ bool in_downtime = IsInDowntime();
+ bool send_notification = hardChange && reachable && !in_downtime && !IsAcknowledged();
+
+ bool send_downtime_notification = m_LastInDowntime != in_downtime;
+ m_LastInDowntime = in_downtime;
+ Touch("last_in_downtime");
olock.Unlock();
EndpointManager::GetInstance()->SendMulticastMessage(rm);
+ if (send_downtime_notification)
+ RequestNotifications(in_downtime ? NotificationDowntimeStart : NotificationDowntimeEnd, cr);
+
if (send_notification)
RequestNotifications(recovery ? NotificationRecovery : NotificationProblem, cr);
}
if (!downtimes)
return;
- ObjectLock olock(downtimes);
+ std::vector<String> ids;
+
+ {
+ ObjectLock olock(downtimes);
+
+ String id;
+ BOOST_FOREACH(boost::tie(id, boost::tuples::ignore), downtimes) {
+ ids.push_back(id);
+
+ }
+ }
- String id;
- BOOST_FOREACH(boost::tie(id, boost::tuples::ignore), downtimes) {
+ BOOST_FOREACH(const String& id, ids) {
TriggerDowntime(id);
}
}
RegisterAttribute("last_result", Attribute_Replicated, &m_LastResult);
RegisterAttribute("last_state_change", Attribute_Replicated, &m_LastStateChange);
RegisterAttribute("last_hard_state_change", Attribute_Replicated, &m_LastHardStateChange);
+ RegisterAttribute("last_in_downtime", Attribute_Replicated, &m_LastInDowntime);
RegisterAttribute("enable_active_checks", Attribute_Replicated, &m_EnableActiveChecks);
RegisterAttribute("enable_passive_checks", Attribute_Replicated, &m_EnablePassiveChecks);
RegisterAttribute("force_next_check", Attribute_Replicated, &m_ForceNextCheck);
Attribute<Dictionary::Ptr> m_LastResult;
Attribute<double> m_LastStateChange;
Attribute<double> m_LastHardStateChange;
+ Attribute<bool> m_LastInDowntime;
Attribute<bool> m_EnableActiveChecks;
Attribute<bool> m_EnablePassiveChecks;
Attribute<bool> m_ForceNextCheck;