mirror of https://github.com/Icinga/icinga2.git
parent
7ae3a47f0e
commit
112f26dc19
|
@ -660,7 +660,7 @@ void ClusterListener::SetSecurityInfo(const Dictionary::Ptr& message, const Dyna
|
|||
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())
|
||||
return;
|
||||
|
@ -1012,7 +1012,7 @@ void ClusterListener::MessageHandler(const Endpoint::Ptr& sender, const Dictiona
|
|||
return;
|
||||
}
|
||||
|
||||
Dictionary::Ptr cr = params->Get("check_result");
|
||||
CheckResult::Ptr cr = params->Get("check_result");
|
||||
|
||||
if (!cr)
|
||||
return;
|
||||
|
|
|
@ -83,7 +83,7 @@ private:
|
|||
Stream::Ptr m_LogFile;
|
||||
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 NextNotificationChangedHandler(const Notification::Ptr& notification, double nextCheck, 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;
|
||||
}
|
||||
|
||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(attrs["output"]);
|
||||
result->Set("state", PluginUtility::ExitStatusToState(Convert::ToLong(attrs["return_code"])));
|
||||
result->Set("execution_start", Convert::ToDouble(attrs["start_time"]));
|
||||
result->Set("execution_end", Convert::ToDouble(attrs["finish_time"]));
|
||||
result->Set("active", 1);
|
||||
CheckResult::Ptr result = PluginUtility::ParseCheckOutput(attrs["output"]);
|
||||
result->SetState(PluginUtility::ExitStatusToState(Convert::ToLong(attrs["return_code"])));
|
||||
result->SetExecutionStart(Convert::ToDouble(attrs["start_time"]));
|
||||
result->SetExecutionEnd(Convert::ToDouble(attrs["finish_time"]));
|
||||
|
||||
service->ProcessCheckResult(result);
|
||||
|
||||
|
|
|
@ -72,14 +72,14 @@ void CompatLogger::Start(void)
|
|||
/**
|
||||
* @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();
|
||||
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
Dictionary::Ptr vars_after = cr->Get("vars_after");
|
||||
Dictionary::Ptr vars_after = cr->GetVarsAfter();
|
||||
|
||||
long state_after = vars_after->Get("state");
|
||||
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 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) {
|
||||
long state_before = vars_before->Get("state");
|
||||
|
@ -251,8 +251,8 @@ void CompatLogger::RemoveDowntimeHandler(const Service::Ptr& service, const Dict
|
|||
* @threadsafety Always.
|
||||
*/
|
||||
void CompatLogger::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)
|
||||
NotificationType const& notification_type, CheckResult::Ptr const& cr,
|
||||
const String& author, const String& comment_text, const String& command_name)
|
||||
{
|
||||
Host::Ptr host = service->GetHost();
|
||||
|
||||
|
@ -505,7 +505,7 @@ void CompatLogger::ReopenFile(bool rotate)
|
|||
ObjectLock olock(hc);
|
||||
|
||||
String output;
|
||||
Dictionary::Ptr cr = hc->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||
|
||||
if (cr) {
|
||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||
|
@ -530,7 +530,7 @@ void CompatLogger::ReopenFile(bool rotate)
|
|||
continue;
|
||||
|
||||
String output;
|
||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||
|
||||
if (cr) {
|
||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||
|
|
|
@ -52,14 +52,14 @@ private:
|
|||
void WriteLine(const String& line);
|
||||
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 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 TriggerDowntimeHandler(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 EventCommandHandler(const Service::Ptr& service);
|
||||
void TriggerDowntimeHandler(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 EventCommandHandler(const Service::Ptr& service);
|
||||
|
||||
Timer::Ptr m_RotationTimer;
|
||||
void RotationTimerHandler(void);
|
||||
|
|
|
@ -269,7 +269,7 @@ Value HostsTable::CheckCommandExpandedAccessor(const Value& row)
|
|||
resolvers.push_back(commandObj);
|
||||
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;
|
||||
if (commandLine.IsObjectType<Array>()) {
|
||||
|
@ -403,10 +403,7 @@ Value HostsTable::NotesExpandedAccessor(const Value& row)
|
|||
|
||||
Value value = custom->Get("notes");
|
||||
|
||||
Dictionary::Ptr cr;
|
||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
||||
|
||||
return value_expanded;
|
||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||
}
|
||||
|
||||
Value HostsTable::NotesUrlAccessor(const Value& row)
|
||||
|
@ -451,10 +448,7 @@ Value HostsTable::NotesUrlExpandedAccessor(const Value& row)
|
|||
|
||||
Value value = custom->Get("notes_url");
|
||||
|
||||
Dictionary::Ptr cr;
|
||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
||||
|
||||
return value_expanded;
|
||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||
}
|
||||
|
||||
Value HostsTable::ActionUrlAccessor(const Value& row)
|
||||
|
@ -499,10 +493,7 @@ Value HostsTable::ActionUrlExpandedAccessor(const Value& row)
|
|||
|
||||
Value value = custom->Get("action_url");
|
||||
|
||||
Dictionary::Ptr cr;
|
||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
||||
|
||||
return value_expanded;
|
||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||
}
|
||||
|
||||
Value HostsTable::PluginOutputAccessor(const Value& row)
|
||||
|
@ -518,7 +509,7 @@ Value HostsTable::PluginOutputAccessor(const Value& row)
|
|||
|
||||
if(hc) {
|
||||
String output;
|
||||
Dictionary::Ptr cr = hc->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||
|
||||
if (cr) {
|
||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||
|
@ -541,7 +532,7 @@ Value HostsTable::PerfDataAccessor(const Value& row)
|
|||
String perfdata;
|
||||
|
||||
if (hc) {
|
||||
Dictionary::Ptr cr = hc->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||
|
||||
if (cr)
|
||||
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
||||
|
@ -593,10 +584,7 @@ Value HostsTable::IconImageExpandedAccessor(const Value& row)
|
|||
|
||||
Value value = custom->Get("icon_image");
|
||||
|
||||
Dictionary::Ptr cr;
|
||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
||||
|
||||
return value_expanded;
|
||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||
}
|
||||
|
||||
Value HostsTable::IconImageAltAccessor(const Value& row)
|
||||
|
@ -642,7 +630,7 @@ Value HostsTable::LongPluginOutputAccessor(const Value& row)
|
|||
|
||||
if (hc) {
|
||||
String long_output;
|
||||
Dictionary::Ptr cr = hc->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||
|
||||
if (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);
|
||||
|
||||
String output;
|
||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||
|
||||
if (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(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;
|
||||
if (commandLine.IsObjectType<Array>()) {
|
||||
|
@ -262,7 +262,7 @@ Value ServicesTable::PluginOutputAccessor(const Value& row)
|
|||
return Empty;
|
||||
|
||||
String output;
|
||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||
|
||||
if (cr) {
|
||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||
|
@ -280,7 +280,7 @@ Value ServicesTable::LongPluginOutputAccessor(const Value& row)
|
|||
return Empty;
|
||||
|
||||
String long_output;
|
||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||
|
||||
if (cr) {
|
||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||
|
@ -298,7 +298,7 @@ Value ServicesTable::PerfDataAccessor(const Value& row)
|
|||
return Empty;
|
||||
|
||||
String perfdata;
|
||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||
|
||||
if (cr)
|
||||
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
||||
|
@ -375,10 +375,7 @@ Value ServicesTable::NotesExpandedAccessor(const Value& row)
|
|||
|
||||
Value value = custom->Get("notes");
|
||||
|
||||
Dictionary::Ptr cr;
|
||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
||||
|
||||
return value_expanded;
|
||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||
}
|
||||
|
||||
Value ServicesTable::NotesUrlAccessor(const Value& row)
|
||||
|
@ -415,10 +412,7 @@ Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
|
|||
|
||||
Value value = custom->Get("notes_url");
|
||||
|
||||
Dictionary::Ptr cr;
|
||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
||||
|
||||
return value_expanded;
|
||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||
}
|
||||
|
||||
Value ServicesTable::ActionUrlAccessor(const Value& row)
|
||||
|
@ -455,10 +449,7 @@ Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
|
|||
|
||||
Value value = custom->Get("action_url");
|
||||
|
||||
Dictionary::Ptr cr;
|
||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
||||
|
||||
return value_expanded;
|
||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||
}
|
||||
|
||||
Value ServicesTable::IconImageAccessor(const Value& row)
|
||||
|
@ -495,10 +486,7 @@ Value ServicesTable::IconImageExpandedAccessor(const Value& row)
|
|||
|
||||
Value value = custom->Get("icon_image");
|
||||
|
||||
Dictionary::Ptr cr;
|
||||
Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
|
||||
|
||||
return value_expanded;
|
||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||
}
|
||||
|
||||
Value ServicesTable::IconImageAltAccessor(const Value& row)
|
||||
|
|
|
@ -105,7 +105,7 @@ void NotificationComponent::NotificationTimerHandler(void)
|
|||
* Processes icinga::SendNotifications messages.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
|
||||
void NotificationTimerHandler(void);
|
||||
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);
|
||||
}
|
||||
|
||||
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())
|
||||
return;
|
||||
|
@ -100,7 +100,7 @@ void GraphiteWriter::CheckResultHandler(const Service::Ptr& service, const Dicti
|
|||
SendMetric(prefix, "latency", Service::CalculateLatency(cr));
|
||||
SendMetric(prefix, "execution_time", Service::CalculateExecutionTime(cr));
|
||||
|
||||
Value pdv = cr->Get("performance_data");
|
||||
Value pdv = cr->GetPerformanceData();
|
||||
|
||||
if (!pdv.IsObjectType<Dictionary>())
|
||||
return;
|
||||
|
|
|
@ -45,15 +45,15 @@ protected:
|
|||
virtual void Start(void);
|
||||
|
||||
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);
|
||||
static void SanitizeMetric(String& str);
|
||||
|
||||
void ReconnectTimerHandler(void);
|
||||
void ReconnectTimerHandler(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ void PerfdataWriter::Start(void)
|
|||
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())
|
||||
return;
|
||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
|||
virtual void Start(void);
|
||||
|
||||
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;
|
||||
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,
|
||||
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();
|
||||
|
||||
|
@ -907,7 +907,7 @@ void ServiceDbObject::AddNotificationHistory(const Service::Ptr& service, const
|
|||
}
|
||||
|
||||
/* 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();
|
||||
|
||||
|
@ -961,14 +961,14 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const D
|
|||
}
|
||||
|
||||
/* 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();
|
||||
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
Dictionary::Ptr vars_after = cr->Get("vars_after");
|
||||
Dictionary::Ptr vars_after = cr->GetVarsAfter();
|
||||
|
||||
long state_after = vars_after->Get("state");
|
||||
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 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) {
|
||||
long state_before = vars_before->Get("state");
|
||||
|
@ -1008,12 +1008,12 @@ void ServiceDbObject::AddCheckResultLogHistory(const Service::Ptr& service, cons
|
|||
return;
|
||||
}
|
||||
|
||||
String output;
|
||||
String output;
|
||||
|
||||
if (cr) {
|
||||
if (cr) {
|
||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||
output = output_bag->Get("output");
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream msgbuf;
|
||||
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,
|
||||
NotificationType const& notification_type, Dictionary::Ptr const& cr,
|
||||
NotificationType notification_type, const CheckResult::Ptr& cr,
|
||||
const String& author, const String& comment_text)
|
||||
{
|
||||
Host::Ptr host = service->GetHost();
|
||||
|
@ -1153,42 +1153,42 @@ void ServiceDbObject::AddNotificationSentLogHistory(const Service::Ptr& service,
|
|||
author_comment = ";" + author + ";" + comment_text;
|
||||
}
|
||||
|
||||
if (!cr)
|
||||
return;
|
||||
if (!cr)
|
||||
return;
|
||||
|
||||
String output;
|
||||
String output;
|
||||
|
||||
if (cr) {
|
||||
if (cr) {
|
||||
Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
|
||||
output = output_bag->Get("output");
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream msgbuf;
|
||||
msgbuf << "SERVICE NOTIFICATION: "
|
||||
<< user->GetName() << ";"
|
||||
<< host->GetName() << ";"
|
||||
<< service->GetShortName() << ";"
|
||||
<< notification_type_str << " "
|
||||
<< "(" << Service::StateToString(service->GetState()) << ");"
|
||||
<< check_command << ";"
|
||||
<< output << author_comment
|
||||
<< "";
|
||||
std::ostringstream msgbuf;
|
||||
msgbuf << "SERVICE NOTIFICATION: "
|
||||
<< user->GetName() << ";"
|
||||
<< host->GetName() << ";"
|
||||
<< service->GetShortName() << ";"
|
||||
<< notification_type_str << " "
|
||||
<< "(" << Service::StateToString(service->GetState()) << ");"
|
||||
<< check_command << ";"
|
||||
<< output << author_comment
|
||||
<< "";
|
||||
|
||||
AddLogHistory(service, msgbuf.str(), LogEntryTypeServiceNotification);
|
||||
AddLogHistory(service, msgbuf.str(), LogEntryTypeServiceNotification);
|
||||
|
||||
if (service == host->GetCheckService()) {
|
||||
std::ostringstream msgbuf;
|
||||
msgbuf << "HOST NOTIFICATION: "
|
||||
<< user->GetName() << ";"
|
||||
<< host->GetName() << ";"
|
||||
<< notification_type_str << " "
|
||||
<< "(" << Service::StateToString(service->GetState()) << ");"
|
||||
<< check_command << ";"
|
||||
<< output << author_comment
|
||||
<< "";
|
||||
if (service == host->GetCheckService()) {
|
||||
std::ostringstream msgbuf;
|
||||
msgbuf << "HOST NOTIFICATION: "
|
||||
<< user->GetName() << ";"
|
||||
<< host->GetName() << ";"
|
||||
<< notification_type_str << " "
|
||||
<< "(" << Service::StateToString(service->GetState()) << ");"
|
||||
<< check_command << ";"
|
||||
<< output << author_comment
|
||||
<< "";
|
||||
|
||||
AddLogHistory(service, msgbuf.str(), LogEntryTypeHostNotification);
|
||||
}
|
||||
AddLogHistory(service, msgbuf.str(), LogEntryTypeHostNotification);
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceDbObject::AddFlappingLogHistory(const Service::Ptr& service, FlappingState flapping_state)
|
||||
|
@ -1338,7 +1338,7 @@ void ServiceDbObject::AddFlappingHistory(const Service::Ptr& service, FlappingSt
|
|||
}
|
||||
|
||||
/* 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();
|
||||
|
||||
|
@ -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("command_object_id", service->GetCheckCommand());
|
||||
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("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("long_output", attrs->Get("long_plugin_output"));
|
||||
fields1->Set("perfdata", attrs->Get("performance_data"));
|
||||
|
@ -1394,11 +1394,12 @@ void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const
|
|||
if (host->GetCheckService() == service) {
|
||||
query1.Table = "hostchecks";
|
||||
|
||||
fields1->Remove("service_object_id");
|
||||
fields1->Set("host_object_id", host);
|
||||
fields1->Set("state", host->GetState());
|
||||
fields1->Set("state_type", host->GetStateType());
|
||||
query1.Fields = fields1;
|
||||
Dictionary::Ptr fields2 = fields1->ShallowClone();
|
||||
fields2->Remove("service_object_id");
|
||||
fields2->Set("host_object_id", host);
|
||||
fields2->Set("state", host->GetState());
|
||||
fields2->Set("state_type", host->GetStateType());
|
||||
query1.Fields = fields2;
|
||||
OnQuery(query1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,17 +100,17 @@ private:
|
|||
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 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 AddStateChangeHistory(const Service::Ptr& service, const Dictionary::Ptr& cr, StateType type);
|
||||
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 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 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 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 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.
|
||||
|
||||
mkclass_target(checkcommand.ti checkcommand.th)
|
||||
mkclass_target(checkresult.ti checkresult.th)
|
||||
mkclass_target(command.ti command.th)
|
||||
mkclass_target(domain.ti domain.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)
|
||||
|
||||
add_library(icinga SHARED
|
||||
api.cpp api.h checkcommand.cpp checkcommand.th cib.cpp command.cpp command.th
|
||||
compatutility.cpp domain.cpp domain.th eventcommand.cpp eventcommand.th
|
||||
externalcommandprocessor.cpp host.cpp host.th hostgroup.cpp hostgroup.th
|
||||
icingaapplication.cpp icingaapplication.th macroprocessor.cpp
|
||||
macroresolver.cpp notificationcommand.cpp notificationcommand.th
|
||||
api.cpp api.h checkcommand.cpp checkcommand.th checkresult.cpp checkresult.th
|
||||
cib.cpp command.cpp command.th compatutility.cpp domain.cpp domain.th
|
||||
eventcommand.cpp eventcommand.th externalcommandprocessor.cpp host.cpp
|
||||
host.th hostgroup.cpp hostgroup.th icingaapplication.cpp icingaapplication.th
|
||||
macroprocessor.cpp macroresolver.cpp notificationcommand.cpp notificationcommand.th
|
||||
notification.cpp notification.th perfdatavalue.cpp perfdatavalue.th
|
||||
pluginutility.cpp service-check.cpp service-comment.cpp service.cpp
|
||||
service-downtime.cpp service-event.cpp service-flapping.cpp service.th
|
||||
|
|
|
@ -24,7 +24,7 @@ using namespace icinga;
|
|||
|
||||
REGISTER_TYPE(CheckCommand);
|
||||
|
||||
Dictionary::Ptr CheckCommand::Execute(const Service::Ptr& service)
|
||||
CheckResult::Ptr CheckCommand::Execute(const Service::Ptr& service)
|
||||
{
|
||||
std::vector<Value> arguments;
|
||||
arguments.push_back(service);
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
DECLARE_PTR_TYPEDEFS(CheckCommand);
|
||||
DECLARE_TYPENAME(CheckCommand);
|
||||
|
||||
virtual Dictionary::Ptr Execute(const Service::Ptr& service);
|
||||
virtual CheckResult::Ptr Execute(const Service::Ptr& service);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
|
@ -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 */
|
|
@ -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);
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
//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
|
||||
check_period_str = "24x7";
|
||||
|
||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||
|
||||
if (cr) {
|
||||
Dictionary::Ptr output_bag = GetCheckResultOutput(cr);
|
||||
output = output_bag->Get("output");
|
||||
long_output = output_bag->Get("long_output");
|
||||
|
||||
check_source = cr->Get("check_source");
|
||||
check_source = cr->GetCheckSource();
|
||||
|
||||
perfdata = GetCheckResultPerfdata(cr);
|
||||
schedule_end = cr->Get("schedule_end");
|
||||
schedule_end = cr->GetScheduleEnd();
|
||||
}
|
||||
|
||||
int state = service->GetState();
|
||||
|
@ -521,7 +521,7 @@ std::set<UserGroup::Ptr> CompatUtility::GetServiceNotificationUserGroups(const S
|
|||
return usergroups;
|
||||
}
|
||||
|
||||
Dictionary::Ptr CompatUtility::GetCheckResultOutput(const Dictionary::Ptr& cr)
|
||||
Dictionary::Ptr CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
|
||||
{
|
||||
if (!cr)
|
||||
return Empty;
|
||||
|
@ -530,7 +530,7 @@ Dictionary::Ptr CompatUtility::GetCheckResultOutput(const Dictionary::Ptr& cr)
|
|||
String output;
|
||||
Dictionary::Ptr bag = make_shared<Dictionary>();
|
||||
|
||||
String raw_output = cr->Get("output");
|
||||
String raw_output = cr->GetOutput();
|
||||
|
||||
/*
|
||||
* replace semi-colons with colons in output
|
||||
|
@ -554,12 +554,12 @@ Dictionary::Ptr CompatUtility::GetCheckResultOutput(const Dictionary::Ptr& cr)
|
|||
return bag;
|
||||
}
|
||||
|
||||
String CompatUtility::GetCheckResultPerfdata(const Dictionary::Ptr& cr)
|
||||
String CompatUtility::GetCheckResultPerfdata(const CheckResult::Ptr& cr)
|
||||
{
|
||||
if (!cr)
|
||||
return String();
|
||||
|
||||
return PluginUtility::FormatPerfdata(cr->Get("performance_data"));
|
||||
return PluginUtility::FormatPerfdata(cr->GetPerformanceData());
|
||||
}
|
||||
|
||||
String CompatUtility::EscapeString(const String& str)
|
||||
|
|
|
@ -59,8 +59,8 @@ public:
|
|||
static std::set<User::Ptr> GetServiceNotificationUsers(const Service::Ptr& service);
|
||||
static std::set<UserGroup::Ptr> GetServiceNotificationUserGroups(const Service::Ptr& service);
|
||||
|
||||
static Dictionary::Ptr GetCheckResultOutput(const Dictionary::Ptr& cr);
|
||||
static String GetCheckResultPerfdata(const Dictionary::Ptr& cr);
|
||||
static Dictionary::Ptr GetCheckResultOutput(const CheckResult::Ptr& cr);
|
||||
static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
|
||||
|
||||
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."));
|
||||
|
||||
int exitStatus = Convert::ToDouble(arguments[1]);
|
||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(arguments[2]);
|
||||
result->Set("state", PluginUtility::ExitStatusToState(exitStatus));
|
||||
CheckResult::Ptr result = PluginUtility::ParseCheckOutput(arguments[2]);
|
||||
result->SetState(PluginUtility::ExitStatusToState(exitStatus));
|
||||
|
||||
result->Set("schedule_start", time);
|
||||
result->Set("schedule_end", time);
|
||||
result->Set("execution_start", time);
|
||||
result->Set("execution_end", time);
|
||||
result->Set("active", 0);
|
||||
result->SetScheduleStart(time);
|
||||
result->SetScheduleEnd(time);
|
||||
result->SetExecutionStart(time);
|
||||
result->SetExecutionEnd(time);
|
||||
result->SetActive(false);
|
||||
|
||||
Log(LogInformation, "icinga", "Processing passive check result for host '" + arguments[0] + "'");
|
||||
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."));
|
||||
|
||||
int exitStatus = Convert::ToDouble(arguments[2]);
|
||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(arguments[3]);
|
||||
result->Set("state", PluginUtility::ExitStatusToState(exitStatus));
|
||||
CheckResult::Ptr result = PluginUtility::ParseCheckOutput(arguments[3]);
|
||||
result->SetState(PluginUtility::ExitStatusToState(exitStatus));
|
||||
|
||||
result->Set("schedule_start", time);
|
||||
result->Set("schedule_end", time);
|
||||
result->Set("execution_start", time);
|
||||
result->Set("execution_end", time);
|
||||
result->Set("active", 0);
|
||||
result->SetScheduleStart(time);
|
||||
result->SetScheduleEnd(time);
|
||||
result->SetExecutionStart(time);
|
||||
result->SetExecutionEnd(time);
|
||||
result->SetActive(false);
|
||||
|
||||
Log(LogInformation, "icinga", "Processing passive check result for service '" + arguments[1] + "'");
|
||||
service->ProcessCheckResult(result);
|
||||
|
|
|
@ -542,7 +542,7 @@ String Host::StateTypeToString(StateType type)
|
|||
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") {
|
||||
*result = GetName();
|
||||
|
@ -554,7 +554,7 @@ bool Host::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *res
|
|||
}
|
||||
|
||||
Service::Ptr hc = GetCheckService();
|
||||
Dictionary::Ptr hccr;
|
||||
CheckResult::Ptr hccr;
|
||||
|
||||
if (hc) {
|
||||
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));
|
||||
return true;
|
||||
} else if (macro == "HOSTOUTPUT") {
|
||||
*result = hccr->Get("output");
|
||||
*result = hccr->GetOutput();
|
||||
return true;
|
||||
} else if (macro == "HOSTPERFDATA") {
|
||||
*result = PluginUtility::FormatPerfdata(hccr->Get("performance_data"));
|
||||
*result = PluginUtility::FormatPerfdata(hccr->GetPerformanceData());
|
||||
return true;
|
||||
} else if (macro == "LASTHOSTCHECK") {
|
||||
*result = Convert::ToString((long)hccr->Get("schedule_start"));
|
||||
*result = Convert::ToString((long)hccr->GetScheduleStart());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "icinga/i2-icinga.h"
|
||||
#include "icinga/host.th"
|
||||
#include "icinga/macroresolver.h"
|
||||
#include "icinga/checkresult.h"
|
||||
#include "base/array.h"
|
||||
#include "base/dictionary.h"
|
||||
|
||||
|
@ -88,7 +89,7 @@ public:
|
|||
static StateType StateTypeFromString(const String& 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:
|
||||
virtual void Start(void);
|
||||
|
|
|
@ -3,32 +3,6 @@
|
|||
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
|
||||
{
|
||||
[config] String display_name {
|
||||
|
|
|
@ -93,7 +93,7 @@ Dictionary::Ptr IcingaApplication::GetMacros(void) const
|
|||
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();
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
String GetPidPath(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;
|
||||
void SetEnableNotifications(bool enabled);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
using namespace icinga;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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,
|
||||
const Dictionary::Ptr& cr, String *result)
|
||||
const CheckResult::Ptr& cr, String *result)
|
||||
{
|
||||
BOOST_FOREACH(const MacroResolver::Ptr& resolver, resolvers) {
|
||||
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,
|
||||
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;
|
||||
offset = 0;
|
||||
|
|
|
@ -41,15 +41,15 @@ public:
|
|||
typedef boost::function<String (const String&)> EscapeCallback;
|
||||
|
||||
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,
|
||||
const Dictionary::Ptr& cr, String *result);
|
||||
const CheckResult::Ptr& cr, String *result);
|
||||
|
||||
private:
|
||||
MacroProcessor(void);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void StaticMacroResolver::Add(const String& macro, const String& 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)) {
|
||||
*result = m_Macros->Get(macro);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define MACRORESOLVER_H
|
||||
|
||||
#include "icinga/i2-icinga.h"
|
||||
#include "icinga/checkresult.h"
|
||||
#include "base/dictionary.h"
|
||||
#include "base/qstring.h"
|
||||
|
||||
|
@ -37,7 +38,7 @@ class I2_ICINGA_API MacroResolver
|
|||
public:
|
||||
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
|
||||
|
@ -49,7 +50,7 @@ public:
|
|||
|
||||
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:
|
||||
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());
|
||||
|
||||
|
@ -240,7 +240,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const Diction
|
|||
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());
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
|
|
@ -74,11 +74,11 @@ public:
|
|||
void UpdateNotificationNumber(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);
|
||||
|
||||
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;
|
||||
|
||||
|
@ -87,7 +87,7 @@ protected:
|
|||
virtual void Stop(void);
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
std::vector<Value> arguments;
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
DECLARE_TYPENAME(NotificationCommand);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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 perfdata;
|
||||
|
@ -75,8 +75,8 @@ Dictionary::Ptr PluginUtility::ParseCheckOutput(const String& output)
|
|||
}
|
||||
}
|
||||
|
||||
result->Set("output", text);
|
||||
result->Set("performance_data", ParsePerfdata(perfdata));
|
||||
result->SetOutput(text);
|
||||
result->SetPerformanceData(ParsePerfdata(perfdata));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class I2_ICINGA_API PluginUtility
|
|||
{
|
||||
public:
|
||||
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 String FormatPerfdata(const Value& perfdata);
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
|
||||
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 Dictionary::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&, const CheckResult::Ptr&, const String&)> Service::OnNewCheckResult;
|
||||
boost::signals2::signal<void (const Service::Ptr&, const CheckResult::Ptr&, StateType, const String&)> Service::OnStateChange;
|
||||
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&, bool, const String&)> Service::OnForceNextCheckChanged;
|
||||
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
|
||||
{
|
||||
Dictionary::Ptr cr = GetLastCheckResult();
|
||||
CheckResult::Ptr cr = GetLastCheckResult();
|
||||
double schedule_end = -1;
|
||||
|
||||
if (cr)
|
||||
schedule_end = cr->Get("schedule_end");
|
||||
schedule_end = cr->GetScheduleEnd();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& authority)
|
||||
void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& authority)
|
||||
{
|
||||
double now = Utility::GetTime();
|
||||
|
||||
if (!cr->Contains("schedule_start"))
|
||||
cr->Set("schedule_start", now);
|
||||
if (cr->GetScheduleStart() == 0)
|
||||
cr->SetScheduleStart(now);
|
||||
|
||||
if (!cr->Contains("schedule_end"))
|
||||
cr->Set("schedule_end", now);
|
||||
if (cr->GetScheduleEnd() == 0)
|
||||
cr->SetScheduleEnd(now);
|
||||
|
||||
if (!cr->Contains("execution_start"))
|
||||
cr->Set("execution_start", now);
|
||||
if (cr->GetExecutionStart() == 0)
|
||||
cr->SetExecutionStart(now);
|
||||
|
||||
if (!cr->Contains("execution_end"))
|
||||
cr->Set("execution_end", now);
|
||||
if (cr->GetExecutionEnd() == 0)
|
||||
cr->SetExecutionEnd(now);
|
||||
|
||||
String check_source = cr->Get("check_source");
|
||||
String check_source = cr->GetCheckSource();
|
||||
|
||||
if (check_source.IsEmpty())
|
||||
cr->Set("check_source", authority);
|
||||
cr->SetCheckSource(authority);
|
||||
|
||||
bool reachable = IsReachable();
|
||||
|
||||
|
@ -212,13 +212,13 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
|
|||
ASSERT(!OwnsLock());
|
||||
ObjectLock olock(this);
|
||||
|
||||
Dictionary::Ptr old_cr = GetLastCheckResult();
|
||||
CheckResult::Ptr old_cr = GetLastCheckResult();
|
||||
ServiceState old_state = GetState();
|
||||
StateType old_stateType = GetStateType();
|
||||
long old_attempt = GetCheckAttempt();
|
||||
bool recovery;
|
||||
|
||||
if (old_cr && cr->Get("execution_start") < old_cr->Get("execution_start"))
|
||||
if (old_cr && cr->GetExecutionStart() < old_cr->GetExecutionStart())
|
||||
return;
|
||||
|
||||
/* 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;
|
||||
|
||||
if (cr->Get("state") == StateOK) {
|
||||
if (cr->GetState() == StateOK) {
|
||||
if (old_state == StateOK && old_stateType == StateTypeSoft)
|
||||
SetStateType(StateTypeHard); // SOFT OK -> HARD OK
|
||||
|
||||
|
@ -250,12 +250,17 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
|
|||
|
||||
recovery = false;
|
||||
|
||||
if (cr->Get("state") == StateWarning)
|
||||
SetLastStateWarning(Utility::GetTime());
|
||||
if (cr->Get("state") == StateCritical)
|
||||
SetLastStateCritical(Utility::GetTime());
|
||||
if (cr->Get("state") == StateUnknown)
|
||||
SetLastStateUnknown(Utility::GetTime());
|
||||
switch (cr->GetState()) {
|
||||
case StateWarning:
|
||||
SetLastStateWarning(Utility::GetTime());
|
||||
break;
|
||||
case StateCritical:
|
||||
SetLastStateCritical(Utility::GetTime());
|
||||
break;
|
||||
case StateUnknown:
|
||||
SetLastStateUnknown(Utility::GetTime());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!reachable)
|
||||
|
@ -263,8 +268,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
|
|||
|
||||
SetCheckAttempt(attempt);
|
||||
|
||||
int state = cr->Get("state");
|
||||
SetState(static_cast<ServiceState>(state));
|
||||
SetState(cr->GetState());
|
||||
|
||||
bool call_eventhandler = false;
|
||||
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);
|
||||
|
||||
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();
|
||||
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 */
|
||||
Dictionary::Ptr checkInfo = make_shared<Dictionary>();
|
||||
checkInfo->Set("schedule_start", GetNextCheck());
|
||||
checkInfo->Set("execution_start", Utility::GetTime());
|
||||
double before_check = Utility::GetTime();
|
||||
|
||||
Service::Ptr self = GetSelf();
|
||||
|
||||
Dictionary::Ptr result;
|
||||
CheckResult::Ptr result;
|
||||
|
||||
try {
|
||||
CheckCommand::Ptr command = GetCheckCommand();
|
||||
|
@ -482,32 +484,25 @@ void Service::ExecuteCheck(void)
|
|||
|
||||
Log(LogWarning, "icinga", message);
|
||||
|
||||
result = make_shared<Dictionary>();
|
||||
result->Set("state", StateUnknown);
|
||||
result->Set("output", message);
|
||||
result = make_shared<CheckResult>();
|
||||
result->SetState(StateUnknown);
|
||||
result->SetOutput(message);
|
||||
}
|
||||
|
||||
checkInfo->Set("execution_end", Utility::GetTime());
|
||||
checkInfo->Set("schedule_end", Utility::GetTime());
|
||||
double after_check = Utility::GetTime();
|
||||
|
||||
if (result) {
|
||||
if (!result->Contains("schedule_start"))
|
||||
result->Set("schedule_start", checkInfo->Get("schedule_start"));
|
||||
if (!result->GetScheduleStart() == 0)
|
||||
result->SetScheduleStart(before_check);
|
||||
|
||||
if (!result->Contains("schedule_end"))
|
||||
result->Set("schedule_end", checkInfo->Get("schedule_end"));
|
||||
if (!result->GetScheduleEnd() == 0)
|
||||
result->SetScheduleEnd(after_check);
|
||||
|
||||
if (!result->Contains("execution_start"))
|
||||
result->Set("execution_start", checkInfo->Get("execution_start"));
|
||||
if (!result->GetExecutionStart() == 0)
|
||||
result->SetExecutionStart(before_check);
|
||||
|
||||
if (!result->Contains("execution_end"))
|
||||
result->Set("execution_end", checkInfo->Get("execution_end"));
|
||||
|
||||
if (!result->Contains("macros"))
|
||||
result->Set("macros", checkInfo->Get("macros"));
|
||||
|
||||
if (!result->Contains("active"))
|
||||
result->Set("active", 1);
|
||||
if (!result->GetExecutionEnd() == 0)
|
||||
result->SetExecutionEnd(after_check);
|
||||
}
|
||||
|
||||
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;
|
||||
Value schedule_end = cr->Get("schedule_end");
|
||||
if (!schedule_end.IsEmpty())
|
||||
ts = static_cast<time_t>(schedule_end);
|
||||
else
|
||||
time_t ts = cr->GetScheduleEnd();
|
||||
|
||||
if (ts == 0)
|
||||
ts = static_cast<time_t>(Utility::GetTime());
|
||||
|
||||
Value active = cr->Get("active");
|
||||
if (active.IsEmpty() || static_cast<long>(active))
|
||||
if (cr->GetActive())
|
||||
CIB::UpdateActiveChecksStatistics(ts, 1);
|
||||
else
|
||||
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) {
|
||||
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);
|
||||
return cr->GetExecutionEnd() - cr->GetExecutionStart();
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
double latency = (cr->GetScheduleEnd() - cr->GetScheduleStart()) - CalculateExecutionTime(cr);
|
||||
|
||||
if (latency < 0)
|
||||
latency = 0;
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
|
||||
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 User::Ptr&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&, const String&)> Service::OnNotificationSentToUser;
|
||||
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 CheckResult::Ptr&, const String&, const String&, const String&)> Service::OnNotificationSentToUser;
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ void Service::SetModifiedAttributes(int flags)
|
|||
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") {
|
||||
*result = GetShortName();
|
||||
|
@ -391,13 +391,13 @@ bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, Strin
|
|||
*result = Convert::ToString(Service::CalculateExecutionTime(cr));
|
||||
return true;
|
||||
} else if (macro == "SERVICEOUTPUT") {
|
||||
*result = cr->Get("output");
|
||||
*result = cr->GetOutput();
|
||||
return true;
|
||||
} else if (macro == "SERVICEPERFDATA") {
|
||||
*result = PluginUtility::FormatPerfdata(cr->Get("performance_data"));
|
||||
*result = PluginUtility::FormatPerfdata(cr->GetPerformanceData());
|
||||
return true;
|
||||
} else if (macro == "LASTSERVICECHECK") {
|
||||
*result = Convert::ToString((long)cr->Get("execution_end"));
|
||||
*result = Convert::ToString((long)cr->GetExecutionEnd());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,16 +172,16 @@ public:
|
|||
bool GetForceNextCheck(void) const;
|
||||
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 ProcessCheckResult(const Dictionary::Ptr& cr, const String& authority = String());
|
||||
void ProcessCheckResult(const CheckResult::Ptr& cr, const String& authority = String());
|
||||
|
||||
int GetModifiedAttributes(void) const;
|
||||
void SetModifiedAttributes(int flags);
|
||||
|
||||
static double CalculateExecutionTime(const Dictionary::Ptr& cr);
|
||||
static double CalculateLatency(const Dictionary::Ptr& cr);
|
||||
static double CalculateExecutionTime(const CheckResult::Ptr& cr);
|
||||
static double CalculateLatency(const CheckResult::Ptr& cr);
|
||||
|
||||
static ServiceState StateFromString(const String& 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&)> OnEnableNotificationsChanged;
|
||||
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnableFlappingChanged;
|
||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnNewCheckResult;
|
||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, 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&, const User::Ptr&, const NotificationType&, const Dictionary::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 CheckResult::Ptr&, const String&)> OnNewCheckResult;
|
||||
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 CheckResult::Ptr&, const String&, const String&)> OnNotificationsRequested;
|
||||
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 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&)> OnCommentRemoved;
|
||||
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&)> 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 */
|
||||
static int GetNextDowntimeID(void);
|
||||
|
@ -261,7 +261,7 @@ public:
|
|||
bool GetEnableNotifications(void) const;
|
||||
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;
|
||||
void AddNotification(const Notification::Ptr& notification);
|
||||
|
|
|
@ -91,7 +91,7 @@ class Service : DynamicObject
|
|||
[state] bool last_reachable {
|
||||
default {{{ return true; }}}
|
||||
};
|
||||
[state] Dictionary::Ptr last_check_result;
|
||||
[state] CheckResult::Ptr last_check_result;
|
||||
[state] double last_state_change {
|
||||
default {{{ return Application::GetStartTime(); }}}
|
||||
};
|
||||
|
|
|
@ -66,7 +66,7 @@ TimePeriod::Ptr User::GetNotificationPeriod(void) const
|
|||
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") {
|
||||
*result = GetName();
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
/* Notifications */
|
||||
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:
|
||||
virtual void Stop(void);
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace icinga;
|
|||
|
||||
REGISTER_SCRIPTFUNCTION(NullCheck, &NullCheckTask::ScriptFunc);
|
||||
|
||||
Dictionary::Ptr NullCheckTask::ScriptFunc(const Service::Ptr&)
|
||||
CheckResult::Ptr NullCheckTask::ScriptFunc(const Service::Ptr&)
|
||||
{
|
||||
char name[255];
|
||||
|
||||
|
@ -43,10 +43,10 @@ Dictionary::Ptr NullCheckTask::ScriptFunc(const Service::Ptr&)
|
|||
Dictionary::Ptr perfdata = make_shared<Dictionary>();
|
||||
perfdata->Set("time", Utility::GetTime());
|
||||
|
||||
Dictionary::Ptr cr = make_shared<Dictionary>();
|
||||
cr->Set("output", output);
|
||||
cr->Set("performance_data", perfdata);
|
||||
cr->Set("state", StateOK);
|
||||
CheckResult::Ptr cr = make_shared<CheckResult>();
|
||||
cr->SetOutput(output);
|
||||
cr->SetPerformanceData(perfdata);
|
||||
cr->SetState(StateOK);
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace icinga
|
|||
class I2_METHODS_API NullCheckTask
|
||||
{
|
||||
public:
|
||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
||||
static CheckResult::Ptr ScriptFunc(const Service::Ptr& service);
|
||||
|
||||
private:
|
||||
NullCheckTask(void);
|
||||
|
|
|
@ -35,7 +35,7 @@ using namespace icinga;
|
|||
|
||||
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();
|
||||
Value raw_command = commandObj->GetCommandLine();
|
||||
|
@ -73,12 +73,12 @@ Dictionary::Ptr PluginCheckTask::ScriptFunc(const Service::Ptr& service)
|
|||
|
||||
String output = pr.Output;
|
||||
output.Trim();
|
||||
Dictionary::Ptr result = PluginUtility::ParseCheckOutput(output);
|
||||
result->Set("command", command);
|
||||
result->Set("state", PluginUtility::ExitStatusToState(pr.ExitStatus));
|
||||
result->Set("exit_state", pr.ExitStatus);
|
||||
result->Set("execution_start", pr.ExecutionStart);
|
||||
result->Set("execution_end", pr.ExecutionEnd);
|
||||
CheckResult::Ptr result = PluginUtility::ParseCheckOutput(output);
|
||||
result->SetCommand(command);
|
||||
result->SetState(PluginUtility::ExitStatusToState(pr.ExitStatus));
|
||||
result->SetExitStatus(pr.ExitStatus);
|
||||
result->SetExecutionStart(pr.ExecutionStart);
|
||||
result->SetExecutionEnd(pr.ExecutionEnd);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace icinga
|
|||
class I2_METHODS_API PluginCheckTask
|
||||
{
|
||||
public:
|
||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
||||
static CheckResult::Ptr ScriptFunc(const Service::Ptr& service);
|
||||
|
||||
private:
|
||||
PluginCheckTask(void);
|
||||
|
|
|
@ -33,7 +33,7 @@ using namespace icinga;
|
|||
|
||||
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)
|
||||
{
|
||||
NotificationCommand::Ptr commandObj = notification->GetNotificationCommand();
|
||||
|
|
|
@ -35,7 +35,7 @@ class I2_METHODS_API PluginNotificationTask
|
|||
{
|
||||
public:
|
||||
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);
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace icinga;
|
|||
|
||||
REGISTER_SCRIPTFUNCTION(RandomCheck, &RandomCheckTask::ScriptFunc);
|
||||
|
||||
Dictionary::Ptr RandomCheckTask::ScriptFunc(const Service::Ptr&)
|
||||
CheckResult::Ptr RandomCheckTask::ScriptFunc(const Service::Ptr&)
|
||||
{
|
||||
char name[255];
|
||||
|
||||
|
@ -43,10 +43,10 @@ Dictionary::Ptr RandomCheckTask::ScriptFunc(const Service::Ptr&)
|
|||
Dictionary::Ptr perfdata = make_shared<Dictionary>();
|
||||
perfdata->Set("time", Utility::GetTime());
|
||||
|
||||
Dictionary::Ptr cr = make_shared<Dictionary>();
|
||||
cr->Set("output", output);
|
||||
cr->Set("performance_data", perfdata);
|
||||
cr->Set("state", static_cast<ServiceState>(Utility::Random() % 4));
|
||||
CheckResult::Ptr cr = make_shared<CheckResult>();
|
||||
cr->SetOutput(output);
|
||||
cr->SetPerformanceData(perfdata);
|
||||
cr->SetState(static_cast<ServiceState>(Utility::Random() % 4));
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace icinga
|
|||
class RandomCheckTask
|
||||
{
|
||||
public:
|
||||
static Dictionary::Ptr ScriptFunc(const Service::Ptr& service);
|
||||
static CheckResult::Ptr ScriptFunc(const Service::Ptr& service);
|
||||
|
||||
private:
|
||||
RandomCheckTask(void);
|
||||
|
|
Loading…
Reference in New Issue