mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 14:44:32 +02:00
parent
7ae3a47f0e
commit
112f26dc19
@ -660,7 +660,7 @@ void ClusterListener::SetSecurityInfo(const Dictionary::Ptr& message, const Dyna
|
|||||||
message->Set("security", security);
|
message->Set("security", security);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClusterListener::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr, const String& authority)
|
void ClusterListener::CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr& cr, const String& authority)
|
||||||
{
|
{
|
||||||
if (!authority.IsEmpty() && authority != GetIdentity())
|
if (!authority.IsEmpty() && authority != GetIdentity())
|
||||||
return;
|
return;
|
||||||
@ -1012,7 +1012,7 @@ void ClusterListener::MessageHandler(const Endpoint::Ptr& sender, const Dictiona
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr cr = params->Get("check_result");
|
CheckResult::Ptr cr = params->Get("check_result");
|
||||||
|
|
||||||
if (!cr)
|
if (!cr)
|
||||||
return;
|
return;
|
||||||
|
@ -83,7 +83,7 @@ private:
|
|||||||
Stream::Ptr m_LogFile;
|
Stream::Ptr m_LogFile;
|
||||||
size_t m_LogMessageCount;
|
size_t m_LogMessageCount;
|
||||||
|
|
||||||
void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr, const String& authority);
|
void CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr& cr, const String& authority);
|
||||||
void NextCheckChangedHandler(const Service::Ptr& service, double nextCheck, const String& authority);
|
void NextCheckChangedHandler(const Service::Ptr& service, double nextCheck, const String& authority);
|
||||||
void NextNotificationChangedHandler(const Notification::Ptr& notification, double nextCheck, const String& authority);
|
void NextNotificationChangedHandler(const Notification::Ptr& notification, double nextCheck, const String& authority);
|
||||||
void ForceNextCheckChangedHandler(const Service::Ptr& service, bool forced, const String& authority);
|
void ForceNextCheckChangedHandler(const Service::Ptr& service, bool forced, const String& authority);
|
||||||
|
@ -101,11 +101,10 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(attrs["output"]);
|
CheckResult::Ptr result = PluginUtility::ParseCheckOutput(attrs["output"]);
|
||||||
result->Set("state", PluginUtility::ExitStatusToState(Convert::ToLong(attrs["return_code"])));
|
result->SetState(PluginUtility::ExitStatusToState(Convert::ToLong(attrs["return_code"])));
|
||||||
result->Set("execution_start", Convert::ToDouble(attrs["start_time"]));
|
result->SetExecutionStart(Convert::ToDouble(attrs["start_time"]));
|
||||||
result->Set("execution_end", Convert::ToDouble(attrs["finish_time"]));
|
result->SetExecutionEnd(Convert::ToDouble(attrs["finish_time"]));
|
||||||
result->Set("active", 1);
|
|
||||||
|
|
||||||
service->ProcessCheckResult(result);
|
service->ProcessCheckResult(result);
|
||||||
|
|
||||||
|
@ -72,14 +72,14 @@ void CompatLogger::Start(void)
|
|||||||
/**
|
/**
|
||||||
* @threadsafety Always.
|
* @threadsafety Always.
|
||||||
*/
|
*/
|
||||||
void CompatLogger::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr &cr)
|
void CompatLogger::CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr &cr)
|
||||||
{
|
{
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
if (!host)
|
if (!host)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Dictionary::Ptr vars_after = cr->Get("vars_after");
|
Dictionary::Ptr vars_after = cr->GetVarsAfter();
|
||||||
|
|
||||||
long state_after = vars_after->Get("state");
|
long state_after = vars_after->Get("state");
|
||||||
long stateType_after = vars_after->Get("state_type");
|
long stateType_after = vars_after->Get("state_type");
|
||||||
@ -87,7 +87,7 @@ void CompatLogger::CheckResultHandler(const Service::Ptr& service, const Diction
|
|||||||
bool reachable_after = vars_after->Get("reachable");
|
bool reachable_after = vars_after->Get("reachable");
|
||||||
bool host_reachable_after = vars_after->Get("host_reachable");
|
bool host_reachable_after = vars_after->Get("host_reachable");
|
||||||
|
|
||||||
Dictionary::Ptr vars_before = cr->Get("vars_before");
|
Dictionary::Ptr vars_before = cr->GetVarsBefore();
|
||||||
|
|
||||||
if (vars_before) {
|
if (vars_before) {
|
||||||
long state_before = vars_before->Get("state");
|
long state_before = vars_before->Get("state");
|
||||||
@ -251,8 +251,8 @@ void CompatLogger::RemoveDowntimeHandler(const Service::Ptr& service, const Dict
|
|||||||
* @threadsafety Always.
|
* @threadsafety Always.
|
||||||
*/
|
*/
|
||||||
void CompatLogger::NotificationSentHandler(const Service::Ptr& service, const User::Ptr& user,
|
void CompatLogger::NotificationSentHandler(const Service::Ptr& service, const User::Ptr& user,
|
||||||
NotificationType const& notification_type, Dictionary::Ptr const& cr,
|
NotificationType const& notification_type, CheckResult::Ptr const& cr,
|
||||||
const String& author, const String& comment_text, const String& command_name)
|
const String& author, const String& comment_text, const String& command_name)
|
||||||
{
|
{
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ void CompatLogger::ReopenFile(bool rotate)
|
|||||||
ObjectLock olock(hc);
|
ObjectLock olock(hc);
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
Dictionary::Ptr cr = hc->GetLastCheckResult();
|
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
@ -530,7 +530,7 @@ void CompatLogger::ReopenFile(bool rotate)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
|
@ -52,14 +52,14 @@ private:
|
|||||||
void WriteLine(const String& line);
|
void WriteLine(const String& line);
|
||||||
void Flush(void);
|
void Flush(void);
|
||||||
|
|
||||||
void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr);
|
void CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr& cr);
|
||||||
void DowntimeHandler(const Service::Ptr& service, DowntimeState downtime_state);
|
void DowntimeHandler(const Service::Ptr& service, DowntimeState downtime_state);
|
||||||
void NotificationSentHandler(const Service::Ptr& service, const User::Ptr& user, NotificationType const& notification_type, Dictionary::Ptr const& cr, const String& author, const String& comment_text, const String& command_name);
|
void NotificationSentHandler(const Service::Ptr& service, const User::Ptr& user, NotificationType const& notification_type, CheckResult::Ptr const& cr, const String& author, const String& comment_text, const String& command_name);
|
||||||
void FlappingHandler(const Service::Ptr& service, FlappingState flapping_state);
|
void FlappingHandler(const Service::Ptr& service, FlappingState flapping_state);
|
||||||
void TriggerDowntimeHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
void TriggerDowntimeHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
||||||
void RemoveDowntimeHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
void RemoveDowntimeHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
||||||
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
|
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
|
||||||
void EventCommandHandler(const Service::Ptr& service);
|
void EventCommandHandler(const Service::Ptr& service);
|
||||||
|
|
||||||
Timer::Ptr m_RotationTimer;
|
Timer::Ptr m_RotationTimer;
|
||||||
void RotationTimerHandler(void);
|
void RotationTimerHandler(void);
|
||||||
|
@ -269,7 +269,7 @@ Value HostsTable::CheckCommandExpandedAccessor(const Value& row)
|
|||||||
resolvers.push_back(commandObj);
|
resolvers.push_back(commandObj);
|
||||||
resolvers.push_back(IcingaApplication::GetInstance());
|
resolvers.push_back(IcingaApplication::GetInstance());
|
||||||
|
|
||||||
Value commandLine = MacroProcessor::ResolveMacros(raw_command, resolvers, Dictionary::Ptr(), Utility::EscapeShellCmd);
|
Value commandLine = MacroProcessor::ResolveMacros(raw_command, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
|
|
||||||
String buf;
|
String buf;
|
||||||
if (commandLine.IsObjectType<Array>()) {
|
if (commandLine.IsObjectType<Array>()) {
|
||||||
@ -403,10 +403,7 @@ Value HostsTable::NotesExpandedAccessor(const Value& row)
|
|||||||
|
|
||||||
Value value = custom->Get("notes");
|
Value value = custom->Get("notes");
|
||||||
|
|
||||||
Dictionary::Ptr cr;
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
return value_expanded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostsTable::NotesUrlAccessor(const Value& row)
|
Value HostsTable::NotesUrlAccessor(const Value& row)
|
||||||
@ -451,10 +448,7 @@ Value HostsTable::NotesUrlExpandedAccessor(const Value& row)
|
|||||||
|
|
||||||
Value value = custom->Get("notes_url");
|
Value value = custom->Get("notes_url");
|
||||||
|
|
||||||
Dictionary::Ptr cr;
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
return value_expanded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostsTable::ActionUrlAccessor(const Value& row)
|
Value HostsTable::ActionUrlAccessor(const Value& row)
|
||||||
@ -499,10 +493,7 @@ Value HostsTable::ActionUrlExpandedAccessor(const Value& row)
|
|||||||
|
|
||||||
Value value = custom->Get("action_url");
|
Value value = custom->Get("action_url");
|
||||||
|
|
||||||
Dictionary::Ptr cr;
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
return value_expanded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostsTable::PluginOutputAccessor(const Value& row)
|
Value HostsTable::PluginOutputAccessor(const Value& row)
|
||||||
@ -518,7 +509,7 @@ Value HostsTable::PluginOutputAccessor(const Value& row)
|
|||||||
|
|
||||||
if(hc) {
|
if(hc) {
|
||||||
String output;
|
String output;
|
||||||
Dictionary::Ptr cr = hc->GetLastCheckResult();
|
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
@ -541,7 +532,7 @@ Value HostsTable::PerfDataAccessor(const Value& row)
|
|||||||
String perfdata;
|
String perfdata;
|
||||||
|
|
||||||
if (hc) {
|
if (hc) {
|
||||||
Dictionary::Ptr cr = hc->GetLastCheckResult();
|
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr)
|
if (cr)
|
||||||
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
||||||
@ -593,10 +584,7 @@ Value HostsTable::IconImageExpandedAccessor(const Value& row)
|
|||||||
|
|
||||||
Value value = custom->Get("icon_image");
|
Value value = custom->Get("icon_image");
|
||||||
|
|
||||||
Dictionary::Ptr cr;
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
return value_expanded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostsTable::IconImageAltAccessor(const Value& row)
|
Value HostsTable::IconImageAltAccessor(const Value& row)
|
||||||
@ -642,7 +630,7 @@ Value HostsTable::LongPluginOutputAccessor(const Value& row)
|
|||||||
|
|
||||||
if (hc) {
|
if (hc) {
|
||||||
String long_output;
|
String long_output;
|
||||||
Dictionary::Ptr cr = hc->GetLastCheckResult();
|
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
@ -2050,7 +2038,7 @@ Value HostsTable::ServicesWithInfoAccessor(const Value& row)
|
|||||||
svc_add->Add(service->HasBeenChecked() ? 1 : 0);
|
svc_add->Add(service->HasBeenChecked() ? 1 : 0);
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
|
@ -214,7 +214,7 @@ Value ServicesTable::CheckCommandExpandedAccessor(const Value& row)
|
|||||||
resolvers.push_back(commandObj);
|
resolvers.push_back(commandObj);
|
||||||
resolvers.push_back(IcingaApplication::GetInstance());
|
resolvers.push_back(IcingaApplication::GetInstance());
|
||||||
|
|
||||||
Value commandLine = MacroProcessor::ResolveMacros(raw_command, resolvers, Dictionary::Ptr(), Utility::EscapeShellCmd);
|
Value commandLine = MacroProcessor::ResolveMacros(raw_command, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
|
|
||||||
String buf;
|
String buf;
|
||||||
if (commandLine.IsObjectType<Array>()) {
|
if (commandLine.IsObjectType<Array>()) {
|
||||||
@ -262,7 +262,7 @@ Value ServicesTable::PluginOutputAccessor(const Value& row)
|
|||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
@ -280,7 +280,7 @@ Value ServicesTable::LongPluginOutputAccessor(const Value& row)
|
|||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
String long_output;
|
String long_output;
|
||||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
@ -298,7 +298,7 @@ Value ServicesTable::PerfDataAccessor(const Value& row)
|
|||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
String perfdata;
|
String perfdata;
|
||||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr)
|
if (cr)
|
||||||
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
||||||
@ -375,10 +375,7 @@ Value ServicesTable::NotesExpandedAccessor(const Value& row)
|
|||||||
|
|
||||||
Value value = custom->Get("notes");
|
Value value = custom->Get("notes");
|
||||||
|
|
||||||
Dictionary::Ptr cr;
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
return value_expanded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::NotesUrlAccessor(const Value& row)
|
Value ServicesTable::NotesUrlAccessor(const Value& row)
|
||||||
@ -415,10 +412,7 @@ Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
|
|||||||
|
|
||||||
Value value = custom->Get("notes_url");
|
Value value = custom->Get("notes_url");
|
||||||
|
|
||||||
Dictionary::Ptr cr;
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
return value_expanded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::ActionUrlAccessor(const Value& row)
|
Value ServicesTable::ActionUrlAccessor(const Value& row)
|
||||||
@ -455,10 +449,7 @@ Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
|
|||||||
|
|
||||||
Value value = custom->Get("action_url");
|
Value value = custom->Get("action_url");
|
||||||
|
|
||||||
Dictionary::Ptr cr;
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
return value_expanded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::IconImageAccessor(const Value& row)
|
Value ServicesTable::IconImageAccessor(const Value& row)
|
||||||
@ -495,10 +486,7 @@ Value ServicesTable::IconImageExpandedAccessor(const Value& row)
|
|||||||
|
|
||||||
Value value = custom->Get("icon_image");
|
Value value = custom->Get("icon_image");
|
||||||
|
|
||||||
Dictionary::Ptr cr;
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
return value_expanded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::IconImageAltAccessor(const Value& row)
|
Value ServicesTable::IconImageAltAccessor(const Value& row)
|
||||||
|
@ -105,7 +105,7 @@ void NotificationComponent::NotificationTimerHandler(void)
|
|||||||
* Processes icinga::SendNotifications messages.
|
* Processes icinga::SendNotifications messages.
|
||||||
*/
|
*/
|
||||||
void NotificationComponent::SendNotificationsHandler(const Service::Ptr& service, NotificationType type,
|
void NotificationComponent::SendNotificationsHandler(const Service::Ptr& service, NotificationType type,
|
||||||
const Dictionary::Ptr& cr, const String& author, const String& text)
|
const CheckResult::Ptr& cr, const String& author, const String& text)
|
||||||
{
|
{
|
||||||
service->SendNotifications(static_cast<NotificationType>(type), cr, author, text);
|
service->SendNotifications(static_cast<NotificationType>(type), cr, author, text);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ private:
|
|||||||
|
|
||||||
void NotificationTimerHandler(void);
|
void NotificationTimerHandler(void);
|
||||||
void SendNotificationsHandler(const Service::Ptr& service, NotificationType type,
|
void SendNotificationsHandler(const Service::Ptr& service, NotificationType type,
|
||||||
const Dictionary::Ptr& cr, const String& author, const String& text);
|
const CheckResult::Ptr& cr, const String& author, const String& text);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ void GraphiteWriter::ReconnectTimerHandler(void)
|
|||||||
m_Stream = make_shared<BufferedStream>(net_stream);
|
m_Stream = make_shared<BufferedStream>(net_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphiteWriter::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr)
|
void GraphiteWriter::CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr& cr)
|
||||||
{
|
{
|
||||||
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !service->GetEnablePerfdata())
|
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !service->GetEnablePerfdata())
|
||||||
return;
|
return;
|
||||||
@ -100,7 +100,7 @@ void GraphiteWriter::CheckResultHandler(const Service::Ptr& service, const Dicti
|
|||||||
SendMetric(prefix, "latency", Service::CalculateLatency(cr));
|
SendMetric(prefix, "latency", Service::CalculateLatency(cr));
|
||||||
SendMetric(prefix, "execution_time", Service::CalculateExecutionTime(cr));
|
SendMetric(prefix, "execution_time", Service::CalculateExecutionTime(cr));
|
||||||
|
|
||||||
Value pdv = cr->Get("performance_data");
|
Value pdv = cr->GetPerformanceData();
|
||||||
|
|
||||||
if (!pdv.IsObjectType<Dictionary>())
|
if (!pdv.IsObjectType<Dictionary>())
|
||||||
return;
|
return;
|
||||||
|
@ -45,15 +45,15 @@ protected:
|
|||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Stream::Ptr m_Stream;
|
Stream::Ptr m_Stream;
|
||||||
|
|
||||||
Timer::Ptr m_ReconnectTimer;
|
Timer::Ptr m_ReconnectTimer;
|
||||||
|
|
||||||
void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr);
|
void CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr& cr);
|
||||||
void SendMetric(const String& prefix, const String& name, double value);
|
void SendMetric(const String& prefix, const String& name, double value);
|
||||||
static void SanitizeMetric(String& str);
|
static void SanitizeMetric(String& str);
|
||||||
|
|
||||||
void ReconnectTimerHandler(void);
|
void ReconnectTimerHandler(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ void PerfdataWriter::Start(void)
|
|||||||
RotateFile();
|
RotateFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfdataWriter::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr)
|
void PerfdataWriter::CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr& cr)
|
||||||
{
|
{
|
||||||
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !service->GetEnablePerfdata())
|
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !service->GetEnablePerfdata())
|
||||||
return;
|
return;
|
||||||
|
@ -44,7 +44,7 @@ protected:
|
|||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr);
|
void CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr& cr);
|
||||||
|
|
||||||
Timer::Ptr m_RotationTimer;
|
Timer::Ptr m_RotationTimer;
|
||||||
void RotationTimerHandler(void);
|
void RotationTimerHandler(void);
|
||||||
|
@ -856,7 +856,7 @@ void ServiceDbObject::AddContactNotificationHistory(const Service::Ptr& service,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServiceDbObject::AddNotificationHistory(const Service::Ptr& service, const std::set<User::Ptr>& users, NotificationType type,
|
void ServiceDbObject::AddNotificationHistory(const Service::Ptr& service, const std::set<User::Ptr>& users, NotificationType type,
|
||||||
const Dictionary::Ptr& cr, const String& author, const String& text)
|
const CheckResult::Ptr& cr, const String& author, const String& text)
|
||||||
{
|
{
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
@ -907,7 +907,7 @@ void ServiceDbObject::AddNotificationHistory(const Service::Ptr& service, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* statehistory */
|
/* statehistory */
|
||||||
void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const Dictionary::Ptr& cr, StateType type)
|
void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const CheckResult::Ptr& cr, StateType type)
|
||||||
{
|
{
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
@ -961,14 +961,14 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const D
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* logentries */
|
/* logentries */
|
||||||
void ServiceDbObject::AddCheckResultLogHistory(const Service::Ptr& service, const Dictionary::Ptr &cr)
|
void ServiceDbObject::AddCheckResultLogHistory(const Service::Ptr& service, const CheckResult::Ptr &cr)
|
||||||
{
|
{
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
if (!host)
|
if (!host)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Dictionary::Ptr vars_after = cr->Get("vars_after");
|
Dictionary::Ptr vars_after = cr->GetVarsAfter();
|
||||||
|
|
||||||
long state_after = vars_after->Get("state");
|
long state_after = vars_after->Get("state");
|
||||||
long stateType_after = vars_after->Get("state_type");
|
long stateType_after = vars_after->Get("state_type");
|
||||||
@ -976,7 +976,7 @@ void ServiceDbObject::AddCheckResultLogHistory(const Service::Ptr& service, cons
|
|||||||
bool reachable_after = vars_after->Get("reachable");
|
bool reachable_after = vars_after->Get("reachable");
|
||||||
bool host_reachable_after = vars_after->Get("host_reachable");
|
bool host_reachable_after = vars_after->Get("host_reachable");
|
||||||
|
|
||||||
Dictionary::Ptr vars_before = cr->Get("vars_before");
|
Dictionary::Ptr vars_before = cr->GetVarsBefore();
|
||||||
|
|
||||||
if (vars_before) {
|
if (vars_before) {
|
||||||
long state_before = vars_before->Get("state");
|
long state_before = vars_before->Get("state");
|
||||||
@ -1008,12 +1008,12 @@ void ServiceDbObject::AddCheckResultLogHistory(const Service::Ptr& service, cons
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag->Get("output");
|
output = output_bag->Get("output");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "SERVICE ALERT: "
|
msgbuf << "SERVICE ALERT: "
|
||||||
@ -1132,7 +1132,7 @@ void ServiceDbObject::AddRemoveDowntimeLogHistory(const Service::Ptr& service, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServiceDbObject::AddNotificationSentLogHistory(const Service::Ptr& service, const User::Ptr& user,
|
void ServiceDbObject::AddNotificationSentLogHistory(const Service::Ptr& service, const User::Ptr& user,
|
||||||
NotificationType const& notification_type, Dictionary::Ptr const& cr,
|
NotificationType notification_type, const CheckResult::Ptr& cr,
|
||||||
const String& author, const String& comment_text)
|
const String& author, const String& comment_text)
|
||||||
{
|
{
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
@ -1153,42 +1153,42 @@ void ServiceDbObject::AddNotificationSentLogHistory(const Service::Ptr& service,
|
|||||||
author_comment = ";" + author + ";" + comment_text;
|
author_comment = ";" + author + ";" + comment_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cr)
|
if (!cr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag->Get("output");
|
output = output_bag->Get("output");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "SERVICE NOTIFICATION: "
|
msgbuf << "SERVICE NOTIFICATION: "
|
||||||
<< user->GetName() << ";"
|
<< user->GetName() << ";"
|
||||||
<< host->GetName() << ";"
|
<< host->GetName() << ";"
|
||||||
<< service->GetShortName() << ";"
|
<< service->GetShortName() << ";"
|
||||||
<< notification_type_str << " "
|
<< notification_type_str << " "
|
||||||
<< "(" << Service::StateToString(service->GetState()) << ");"
|
<< "(" << Service::StateToString(service->GetState()) << ");"
|
||||||
<< check_command << ";"
|
<< check_command << ";"
|
||||||
<< output << author_comment
|
<< output << author_comment
|
||||||
<< "";
|
<< "";
|
||||||
|
|
||||||
AddLogHistory(service, msgbuf.str(), LogEntryTypeServiceNotification);
|
AddLogHistory(service, msgbuf.str(), LogEntryTypeServiceNotification);
|
||||||
|
|
||||||
if (service == host->GetCheckService()) {
|
if (service == host->GetCheckService()) {
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "HOST NOTIFICATION: "
|
msgbuf << "HOST NOTIFICATION: "
|
||||||
<< user->GetName() << ";"
|
<< user->GetName() << ";"
|
||||||
<< host->GetName() << ";"
|
<< host->GetName() << ";"
|
||||||
<< notification_type_str << " "
|
<< notification_type_str << " "
|
||||||
<< "(" << Service::StateToString(service->GetState()) << ");"
|
<< "(" << Service::StateToString(service->GetState()) << ");"
|
||||||
<< check_command << ";"
|
<< check_command << ";"
|
||||||
<< output << author_comment
|
<< output << author_comment
|
||||||
<< "";
|
<< "";
|
||||||
|
|
||||||
AddLogHistory(service, msgbuf.str(), LogEntryTypeHostNotification);
|
AddLogHistory(service, msgbuf.str(), LogEntryTypeHostNotification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceDbObject::AddFlappingLogHistory(const Service::Ptr& service, FlappingState flapping_state)
|
void ServiceDbObject::AddFlappingLogHistory(const Service::Ptr& service, FlappingState flapping_state)
|
||||||
@ -1338,7 +1338,7 @@ void ServiceDbObject::AddFlappingHistory(const Service::Ptr& service, FlappingSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* servicechecks */
|
/* servicechecks */
|
||||||
void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const Dictionary::Ptr &cr)
|
void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const CheckResult::Ptr &cr)
|
||||||
{
|
{
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
@ -1378,10 +1378,10 @@ void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const
|
|||||||
fields1->Set("end_time_usec", time_bag_end->Get("time_usec"));
|
fields1->Set("end_time_usec", time_bag_end->Get("time_usec"));
|
||||||
fields1->Set("command_object_id", service->GetCheckCommand());
|
fields1->Set("command_object_id", service->GetCheckCommand());
|
||||||
fields1->Set("command_args", Empty);
|
fields1->Set("command_args", Empty);
|
||||||
fields1->Set("command_line", cr->Get("command"));
|
fields1->Set("command_line", cr->GetCommand());
|
||||||
fields1->Set("execution_time", attrs->Get("check_execution_time"));
|
fields1->Set("execution_time", attrs->Get("check_execution_time"));
|
||||||
fields1->Set("latency", attrs->Get("check_latency"));
|
fields1->Set("latency", attrs->Get("check_latency"));
|
||||||
fields1->Set("return_code", cr->Get("exit_state"));
|
fields1->Set("return_code", cr->GetExitStatus());
|
||||||
fields1->Set("output", attrs->Get("plugin_output"));
|
fields1->Set("output", attrs->Get("plugin_output"));
|
||||||
fields1->Set("long_output", attrs->Get("long_plugin_output"));
|
fields1->Set("long_output", attrs->Get("long_plugin_output"));
|
||||||
fields1->Set("perfdata", attrs->Get("performance_data"));
|
fields1->Set("perfdata", attrs->Get("performance_data"));
|
||||||
@ -1394,11 +1394,12 @@ void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const
|
|||||||
if (host->GetCheckService() == service) {
|
if (host->GetCheckService() == service) {
|
||||||
query1.Table = "hostchecks";
|
query1.Table = "hostchecks";
|
||||||
|
|
||||||
fields1->Remove("service_object_id");
|
Dictionary::Ptr fields2 = fields1->ShallowClone();
|
||||||
fields1->Set("host_object_id", host);
|
fields2->Remove("service_object_id");
|
||||||
fields1->Set("state", host->GetState());
|
fields2->Set("host_object_id", host);
|
||||||
fields1->Set("state_type", host->GetStateType());
|
fields2->Set("state", host->GetState());
|
||||||
query1.Fields = fields1;
|
fields2->Set("state_type", host->GetStateType());
|
||||||
|
query1.Fields = fields2;
|
||||||
OnQuery(query1);
|
OnQuery(query1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,17 +100,17 @@ private:
|
|||||||
static void AddDowntimeHistory(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
static void AddDowntimeHistory(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
||||||
static void AddAcknowledgementHistory(const Service::Ptr& service, const String& author, const String& comment, AcknowledgementType type, double expiry);
|
static void AddAcknowledgementHistory(const Service::Ptr& service, const String& author, const String& comment, AcknowledgementType type, double expiry);
|
||||||
static void AddContactNotificationHistory(const Service::Ptr& service, const User::Ptr& user);
|
static void AddContactNotificationHistory(const Service::Ptr& service, const User::Ptr& user);
|
||||||
static void AddNotificationHistory(const Service::Ptr& service, const std::set<User::Ptr>& users, NotificationType type, const Dictionary::Ptr& cr, const String& author, const String& text);
|
static void AddNotificationHistory(const Service::Ptr& service, const std::set<User::Ptr>& users, NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text);
|
||||||
static void AddStateChangeHistory(const Service::Ptr& service, const Dictionary::Ptr& cr, StateType type);
|
static void AddStateChangeHistory(const Service::Ptr& service, const CheckResult::Ptr& cr, StateType type);
|
||||||
|
|
||||||
static void AddCheckResultLogHistory(const Service::Ptr& service, const Dictionary::Ptr &cr);
|
static void AddCheckResultLogHistory(const Service::Ptr& service, const CheckResult::Ptr &cr);
|
||||||
static void AddTriggerDowntimeLogHistory(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
static void AddTriggerDowntimeLogHistory(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
||||||
static void AddRemoveDowntimeLogHistory(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
static void AddRemoveDowntimeLogHistory(const Service::Ptr& service, const Dictionary::Ptr& downtime);
|
||||||
static void AddNotificationSentLogHistory(const Service::Ptr& service, const User::Ptr& user, NotificationType const& notification_type, Dictionary::Ptr const& cr, const String& author, const String& comment_text);
|
static void AddNotificationSentLogHistory(const Service::Ptr& service, const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author, const String& comment_text);
|
||||||
static void AddFlappingLogHistory(const Service::Ptr& service, FlappingState flapping_state);
|
static void AddFlappingLogHistory(const Service::Ptr& service, FlappingState flapping_state);
|
||||||
|
|
||||||
static void AddFlappingHistory(const Service::Ptr& service, FlappingState flapping_state);
|
static void AddFlappingHistory(const Service::Ptr& service, FlappingState flapping_state);
|
||||||
static void AddServiceCheckHistory(const Service::Ptr& service, const Dictionary::Ptr &cr);
|
static void AddServiceCheckHistory(const Service::Ptr& service, const CheckResult::Ptr &cr);
|
||||||
static void AddEventHandlerHistory(const Service::Ptr& service);
|
static void AddEventHandlerHistory(const Service::Ptr& service);
|
||||||
static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
|
static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
|
||||||
};
|
};
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
mkclass_target(checkcommand.ti checkcommand.th)
|
mkclass_target(checkcommand.ti checkcommand.th)
|
||||||
|
mkclass_target(checkresult.ti checkresult.th)
|
||||||
mkclass_target(command.ti command.th)
|
mkclass_target(command.ti command.th)
|
||||||
mkclass_target(domain.ti domain.th)
|
mkclass_target(domain.ti domain.th)
|
||||||
mkclass_target(eventcommand.ti eventcommand.th)
|
mkclass_target(eventcommand.ti eventcommand.th)
|
||||||
@ -34,11 +35,11 @@ mkclass_target(user.ti user.th)
|
|||||||
mkembedconfig_target(icinga-type.conf icinga-type.cpp)
|
mkembedconfig_target(icinga-type.conf icinga-type.cpp)
|
||||||
|
|
||||||
add_library(icinga SHARED
|
add_library(icinga SHARED
|
||||||
api.cpp api.h checkcommand.cpp checkcommand.th cib.cpp command.cpp command.th
|
api.cpp api.h checkcommand.cpp checkcommand.th checkresult.cpp checkresult.th
|
||||||
compatutility.cpp domain.cpp domain.th eventcommand.cpp eventcommand.th
|
cib.cpp command.cpp command.th compatutility.cpp domain.cpp domain.th
|
||||||
externalcommandprocessor.cpp host.cpp host.th hostgroup.cpp hostgroup.th
|
eventcommand.cpp eventcommand.th externalcommandprocessor.cpp host.cpp
|
||||||
icingaapplication.cpp icingaapplication.th macroprocessor.cpp
|
host.th hostgroup.cpp hostgroup.th icingaapplication.cpp icingaapplication.th
|
||||||
macroresolver.cpp notificationcommand.cpp notificationcommand.th
|
macroprocessor.cpp macroresolver.cpp notificationcommand.cpp notificationcommand.th
|
||||||
notification.cpp notification.th perfdatavalue.cpp perfdatavalue.th
|
notification.cpp notification.th perfdatavalue.cpp perfdatavalue.th
|
||||||
pluginutility.cpp service-check.cpp service-comment.cpp service.cpp
|
pluginutility.cpp service-check.cpp service-comment.cpp service.cpp
|
||||||
service-downtime.cpp service-event.cpp service-flapping.cpp service.th
|
service-downtime.cpp service-event.cpp service-flapping.cpp service.th
|
||||||
|
@ -24,7 +24,7 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_TYPE(CheckCommand);
|
REGISTER_TYPE(CheckCommand);
|
||||||
|
|
||||||
Dictionary::Ptr CheckCommand::Execute(const Service::Ptr& service)
|
CheckResult::Ptr CheckCommand::Execute(const Service::Ptr& service)
|
||||||
{
|
{
|
||||||
std::vector<Value> arguments;
|
std::vector<Value> arguments;
|
||||||
arguments.push_back(service);
|
arguments.push_back(service);
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
DECLARE_PTR_TYPEDEFS(CheckCommand);
|
DECLARE_PTR_TYPEDEFS(CheckCommand);
|
||||||
DECLARE_TYPENAME(CheckCommand);
|
DECLARE_TYPENAME(CheckCommand);
|
||||||
|
|
||||||
virtual Dictionary::Ptr Execute(const Service::Ptr& service);
|
virtual CheckResult::Ptr Execute(const Service::Ptr& service);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
25
lib/icinga/checkresult.cpp
Normal file
25
lib/icinga/checkresult.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the Free Software Foundation *
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "icinga/checkresult.h"
|
||||||
|
#include "base/dynamictype.h"
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
|
REGISTER_TYPE(CheckResult);
|
42
lib/icinga/checkresult.h
Normal file
42
lib/icinga/checkresult.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the Free Software Foundation *
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CHECKRESULT_H
|
||||||
|
#define CHECKRESULT_H
|
||||||
|
|
||||||
|
#include "icinga/i2-icinga.h"
|
||||||
|
#include "icinga/checkresult.th"
|
||||||
|
|
||||||
|
namespace icinga
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A check result.
|
||||||
|
*
|
||||||
|
* @ingroup icinga
|
||||||
|
*/
|
||||||
|
class I2_ICINGA_API CheckResult : public ObjectImpl<CheckResult>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_PTR_TYPEDEFS(CheckResult);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CHECKRESULT_H */
|
54
lib/icinga/checkresult.ti
Normal file
54
lib/icinga/checkresult.ti
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
namespace icinga
|
||||||
|
{
|
||||||
|
|
||||||
|
code {{{
|
||||||
|
/**
|
||||||
|
* The state of a service.
|
||||||
|
*
|
||||||
|
* @ingroup icinga
|
||||||
|
*/
|
||||||
|
enum ServiceState
|
||||||
|
{
|
||||||
|
StateOK = 0,
|
||||||
|
StateWarning = 1,
|
||||||
|
StateCritical = 2,
|
||||||
|
StateUnknown = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state type of a host or service.
|
||||||
|
*
|
||||||
|
* @ingroup icinga
|
||||||
|
*/
|
||||||
|
enum StateType
|
||||||
|
{
|
||||||
|
StateTypeSoft = 0,
|
||||||
|
StateTypeHard = 1
|
||||||
|
};
|
||||||
|
}}}
|
||||||
|
|
||||||
|
class CheckResult
|
||||||
|
{
|
||||||
|
[state] double schedule_start;
|
||||||
|
[state] double schedule_end;
|
||||||
|
[state] double execution_start;
|
||||||
|
[state] double execution_end;
|
||||||
|
|
||||||
|
[state] String command;
|
||||||
|
[state] int exit_status;
|
||||||
|
|
||||||
|
[state, enum] ServiceState "state";
|
||||||
|
[state] String output;
|
||||||
|
[state] Value performance_data;
|
||||||
|
|
||||||
|
[state] bool active {
|
||||||
|
default {{{ return true; }}}
|
||||||
|
};
|
||||||
|
|
||||||
|
[state] String check_source;
|
||||||
|
|
||||||
|
[state] Dictionary::Ptr vars_before;
|
||||||
|
[state] Dictionary::Ptr vars_after;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -23,7 +23,7 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_TYPE(Command);
|
REGISTER_TYPE(Command);
|
||||||
|
|
||||||
bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
bool Command::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
|
||||||
{
|
{
|
||||||
Dictionary::Ptr macros = GetMacros();
|
Dictionary::Ptr macros = GetMacros();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
//virtual Dictionary::Ptr Execute(const Object::Ptr& context) = 0;
|
//virtual Dictionary::Ptr Execute(const Object::Ptr& context) = 0;
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -184,17 +184,17 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
|
|||||||
else
|
else
|
||||||
check_period_str = "24x7";
|
check_period_str = "24x7";
|
||||||
|
|
||||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
Dictionary::Ptr output_bag = GetCheckResultOutput(cr);
|
Dictionary::Ptr output_bag = GetCheckResultOutput(cr);
|
||||||
output = output_bag->Get("output");
|
output = output_bag->Get("output");
|
||||||
long_output = output_bag->Get("long_output");
|
long_output = output_bag->Get("long_output");
|
||||||
|
|
||||||
check_source = cr->Get("check_source");
|
check_source = cr->GetCheckSource();
|
||||||
|
|
||||||
perfdata = GetCheckResultPerfdata(cr);
|
perfdata = GetCheckResultPerfdata(cr);
|
||||||
schedule_end = cr->Get("schedule_end");
|
schedule_end = cr->GetScheduleEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
int state = service->GetState();
|
int state = service->GetState();
|
||||||
@ -521,7 +521,7 @@ std::set<UserGroup::Ptr> CompatUtility::GetServiceNotificationUserGroups(const S
|
|||||||
return usergroups;
|
return usergroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr CompatUtility::GetCheckResultOutput(const Dictionary::Ptr& cr)
|
Dictionary::Ptr CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
|
||||||
{
|
{
|
||||||
if (!cr)
|
if (!cr)
|
||||||
return Empty;
|
return Empty;
|
||||||
@ -530,7 +530,7 @@ Dictionary::Ptr CompatUtility::GetCheckResultOutput(const Dictionary::Ptr& cr)
|
|||||||
String output;
|
String output;
|
||||||
Dictionary::Ptr bag = make_shared<Dictionary>();
|
Dictionary::Ptr bag = make_shared<Dictionary>();
|
||||||
|
|
||||||
String raw_output = cr->Get("output");
|
String raw_output = cr->GetOutput();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* replace semi-colons with colons in output
|
* replace semi-colons with colons in output
|
||||||
@ -554,12 +554,12 @@ Dictionary::Ptr CompatUtility::GetCheckResultOutput(const Dictionary::Ptr& cr)
|
|||||||
return bag;
|
return bag;
|
||||||
}
|
}
|
||||||
|
|
||||||
String CompatUtility::GetCheckResultPerfdata(const Dictionary::Ptr& cr)
|
String CompatUtility::GetCheckResultPerfdata(const CheckResult::Ptr& cr)
|
||||||
{
|
{
|
||||||
if (!cr)
|
if (!cr)
|
||||||
return String();
|
return String();
|
||||||
|
|
||||||
return PluginUtility::FormatPerfdata(cr->Get("performance_data"));
|
return PluginUtility::FormatPerfdata(cr->GetPerformanceData());
|
||||||
}
|
}
|
||||||
|
|
||||||
String CompatUtility::EscapeString(const String& str)
|
String CompatUtility::EscapeString(const String& str)
|
||||||
|
@ -59,8 +59,8 @@ public:
|
|||||||
static std::set<User::Ptr> GetServiceNotificationUsers(const Service::Ptr& service);
|
static std::set<User::Ptr> GetServiceNotificationUsers(const Service::Ptr& service);
|
||||||
static std::set<UserGroup::Ptr> GetServiceNotificationUserGroups(const Service::Ptr& service);
|
static std::set<UserGroup::Ptr> GetServiceNotificationUserGroups(const Service::Ptr& service);
|
||||||
|
|
||||||
static Dictionary::Ptr GetCheckResultOutput(const Dictionary::Ptr& cr);
|
static Dictionary::Ptr GetCheckResultOutput(const CheckResult::Ptr& cr);
|
||||||
static String GetCheckResultPerfdata(const Dictionary::Ptr& cr);
|
static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
|
||||||
|
|
||||||
static Dictionary::Ptr ConvertTimestamp(double time);
|
static Dictionary::Ptr ConvertTimestamp(double time);
|
||||||
|
|
||||||
|
@ -214,14 +214,14 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
|
|||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled."));
|
||||||
|
|
||||||
int exitStatus = Convert::ToDouble(arguments[1]);
|
int exitStatus = Convert::ToDouble(arguments[1]);
|
||||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(arguments[2]);
|
CheckResult::Ptr result = PluginUtility::ParseCheckOutput(arguments[2]);
|
||||||
result->Set("state", PluginUtility::ExitStatusToState(exitStatus));
|
result->SetState(PluginUtility::ExitStatusToState(exitStatus));
|
||||||
|
|
||||||
result->Set("schedule_start", time);
|
result->SetScheduleStart(time);
|
||||||
result->Set("schedule_end", time);
|
result->SetScheduleEnd(time);
|
||||||
result->Set("execution_start", time);
|
result->SetExecutionStart(time);
|
||||||
result->Set("execution_end", time);
|
result->SetExecutionEnd(time);
|
||||||
result->Set("active", 0);
|
result->SetActive(false);
|
||||||
|
|
||||||
Log(LogInformation, "icinga", "Processing passive check result for host '" + arguments[0] + "'");
|
Log(LogInformation, "icinga", "Processing passive check result for host '" + arguments[0] + "'");
|
||||||
hc->ProcessCheckResult(result);
|
hc->ProcessCheckResult(result);
|
||||||
@ -250,14 +250,14 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
|
|||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
|
||||||
|
|
||||||
int exitStatus = Convert::ToDouble(arguments[2]);
|
int exitStatus = Convert::ToDouble(arguments[2]);
|
||||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(arguments[3]);
|
CheckResult::Ptr result = PluginUtility::ParseCheckOutput(arguments[3]);
|
||||||
result->Set("state", PluginUtility::ExitStatusToState(exitStatus));
|
result->SetState(PluginUtility::ExitStatusToState(exitStatus));
|
||||||
|
|
||||||
result->Set("schedule_start", time);
|
result->SetScheduleStart(time);
|
||||||
result->Set("schedule_end", time);
|
result->SetScheduleEnd(time);
|
||||||
result->Set("execution_start", time);
|
result->SetExecutionStart(time);
|
||||||
result->Set("execution_end", time);
|
result->SetExecutionEnd(time);
|
||||||
result->Set("active", 0);
|
result->SetActive(false);
|
||||||
|
|
||||||
Log(LogInformation, "icinga", "Processing passive check result for service '" + arguments[1] + "'");
|
Log(LogInformation, "icinga", "Processing passive check result for service '" + arguments[1] + "'");
|
||||||
service->ProcessCheckResult(result);
|
service->ProcessCheckResult(result);
|
||||||
|
@ -542,7 +542,7 @@ String Host::StateTypeToString(StateType type)
|
|||||||
return "HARD";
|
return "HARD";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Host::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
|
||||||
{
|
{
|
||||||
if (macro == "HOSTNAME") {
|
if (macro == "HOSTNAME") {
|
||||||
*result = GetName();
|
*result = GetName();
|
||||||
@ -554,7 +554,7 @@ bool Host::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *res
|
|||||||
}
|
}
|
||||||
|
|
||||||
Service::Ptr hc = GetCheckService();
|
Service::Ptr hc = GetCheckService();
|
||||||
Dictionary::Ptr hccr;
|
CheckResult::Ptr hccr;
|
||||||
|
|
||||||
if (hc) {
|
if (hc) {
|
||||||
ServiceState state = hc->GetState();
|
ServiceState state = hc->GetState();
|
||||||
@ -618,13 +618,13 @@ bool Host::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *res
|
|||||||
*result = Convert::ToString(Service::CalculateExecutionTime(hccr));
|
*result = Convert::ToString(Service::CalculateExecutionTime(hccr));
|
||||||
return true;
|
return true;
|
||||||
} else if (macro == "HOSTOUTPUT") {
|
} else if (macro == "HOSTOUTPUT") {
|
||||||
*result = hccr->Get("output");
|
*result = hccr->GetOutput();
|
||||||
return true;
|
return true;
|
||||||
} else if (macro == "HOSTPERFDATA") {
|
} else if (macro == "HOSTPERFDATA") {
|
||||||
*result = PluginUtility::FormatPerfdata(hccr->Get("performance_data"));
|
*result = PluginUtility::FormatPerfdata(hccr->GetPerformanceData());
|
||||||
return true;
|
return true;
|
||||||
} else if (macro == "LASTHOSTCHECK") {
|
} else if (macro == "LASTHOSTCHECK") {
|
||||||
*result = Convert::ToString((long)hccr->Get("schedule_start"));
|
*result = Convert::ToString((long)hccr->GetScheduleStart());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "icinga/i2-icinga.h"
|
#include "icinga/i2-icinga.h"
|
||||||
#include "icinga/host.th"
|
#include "icinga/host.th"
|
||||||
#include "icinga/macroresolver.h"
|
#include "icinga/macroresolver.h"
|
||||||
|
#include "icinga/checkresult.h"
|
||||||
#include "base/array.h"
|
#include "base/array.h"
|
||||||
#include "base/dictionary.h"
|
#include "base/dictionary.h"
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ public:
|
|||||||
static StateType StateTypeFromString(const String& state);
|
static StateType StateTypeFromString(const String& state);
|
||||||
static String StateTypeToString(StateType state);
|
static String StateTypeToString(StateType state);
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
@ -3,32 +3,6 @@
|
|||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
code {{{
|
|
||||||
/**
|
|
||||||
* The state of a service.
|
|
||||||
*
|
|
||||||
* @ingroup icinga
|
|
||||||
*/
|
|
||||||
enum ServiceState
|
|
||||||
{
|
|
||||||
StateOK = 0,
|
|
||||||
StateWarning = 1,
|
|
||||||
StateCritical = 2,
|
|
||||||
StateUnknown = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The state type of a host or service.
|
|
||||||
*
|
|
||||||
* @ingroup icinga
|
|
||||||
*/
|
|
||||||
enum StateType
|
|
||||||
{
|
|
||||||
StateTypeSoft = 0,
|
|
||||||
StateTypeHard = 1
|
|
||||||
};
|
|
||||||
}}}
|
|
||||||
|
|
||||||
class Host : DynamicObject
|
class Host : DynamicObject
|
||||||
{
|
{
|
||||||
[config] String display_name {
|
[config] String display_name {
|
||||||
|
@ -93,7 +93,7 @@ Dictionary::Ptr IcingaApplication::GetMacros(void) const
|
|||||||
return ScriptVariable::Get("IcingaMacros");
|
return ScriptVariable::Get("IcingaMacros");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IcingaApplication::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
bool IcingaApplication::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
|
||||||
{
|
{
|
||||||
double now = Utility::GetTime();
|
double now = Utility::GetTime();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
String GetPidPath(void) const;
|
String GetPidPath(void) const;
|
||||||
Dictionary::Ptr GetMacros(void) const;
|
Dictionary::Ptr GetMacros(void) const;
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
bool GetEnableNotifications(void) const;
|
bool GetEnableNotifications(void) const;
|
||||||
void SetEnableNotifications(bool enabled);
|
void SetEnableNotifications(bool enabled);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
Value MacroProcessor::ResolveMacros(const Value& str, const std::vector<MacroResolver::Ptr>& resolvers,
|
Value MacroProcessor::ResolveMacros(const Value& str, const std::vector<MacroResolver::Ptr>& resolvers,
|
||||||
const Dictionary::Ptr& cr, const MacroProcessor::EscapeCallback& escapeFn, const Array::Ptr& escapeMacros)
|
const CheckResult::Ptr& cr, const MacroProcessor::EscapeCallback& escapeFn, const Array::Ptr& escapeMacros)
|
||||||
{
|
{
|
||||||
Value result;
|
Value result;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ Value MacroProcessor::ResolveMacros(const Value& str, const std::vector<MacroRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MacroProcessor::ResolveMacro(const String& macro, const std::vector<MacroResolver::Ptr>& resolvers,
|
bool MacroProcessor::ResolveMacro(const String& macro, const std::vector<MacroResolver::Ptr>& resolvers,
|
||||||
const Dictionary::Ptr& cr, String *result)
|
const CheckResult::Ptr& cr, String *result)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const MacroResolver::Ptr& resolver, resolvers) {
|
BOOST_FOREACH(const MacroResolver::Ptr& resolver, resolvers) {
|
||||||
if (resolver->ResolveMacro(macro, cr, result))
|
if (resolver->ResolveMacro(macro, cr, result))
|
||||||
@ -70,7 +70,7 @@ bool MacroProcessor::ResolveMacro(const String& macro, const std::vector<MacroRe
|
|||||||
|
|
||||||
|
|
||||||
String MacroProcessor::InternalResolveMacros(const String& str, const std::vector<MacroResolver::Ptr>& resolvers,
|
String MacroProcessor::InternalResolveMacros(const String& str, const std::vector<MacroResolver::Ptr>& resolvers,
|
||||||
const Dictionary::Ptr& cr, const MacroProcessor::EscapeCallback& escapeFn, const Array::Ptr& escapeMacros)
|
const CheckResult::Ptr& cr, const MacroProcessor::EscapeCallback& escapeFn, const Array::Ptr& escapeMacros)
|
||||||
{
|
{
|
||||||
size_t offset, pos_first, pos_second;
|
size_t offset, pos_first, pos_second;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
@ -41,15 +41,15 @@ public:
|
|||||||
typedef boost::function<String (const String&)> EscapeCallback;
|
typedef boost::function<String (const String&)> EscapeCallback;
|
||||||
|
|
||||||
static Value ResolveMacros(const Value& str, const std::vector<MacroResolver::Ptr>& resolvers,
|
static Value ResolveMacros(const Value& str, const std::vector<MacroResolver::Ptr>& resolvers,
|
||||||
const Dictionary::Ptr& cr, const EscapeCallback& escapeFn = EscapeCallback(), const Array::Ptr& escapeMacros = Array::Ptr());
|
const CheckResult::Ptr& cr, const EscapeCallback& escapeFn = EscapeCallback(), const Array::Ptr& escapeMacros = Array::Ptr());
|
||||||
static bool ResolveMacro(const String& macro, const std::vector<MacroResolver::Ptr>& resolvers,
|
static bool ResolveMacro(const String& macro, const std::vector<MacroResolver::Ptr>& resolvers,
|
||||||
const Dictionary::Ptr& cr, String *result);
|
const CheckResult::Ptr& cr, String *result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MacroProcessor(void);
|
MacroProcessor(void);
|
||||||
|
|
||||||
static String InternalResolveMacros(const String& str,
|
static String InternalResolveMacros(const String& str,
|
||||||
const std::vector<MacroResolver::Ptr>& resolvers, const Dictionary::Ptr& cr,
|
const std::vector<MacroResolver::Ptr>& resolvers, const CheckResult::Ptr& cr,
|
||||||
const EscapeCallback& escapeFn, const Array::Ptr& escapeMacros);
|
const EscapeCallback& escapeFn, const Array::Ptr& escapeMacros);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ void StaticMacroResolver::Add(const String& macro, const String& value)
|
|||||||
m_Macros->Set(macro, value);
|
m_Macros->Set(macro, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StaticMacroResolver::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
bool StaticMacroResolver::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
|
||||||
{
|
{
|
||||||
if (m_Macros->Contains(macro)) {
|
if (m_Macros->Contains(macro)) {
|
||||||
*result = m_Macros->Get(macro);
|
*result = m_Macros->Get(macro);
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define MACRORESOLVER_H
|
#define MACRORESOLVER_H
|
||||||
|
|
||||||
#include "icinga/i2-icinga.h"
|
#include "icinga/i2-icinga.h"
|
||||||
|
#include "icinga/checkresult.h"
|
||||||
#include "base/dictionary.h"
|
#include "base/dictionary.h"
|
||||||
#include "base/qstring.h"
|
#include "base/qstring.h"
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ class I2_ICINGA_API MacroResolver
|
|||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(MacroResolver);
|
DECLARE_PTR_TYPEDEFS(MacroResolver);
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const = 0;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class I2_ICINGA_API StaticMacroResolver : public Object, public MacroResolver
|
class I2_ICINGA_API StaticMacroResolver : public Object, public MacroResolver
|
||||||
@ -49,7 +50,7 @@ public:
|
|||||||
|
|
||||||
void Add(const String& macro, const String& value);
|
void Add(const String& macro, const String& value);
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Dictionary::Ptr m_Macros;
|
Dictionary::Ptr m_Macros;
|
||||||
|
@ -169,7 +169,7 @@ String Notification::NotificationTypeToString(NotificationType type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::BeginExecuteNotification(NotificationType type, const Dictionary::Ptr& cr, bool force, const String& author, const String& text)
|
void Notification::BeginExecuteNotification(NotificationType type, const CheckResult::Ptr& cr, bool force, const String& author, const String& text)
|
||||||
{
|
{
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const Diction
|
|||||||
Service::OnNotificationSentToAllUsers(GetService(), allUsers, type, cr, author, text);
|
Service::OnNotificationSentToAllUsers(GetService(), allUsers, type, cr, author, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 CheckResult::Ptr& cr, bool force, const String& author, const String& text)
|
||||||
{
|
{
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notification::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
bool Notification::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
|
||||||
{
|
{
|
||||||
Dictionary::Ptr macros = GetMacros();
|
Dictionary::Ptr macros = GetMacros();
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ public:
|
|||||||
void UpdateNotificationNumber(void);
|
void UpdateNotificationNumber(void);
|
||||||
void ResetNotificationNumber(void);
|
void ResetNotificationNumber(void);
|
||||||
|
|
||||||
void BeginExecuteNotification(NotificationType type, const Dictionary::Ptr& cr, bool force, const String& author = "", const String& text = "");
|
void BeginExecuteNotification(NotificationType type, const CheckResult::Ptr& cr, bool force, const String& author = "", const String& text = "");
|
||||||
|
|
||||||
static String NotificationTypeToString(NotificationType type);
|
static String NotificationTypeToString(NotificationType type);
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
static boost::signals2::signal<void (const Notification::Ptr&, double, const String&)> OnNextNotificationChanged;
|
static boost::signals2::signal<void (const Notification::Ptr&, double, const String&)> OnNextNotificationChanged;
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ protected:
|
|||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const Dictionary::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 = "");
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ using namespace icinga;
|
|||||||
REGISTER_TYPE(NotificationCommand);
|
REGISTER_TYPE(NotificationCommand);
|
||||||
|
|
||||||
Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notification,
|
Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notification,
|
||||||
const User::Ptr& user, const Dictionary::Ptr& cr, const NotificationType& type,
|
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationType& type,
|
||||||
const String& author, const String& comment)
|
const String& author, const String& comment)
|
||||||
{
|
{
|
||||||
std::vector<Value> arguments;
|
std::vector<Value> arguments;
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
DECLARE_TYPENAME(NotificationCommand);
|
DECLARE_TYPENAME(NotificationCommand);
|
||||||
|
|
||||||
virtual Dictionary::Ptr Execute(const shared_ptr<Notification>& notification,
|
virtual Dictionary::Ptr Execute(const shared_ptr<Notification>& notification,
|
||||||
const User::Ptr& user, const Dictionary::Ptr& cr, const NotificationType& type,
|
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationType& type,
|
||||||
const String& author, const String& comment);
|
const String& author, const String& comment);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ ServiceState PluginUtility::ExitStatusToState(int exitStatus)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr PluginUtility::ParseCheckOutput(const String& output)
|
CheckResult::Ptr PluginUtility::ParseCheckOutput(const String& output)
|
||||||
{
|
{
|
||||||
Dictionary::Ptr result = make_shared<Dictionary>();
|
CheckResult::Ptr result = make_shared<CheckResult>();
|
||||||
|
|
||||||
String text;
|
String text;
|
||||||
String perfdata;
|
String perfdata;
|
||||||
@ -75,8 +75,8 @@ Dictionary::Ptr PluginUtility::ParseCheckOutput(const String& output)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result->Set("output", text);
|
result->SetOutput(text);
|
||||||
result->Set("performance_data", ParsePerfdata(perfdata));
|
result->SetPerformanceData(ParsePerfdata(perfdata));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class I2_ICINGA_API PluginUtility
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static ServiceState ExitStatusToState(int exitStatus);
|
static ServiceState ExitStatusToState(int exitStatus);
|
||||||
static Dictionary::Ptr ParseCheckOutput(const String& output);
|
static CheckResult::Ptr ParseCheckOutput(const String& output);
|
||||||
|
|
||||||
static Value ParsePerfdata(const String& perfdata);
|
static Value ParsePerfdata(const String& perfdata);
|
||||||
static String FormatPerfdata(const Value& perfdata);
|
static String FormatPerfdata(const Value& perfdata);
|
||||||
|
@ -32,9 +32,9 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> Service::OnNewCheckResult;
|
boost::signals2::signal<void (const Service::Ptr&, const CheckResult::Ptr&, const String&)> Service::OnNewCheckResult;
|
||||||
boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, StateType, const String&)> Service::OnStateChange;
|
boost::signals2::signal<void (const Service::Ptr&, const CheckResult::Ptr&, StateType, const String&)> Service::OnStateChange;
|
||||||
boost::signals2::signal<void (const Service::Ptr&, NotificationType, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationsRequested;
|
boost::signals2::signal<void (const Service::Ptr&, NotificationType, const CheckResult::Ptr&, const String&, const String&)> Service::OnNotificationsRequested;
|
||||||
boost::signals2::signal<void (const Service::Ptr&, double, const String&)> Service::OnNextCheckChanged;
|
boost::signals2::signal<void (const Service::Ptr&, double, const String&)> Service::OnNextCheckChanged;
|
||||||
boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> Service::OnForceNextCheckChanged;
|
boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> Service::OnForceNextCheckChanged;
|
||||||
boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> Service::OnForceNextNotificationChanged;
|
boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> Service::OnForceNextNotificationChanged;
|
||||||
@ -129,11 +129,11 @@ bool Service::HasBeenChecked(void) const
|
|||||||
|
|
||||||
double Service::GetLastCheck(void) const
|
double Service::GetLastCheck(void) const
|
||||||
{
|
{
|
||||||
Dictionary::Ptr cr = GetLastCheckResult();
|
CheckResult::Ptr cr = GetLastCheckResult();
|
||||||
double schedule_end = -1;
|
double schedule_end = -1;
|
||||||
|
|
||||||
if (cr)
|
if (cr)
|
||||||
schedule_end = cr->Get("schedule_end");
|
schedule_end = cr->GetScheduleEnd();
|
||||||
|
|
||||||
return schedule_end;
|
return schedule_end;
|
||||||
}
|
}
|
||||||
@ -180,26 +180,26 @@ void Service::SetForceNextCheck(bool forced, const String& authority)
|
|||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnForceNextCheckChanged), GetSelf(), forced, authority));
|
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnForceNextCheckChanged), GetSelf(), forced, authority));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& authority)
|
void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& authority)
|
||||||
{
|
{
|
||||||
double now = Utility::GetTime();
|
double now = Utility::GetTime();
|
||||||
|
|
||||||
if (!cr->Contains("schedule_start"))
|
if (cr->GetScheduleStart() == 0)
|
||||||
cr->Set("schedule_start", now);
|
cr->SetScheduleStart(now);
|
||||||
|
|
||||||
if (!cr->Contains("schedule_end"))
|
if (cr->GetScheduleEnd() == 0)
|
||||||
cr->Set("schedule_end", now);
|
cr->SetScheduleEnd(now);
|
||||||
|
|
||||||
if (!cr->Contains("execution_start"))
|
if (cr->GetExecutionStart() == 0)
|
||||||
cr->Set("execution_start", now);
|
cr->SetExecutionStart(now);
|
||||||
|
|
||||||
if (!cr->Contains("execution_end"))
|
if (cr->GetExecutionEnd() == 0)
|
||||||
cr->Set("execution_end", now);
|
cr->SetExecutionEnd(now);
|
||||||
|
|
||||||
String check_source = cr->Get("check_source");
|
String check_source = cr->GetCheckSource();
|
||||||
|
|
||||||
if (check_source.IsEmpty())
|
if (check_source.IsEmpty())
|
||||||
cr->Set("check_source", authority);
|
cr->SetCheckSource(authority);
|
||||||
|
|
||||||
bool reachable = IsReachable();
|
bool reachable = IsReachable();
|
||||||
|
|
||||||
@ -212,13 +212,13 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
|
|||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
Dictionary::Ptr old_cr = GetLastCheckResult();
|
CheckResult::Ptr old_cr = GetLastCheckResult();
|
||||||
ServiceState old_state = GetState();
|
ServiceState old_state = GetState();
|
||||||
StateType old_stateType = GetStateType();
|
StateType old_stateType = GetStateType();
|
||||||
long old_attempt = GetCheckAttempt();
|
long old_attempt = GetCheckAttempt();
|
||||||
bool recovery;
|
bool recovery;
|
||||||
|
|
||||||
if (old_cr && cr->Get("execution_start") < old_cr->Get("execution_start"))
|
if (old_cr && cr->GetExecutionStart() < old_cr->GetExecutionStart())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* The ExecuteCheck function already sets the old state, but we need to do it again
|
/* The ExecuteCheck function already sets the old state, but we need to do it again
|
||||||
@ -229,7 +229,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
|
|||||||
|
|
||||||
long attempt;
|
long attempt;
|
||||||
|
|
||||||
if (cr->Get("state") == StateOK) {
|
if (cr->GetState() == StateOK) {
|
||||||
if (old_state == StateOK && old_stateType == StateTypeSoft)
|
if (old_state == StateOK && old_stateType == StateTypeSoft)
|
||||||
SetStateType(StateTypeHard); // SOFT OK -> HARD OK
|
SetStateType(StateTypeHard); // SOFT OK -> HARD OK
|
||||||
|
|
||||||
@ -250,12 +250,17 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
|
|||||||
|
|
||||||
recovery = false;
|
recovery = false;
|
||||||
|
|
||||||
if (cr->Get("state") == StateWarning)
|
switch (cr->GetState()) {
|
||||||
SetLastStateWarning(Utility::GetTime());
|
case StateWarning:
|
||||||
if (cr->Get("state") == StateCritical)
|
SetLastStateWarning(Utility::GetTime());
|
||||||
SetLastStateCritical(Utility::GetTime());
|
break;
|
||||||
if (cr->Get("state") == StateUnknown)
|
case StateCritical:
|
||||||
SetLastStateUnknown(Utility::GetTime());
|
SetLastStateCritical(Utility::GetTime());
|
||||||
|
break;
|
||||||
|
case StateUnknown:
|
||||||
|
SetLastStateUnknown(Utility::GetTime());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!reachable)
|
if (!reachable)
|
||||||
@ -263,8 +268,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
|
|||||||
|
|
||||||
SetCheckAttempt(attempt);
|
SetCheckAttempt(attempt);
|
||||||
|
|
||||||
int state = cr->Get("state");
|
SetState(cr->GetState());
|
||||||
SetState(static_cast<ServiceState>(state));
|
|
||||||
|
|
||||||
bool call_eventhandler = false;
|
bool call_eventhandler = false;
|
||||||
bool stateChange = (old_state != GetState());
|
bool stateChange = (old_state != GetState());
|
||||||
@ -341,9 +345,9 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
|
|||||||
vars_after->Set("host_reachable", host_reachable);
|
vars_after->Set("host_reachable", host_reachable);
|
||||||
|
|
||||||
if (old_cr)
|
if (old_cr)
|
||||||
cr->Set("vars_before", old_cr->Get("vars_after"));
|
cr->SetVarsBefore(old_cr->GetVarsAfter());
|
||||||
|
|
||||||
cr->Set("vars_after", vars_after);
|
cr->SetVarsAfter(vars_after);
|
||||||
|
|
||||||
olock.Lock();
|
olock.Lock();
|
||||||
SetLastCheckResult(cr);
|
SetLastCheckResult(cr);
|
||||||
@ -457,13 +461,11 @@ void Service::ExecuteCheck(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* keep track of scheduling info in case the check type doesn't provide its own information */
|
/* keep track of scheduling info in case the check type doesn't provide its own information */
|
||||||
Dictionary::Ptr checkInfo = make_shared<Dictionary>();
|
double before_check = Utility::GetTime();
|
||||||
checkInfo->Set("schedule_start", GetNextCheck());
|
|
||||||
checkInfo->Set("execution_start", Utility::GetTime());
|
|
||||||
|
|
||||||
Service::Ptr self = GetSelf();
|
Service::Ptr self = GetSelf();
|
||||||
|
|
||||||
Dictionary::Ptr result;
|
CheckResult::Ptr result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CheckCommand::Ptr command = GetCheckCommand();
|
CheckCommand::Ptr command = GetCheckCommand();
|
||||||
@ -482,32 +484,25 @@ void Service::ExecuteCheck(void)
|
|||||||
|
|
||||||
Log(LogWarning, "icinga", message);
|
Log(LogWarning, "icinga", message);
|
||||||
|
|
||||||
result = make_shared<Dictionary>();
|
result = make_shared<CheckResult>();
|
||||||
result->Set("state", StateUnknown);
|
result->SetState(StateUnknown);
|
||||||
result->Set("output", message);
|
result->SetOutput(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkInfo->Set("execution_end", Utility::GetTime());
|
double after_check = Utility::GetTime();
|
||||||
checkInfo->Set("schedule_end", Utility::GetTime());
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
if (!result->Contains("schedule_start"))
|
if (!result->GetScheduleStart() == 0)
|
||||||
result->Set("schedule_start", checkInfo->Get("schedule_start"));
|
result->SetScheduleStart(before_check);
|
||||||
|
|
||||||
if (!result->Contains("schedule_end"))
|
if (!result->GetScheduleEnd() == 0)
|
||||||
result->Set("schedule_end", checkInfo->Get("schedule_end"));
|
result->SetScheduleEnd(after_check);
|
||||||
|
|
||||||
if (!result->Contains("execution_start"))
|
if (!result->GetExecutionStart() == 0)
|
||||||
result->Set("execution_start", checkInfo->Get("execution_start"));
|
result->SetExecutionStart(before_check);
|
||||||
|
|
||||||
if (!result->Contains("execution_end"))
|
if (!result->GetExecutionEnd() == 0)
|
||||||
result->Set("execution_end", checkInfo->Get("execution_end"));
|
result->SetExecutionEnd(after_check);
|
||||||
|
|
||||||
if (!result->Contains("macros"))
|
|
||||||
result->Set("macros", checkInfo->Get("macros"));
|
|
||||||
|
|
||||||
if (!result->Contains("active"))
|
|
||||||
result->Set("active", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
@ -524,50 +519,33 @@ void Service::ExecuteCheck(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::UpdateStatistics(const Dictionary::Ptr& cr)
|
void Service::UpdateStatistics(const CheckResult::Ptr& cr)
|
||||||
{
|
{
|
||||||
time_t ts;
|
time_t ts = cr->GetScheduleEnd();
|
||||||
Value schedule_end = cr->Get("schedule_end");
|
|
||||||
if (!schedule_end.IsEmpty())
|
if (ts == 0)
|
||||||
ts = static_cast<time_t>(schedule_end);
|
|
||||||
else
|
|
||||||
ts = static_cast<time_t>(Utility::GetTime());
|
ts = static_cast<time_t>(Utility::GetTime());
|
||||||
|
|
||||||
Value active = cr->Get("active");
|
if (cr->GetActive())
|
||||||
if (active.IsEmpty() || static_cast<long>(active))
|
|
||||||
CIB::UpdateActiveChecksStatistics(ts, 1);
|
CIB::UpdateActiveChecksStatistics(ts, 1);
|
||||||
else
|
else
|
||||||
CIB::UpdatePassiveChecksStatistics(ts, 1);
|
CIB::UpdatePassiveChecksStatistics(ts, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Service::CalculateExecutionTime(const Dictionary::Ptr& cr)
|
double Service::CalculateExecutionTime(const CheckResult::Ptr& cr)
|
||||||
{
|
{
|
||||||
double execution_start = 0, execution_end = 0;
|
if (!cr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (cr) {
|
return cr->GetExecutionEnd() - cr->GetExecutionStart();
|
||||||
if (!cr->Contains("execution_start") || !cr->Contains("execution_end"))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
execution_start = cr->Get("execution_start");
|
|
||||||
execution_end = cr->Get("execution_end");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (execution_end - execution_start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double Service::CalculateLatency(const Dictionary::Ptr& cr)
|
double Service::CalculateLatency(const CheckResult::Ptr& cr)
|
||||||
{
|
{
|
||||||
double schedule_start = 0, schedule_end = 0;
|
if (!cr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (cr) {
|
double latency = (cr->GetScheduleEnd() - cr->GetScheduleStart()) - CalculateExecutionTime(cr);
|
||||||
if (!cr->Contains("schedule_start") || !cr->Contains("schedule_end"))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
schedule_start = cr->Get("schedule_start");
|
|
||||||
schedule_end = cr->Get("schedule_end");
|
|
||||||
}
|
|
||||||
|
|
||||||
double latency = (schedule_end - schedule_start) - CalculateExecutionTime(cr);
|
|
||||||
|
|
||||||
if (latency < 0)
|
if (latency < 0)
|
||||||
latency = 0;
|
latency = 0;
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
boost::signals2::signal<void (const Service::Ptr&, const std::set<User::Ptr>&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationSentToAllUsers;
|
boost::signals2::signal<void (const Service::Ptr&, const std::set<User::Ptr>&, const NotificationType&, const CheckResult::Ptr&, const String&, const String&)> Service::OnNotificationSentToAllUsers;
|
||||||
boost::signals2::signal<void (const Service::Ptr&, const User::Ptr&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&, const String&)> Service::OnNotificationSentToUser;
|
boost::signals2::signal<void (const Service::Ptr&, const User::Ptr&, const NotificationType&, const CheckResult::Ptr&, const String&, const String&, const String&)> Service::OnNotificationSentToUser;
|
||||||
|
|
||||||
void Service::ResetNotificationNumbers(void)
|
void Service::ResetNotificationNumbers(void)
|
||||||
{
|
{
|
||||||
@ -42,7 +42,7 @@ void Service::ResetNotificationNumbers(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::SendNotifications(NotificationType type, const Dictionary::Ptr& cr, const String& author, const String& text)
|
void Service::SendNotifications(NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text)
|
||||||
{
|
{
|
||||||
bool force = GetForceNextNotification();
|
bool force = GetForceNextNotification();
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ void Service::SetModifiedAttributes(int flags)
|
|||||||
SetOverrideRetryInterval(Empty);
|
SetOverrideRetryInterval(Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const
|
bool Service::ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const
|
||||||
{
|
{
|
||||||
if (macro == "SERVICEDESC") {
|
if (macro == "SERVICEDESC") {
|
||||||
*result = GetShortName();
|
*result = GetShortName();
|
||||||
@ -391,13 +391,13 @@ bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, Strin
|
|||||||
*result = Convert::ToString(Service::CalculateExecutionTime(cr));
|
*result = Convert::ToString(Service::CalculateExecutionTime(cr));
|
||||||
return true;
|
return true;
|
||||||
} else if (macro == "SERVICEOUTPUT") {
|
} else if (macro == "SERVICEOUTPUT") {
|
||||||
*result = cr->Get("output");
|
*result = cr->GetOutput();
|
||||||
return true;
|
return true;
|
||||||
} else if (macro == "SERVICEPERFDATA") {
|
} else if (macro == "SERVICEPERFDATA") {
|
||||||
*result = PluginUtility::FormatPerfdata(cr->Get("performance_data"));
|
*result = PluginUtility::FormatPerfdata(cr->GetPerformanceData());
|
||||||
return true;
|
return true;
|
||||||
} else if (macro == "LASTSERVICECHECK") {
|
} else if (macro == "LASTSERVICECHECK") {
|
||||||
*result = Convert::ToString((long)cr->Get("execution_end"));
|
*result = Convert::ToString((long)cr->GetExecutionEnd());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,16 +172,16 @@ public:
|
|||||||
bool GetForceNextCheck(void) const;
|
bool GetForceNextCheck(void) const;
|
||||||
void SetForceNextCheck(bool forced, const String& authority = String());
|
void SetForceNextCheck(bool forced, const String& authority = String());
|
||||||
|
|
||||||
static void UpdateStatistics(const Dictionary::Ptr& cr);
|
static void UpdateStatistics(const CheckResult::Ptr& cr);
|
||||||
|
|
||||||
void ExecuteCheck(void);
|
void ExecuteCheck(void);
|
||||||
void ProcessCheckResult(const Dictionary::Ptr& cr, const String& authority = String());
|
void ProcessCheckResult(const CheckResult::Ptr& cr, const String& authority = String());
|
||||||
|
|
||||||
int GetModifiedAttributes(void) const;
|
int GetModifiedAttributes(void) const;
|
||||||
void SetModifiedAttributes(int flags);
|
void SetModifiedAttributes(int flags);
|
||||||
|
|
||||||
static double CalculateExecutionTime(const Dictionary::Ptr& cr);
|
static double CalculateExecutionTime(const CheckResult::Ptr& cr);
|
||||||
static double CalculateLatency(const Dictionary::Ptr& cr);
|
static double CalculateLatency(const CheckResult::Ptr& cr);
|
||||||
|
|
||||||
static ServiceState StateFromString(const String& state);
|
static ServiceState StateFromString(const String& state);
|
||||||
static String StateToString(ServiceState state);
|
static String StateToString(ServiceState state);
|
||||||
@ -196,11 +196,11 @@ public:
|
|||||||
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnablePassiveChecksChanged;
|
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnablePassiveChecksChanged;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnableNotificationsChanged;
|
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnableNotificationsChanged;
|
||||||
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 CheckResult::Ptr&, const String&)> OnNewCheckResult;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, StateType, const String&)> OnStateChange;
|
static boost::signals2::signal<void (const Service::Ptr&, const CheckResult::Ptr&, StateType, const String&)> OnStateChange;
|
||||||
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 CheckResult::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&, const String&)> OnNotificationSentToUser;
|
static boost::signals2::signal<void (const Service::Ptr&, const User::Ptr&, const NotificationType&, const CheckResult::Ptr&, const String&, 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&)> OnNotificationSentToAllUsers;
|
static boost::signals2::signal<void (const Service::Ptr&, const std::set<User::Ptr>&, const NotificationType&, const CheckResult::Ptr&, const String&, const String&)> 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;
|
||||||
@ -211,7 +211,7 @@ public:
|
|||||||
static boost::signals2::signal<void (const Service::Ptr&, const String&)> OnAcknowledgementCleared;
|
static boost::signals2::signal<void (const Service::Ptr&, const String&)> OnAcknowledgementCleared;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&)> OnEventCommandExecuted;
|
static boost::signals2::signal<void (const Service::Ptr&)> OnEventCommandExecuted;
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
/* Downtimes */
|
/* Downtimes */
|
||||||
static int GetNextDowntimeID(void);
|
static int GetNextDowntimeID(void);
|
||||||
@ -261,7 +261,7 @@ public:
|
|||||||
bool GetEnableNotifications(void) const;
|
bool GetEnableNotifications(void) const;
|
||||||
void SetEnableNotifications(bool enabled, const String& authority = String());
|
void SetEnableNotifications(bool enabled, const String& authority = String());
|
||||||
|
|
||||||
void SendNotifications(NotificationType type, const Dictionary::Ptr& cr, const String& author = "", const String& text = "");
|
void SendNotifications(NotificationType type, const CheckResult::Ptr& cr, const String& author = "", const String& text = "");
|
||||||
|
|
||||||
std::set<Notification::Ptr> GetNotifications(void) const;
|
std::set<Notification::Ptr> GetNotifications(void) const;
|
||||||
void AddNotification(const Notification::Ptr& notification);
|
void AddNotification(const Notification::Ptr& notification);
|
||||||
|
@ -91,7 +91,7 @@ class Service : DynamicObject
|
|||||||
[state] bool last_reachable {
|
[state] bool last_reachable {
|
||||||
default {{{ return true; }}}
|
default {{{ return true; }}}
|
||||||
};
|
};
|
||||||
[state] Dictionary::Ptr last_check_result;
|
[state] CheckResult::Ptr last_check_result;
|
||||||
[state] double last_state_change {
|
[state] double last_state_change {
|
||||||
default {{{ return Application::GetStartTime(); }}}
|
default {{{ return Application::GetStartTime(); }}}
|
||||||
};
|
};
|
||||||
|
@ -66,7 +66,7 @@ TimePeriod::Ptr User::GetNotificationPeriod(void) const
|
|||||||
return TimePeriod::GetByName(GetNotificationPeriodRaw());
|
return TimePeriod::GetByName(GetNotificationPeriodRaw());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool User::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
bool User::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
|
||||||
{
|
{
|
||||||
if (macro == "USERNAME" || macro == "CONTACTNAME") {
|
if (macro == "USERNAME" || macro == "CONTACTNAME") {
|
||||||
*result = GetName();
|
*result = GetName();
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
/* Notifications */
|
/* Notifications */
|
||||||
TimePeriod::Ptr GetNotificationPeriod(void) const;
|
TimePeriod::Ptr GetNotificationPeriod(void) const;
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
|
@ -30,7 +30,7 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_SCRIPTFUNCTION(NullCheck, &NullCheckTask::ScriptFunc);
|
REGISTER_SCRIPTFUNCTION(NullCheck, &NullCheckTask::ScriptFunc);
|
||||||
|
|
||||||
Dictionary::Ptr NullCheckTask::ScriptFunc(const Service::Ptr&)
|
CheckResult::Ptr NullCheckTask::ScriptFunc(const Service::Ptr&)
|
||||||
{
|
{
|
||||||
char name[255];
|
char name[255];
|
||||||
|
|
||||||
@ -43,10 +43,10 @@ Dictionary::Ptr NullCheckTask::ScriptFunc(const Service::Ptr&)
|
|||||||
Dictionary::Ptr perfdata = make_shared<Dictionary>();
|
Dictionary::Ptr perfdata = make_shared<Dictionary>();
|
||||||
perfdata->Set("time", Utility::GetTime());
|
perfdata->Set("time", Utility::GetTime());
|
||||||
|
|
||||||
Dictionary::Ptr cr = make_shared<Dictionary>();
|
CheckResult::Ptr cr = make_shared<CheckResult>();
|
||||||
cr->Set("output", output);
|
cr->SetOutput(output);
|
||||||
cr->Set("performance_data", perfdata);
|
cr->SetPerformanceData(perfdata);
|
||||||
cr->Set("state", StateOK);
|
cr->SetState(StateOK);
|
||||||
|
|
||||||
return cr;
|
return cr;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace icinga
|
|||||||
class I2_METHODS_API NullCheckTask
|
class I2_METHODS_API NullCheckTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
static CheckResult::Ptr ScriptFunc(const Service::Ptr& service);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NullCheckTask(void);
|
NullCheckTask(void);
|
||||||
|
@ -35,7 +35,7 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_SCRIPTFUNCTION(PluginCheck, &PluginCheckTask::ScriptFunc);
|
REGISTER_SCRIPTFUNCTION(PluginCheck, &PluginCheckTask::ScriptFunc);
|
||||||
|
|
||||||
Dictionary::Ptr PluginCheckTask::ScriptFunc(const Service::Ptr& service)
|
CheckResult::Ptr PluginCheckTask::ScriptFunc(const Service::Ptr& service)
|
||||||
{
|
{
|
||||||
CheckCommand::Ptr commandObj = service->GetCheckCommand();
|
CheckCommand::Ptr commandObj = service->GetCheckCommand();
|
||||||
Value raw_command = commandObj->GetCommandLine();
|
Value raw_command = commandObj->GetCommandLine();
|
||||||
@ -73,12 +73,12 @@ Dictionary::Ptr PluginCheckTask::ScriptFunc(const Service::Ptr& service)
|
|||||||
|
|
||||||
String output = pr.Output;
|
String output = pr.Output;
|
||||||
output.Trim();
|
output.Trim();
|
||||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(output);
|
CheckResult::Ptr result = PluginUtility::ParseCheckOutput(output);
|
||||||
result->Set("command", command);
|
result->SetCommand(command);
|
||||||
result->Set("state", PluginUtility::ExitStatusToState(pr.ExitStatus));
|
result->SetState(PluginUtility::ExitStatusToState(pr.ExitStatus));
|
||||||
result->Set("exit_state", pr.ExitStatus);
|
result->SetExitStatus(pr.ExitStatus);
|
||||||
result->Set("execution_start", pr.ExecutionStart);
|
result->SetExecutionStart(pr.ExecutionStart);
|
||||||
result->Set("execution_end", pr.ExecutionEnd);
|
result->SetExecutionEnd(pr.ExecutionEnd);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace icinga
|
|||||||
class I2_METHODS_API PluginCheckTask
|
class I2_METHODS_API PluginCheckTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
static CheckResult::Ptr ScriptFunc(const Service::Ptr& service);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PluginCheckTask(void);
|
PluginCheckTask(void);
|
||||||
|
@ -33,7 +33,7 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_SCRIPTFUNCTION(PluginNotification, &PluginNotificationTask::ScriptFunc);
|
REGISTER_SCRIPTFUNCTION(PluginNotification, &PluginNotificationTask::ScriptFunc);
|
||||||
|
|
||||||
void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, const User::Ptr& user, const Dictionary::Ptr& cr, int itype,
|
void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, const User::Ptr& user, const CheckResult::Ptr& cr, int itype,
|
||||||
const String& author, const String& comment)
|
const String& author, const String& comment)
|
||||||
{
|
{
|
||||||
NotificationCommand::Ptr commandObj = notification->GetNotificationCommand();
|
NotificationCommand::Ptr commandObj = notification->GetNotificationCommand();
|
||||||
|
@ -35,7 +35,7 @@ class I2_METHODS_API PluginNotificationTask
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void ScriptFunc(const Notification::Ptr& notification,
|
static void ScriptFunc(const Notification::Ptr& notification,
|
||||||
const User::Ptr& user, const Dictionary::Ptr& cr, int itype,
|
const User::Ptr& user, const CheckResult::Ptr& cr, int itype,
|
||||||
const String& author, const String& comment);
|
const String& author, const String& comment);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -30,7 +30,7 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_SCRIPTFUNCTION(RandomCheck, &RandomCheckTask::ScriptFunc);
|
REGISTER_SCRIPTFUNCTION(RandomCheck, &RandomCheckTask::ScriptFunc);
|
||||||
|
|
||||||
Dictionary::Ptr RandomCheckTask::ScriptFunc(const Service::Ptr&)
|
CheckResult::Ptr RandomCheckTask::ScriptFunc(const Service::Ptr&)
|
||||||
{
|
{
|
||||||
char name[255];
|
char name[255];
|
||||||
|
|
||||||
@ -43,10 +43,10 @@ Dictionary::Ptr RandomCheckTask::ScriptFunc(const Service::Ptr&)
|
|||||||
Dictionary::Ptr perfdata = make_shared<Dictionary>();
|
Dictionary::Ptr perfdata = make_shared<Dictionary>();
|
||||||
perfdata->Set("time", Utility::GetTime());
|
perfdata->Set("time", Utility::GetTime());
|
||||||
|
|
||||||
Dictionary::Ptr cr = make_shared<Dictionary>();
|
CheckResult::Ptr cr = make_shared<CheckResult>();
|
||||||
cr->Set("output", output);
|
cr->SetOutput(output);
|
||||||
cr->Set("performance_data", perfdata);
|
cr->SetPerformanceData(perfdata);
|
||||||
cr->Set("state", static_cast<ServiceState>(Utility::Random() % 4));
|
cr->SetState(static_cast<ServiceState>(Utility::Random() % 4));
|
||||||
|
|
||||||
return cr;
|
return cr;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace icinga
|
|||||||
class RandomCheckTask
|
class RandomCheckTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
static CheckResult::Ptr ScriptFunc(const Service::Ptr& service);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RandomCheckTask(void);
|
RandomCheckTask(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user