mirror of https://github.com/Icinga/icinga2.git
Implement scheduling_source attribute (#6326)
* Implement scheduling_source attribute This implements the attribute `scheduling_source` for hosts and services to show which endpoint is running the scheduler for the check. refs #4814
This commit is contained in:
parent
89472a9e51
commit
da394b2ab0
|
@ -1180,6 +1180,7 @@ to represent its internal state. The following types are exposed via the [API](1
|
||||||
output | String | The check output.
|
output | String | The check output.
|
||||||
performance\_data | Array | Array of [performance data values](08-advanced-topics.md#advanced-value-types-perfdatavalue).
|
performance\_data | Array | Array of [performance data values](08-advanced-topics.md#advanced-value-types-perfdatavalue).
|
||||||
check\_source | String | Name of the node executing the check.
|
check\_source | String | Name of the node executing the check.
|
||||||
|
scheduling\_source | String | Name of the node scheduling the check.
|
||||||
state | Number | The current state (0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN).
|
state | Number | The current state (0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN).
|
||||||
command | Value | Array of command with shell-escaped arguments or command line string.
|
command | Value | Array of command with shell-escaped arguments or command line string.
|
||||||
execution\_start | Timestamp | Check execution start time (as a UNIX timestamp).
|
execution\_start | Timestamp | Check execution start time (as a UNIX timestamp).
|
||||||
|
|
|
@ -104,6 +104,7 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object,
|
||||||
cr->SetExecutionEnd(HttpUtility::GetLastParameter(params, "execution_end"));
|
cr->SetExecutionEnd(HttpUtility::GetLastParameter(params, "execution_end"));
|
||||||
|
|
||||||
cr->SetCheckSource(HttpUtility::GetLastParameter(params, "check_source"));
|
cr->SetCheckSource(HttpUtility::GetLastParameter(params, "check_source"));
|
||||||
|
cr->SetSchedulingSource(HttpUtility::GetLastParameter(params, "scheduling_source"));
|
||||||
|
|
||||||
Value perfData = params->Get("performance_data");
|
Value perfData = params->Get("performance_data");
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,9 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
|
||||||
if (cr->GetExecutionEnd() == 0)
|
if (cr->GetExecutionEnd() == 0)
|
||||||
cr->SetExecutionEnd(now);
|
cr->SetExecutionEnd(now);
|
||||||
|
|
||||||
|
if (!origin || origin->IsLocal())
|
||||||
|
cr->SetSchedulingSource(IcingaApplication::GetInstance()->GetNodeName());
|
||||||
|
|
||||||
Endpoint::Ptr command_endpoint = GetCommandEndpoint();
|
Endpoint::Ptr command_endpoint = GetCommandEndpoint();
|
||||||
|
|
||||||
if (cr->GetCheckSource().IsEmpty()) {
|
if (cr->GetCheckSource().IsEmpty()) {
|
||||||
|
|
|
@ -61,6 +61,7 @@ class CheckResult
|
||||||
};
|
};
|
||||||
|
|
||||||
[state] String check_source;
|
[state] String check_source;
|
||||||
|
[state] String scheduling_source;
|
||||||
[state] double ttl;
|
[state] double ttl;
|
||||||
|
|
||||||
[state] Dictionary::Ptr vars_before;
|
[state] Dictionary::Ptr vars_before;
|
||||||
|
|
|
@ -320,6 +320,9 @@ bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, Value *res
|
||||||
} else if (macro == "check_source") {
|
} else if (macro == "check_source") {
|
||||||
*result = cr->GetCheckSource();
|
*result = cr->GetCheckSource();
|
||||||
return true;
|
return true;
|
||||||
|
} else if (macro == "scheduling_source") {
|
||||||
|
*result = cr->GetSchedulingSource();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,6 +267,9 @@ bool Service::ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Valu
|
||||||
} else if (macro == "check_source") {
|
} else if (macro == "check_source") {
|
||||||
*result = cr->GetCheckSource();
|
*result = cr->GetCheckSource();
|
||||||
return true;
|
return true;
|
||||||
|
} else if (macro == "scheduling_source") {
|
||||||
|
*result = cr->GetSchedulingSource();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,4 +285,3 @@ std::pair<Host::Ptr, Service::Ptr> icinga::GetHostService(const Checkable::Ptr&
|
||||||
else
|
else
|
||||||
return std::make_pair(static_pointer_cast<Host>(checkable), nullptr);
|
return std::make_pair(static_pointer_cast<Host>(checkable), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue