mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 08:34:20 +02:00
IdoCheckTask::ScriptFunc(): take CheckResultProducer::Ptr
This commit is contained in:
parent
de6270ab78
commit
bd95cdb468
@ -16,11 +16,11 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IdoCheck, &IdoCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IdoCheck, &IdoCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
static void ReportIdoCheck(
|
||||
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj,
|
||||
const CheckResult::Ptr& cr, String output, ServiceState state = ServiceUnknown
|
||||
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj, const CheckResult::Ptr& cr,
|
||||
const CheckResultProducer::Ptr& producer, String output, ServiceState state = ServiceUnknown
|
||||
)
|
||||
{
|
||||
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
||||
@ -36,12 +36,12 @@ static void ReportIdoCheck(
|
||||
} else {
|
||||
cr->SetState(state);
|
||||
cr->SetOutput(output);
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
||||
void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
ServiceState state;
|
||||
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
|
||||
@ -88,19 +88,19 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||
return;
|
||||
|
||||
if (idoType.IsEmpty()) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "Attribute 'ido_type' must be set.");
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "Attribute 'ido_type' must be set.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (idoName.IsEmpty()) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "Attribute 'ido_name' must be set.");
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "Attribute 'ido_name' must be set.");
|
||||
return;
|
||||
}
|
||||
|
||||
Type::Ptr type = Type::GetByName(idoType);
|
||||
|
||||
if (!type || !DbConnection::TypeInstance->IsAssignableFrom(type)) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "DB IDO type '" + idoType + "' is invalid.");
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO type '" + idoType + "' is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -110,14 +110,14 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||
DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));
|
||||
|
||||
if (!conn) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "DB IDO connection '" + idoName + "' does not exist.");
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO connection '" + idoName + "' does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
double qps = conn->GetQueryCount(60) / 60.0;
|
||||
|
||||
if (conn->IsPaused()) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "DB IDO connection is temporarily disabled on this cluster instance.", ServiceOK);
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO connection is temporarily disabled on this cluster instance.", ServiceOK);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -125,10 +125,10 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||
|
||||
if (!conn->GetConnected()) {
|
||||
if (conn->GetShouldConnect()) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "Could not connect to the database server.", ServiceCritical);
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "Could not connect to the database server.", ServiceCritical);
|
||||
} else {
|
||||
ReportIdoCheck(
|
||||
checkable, commandObj, cr,
|
||||
checkable, commandObj, cr, producer,
|
||||
"Not currently enabled: Another cluster instance is responsible for the IDO database.", ServiceOK
|
||||
);
|
||||
}
|
||||
@ -193,5 +193,5 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||
{ new PerfdataValue("pending_queries", pendingQueries, false, "", pendingQueriesWarning, pendingQueriesCritical) }
|
||||
}));
|
||||
|
||||
ReportIdoCheck(checkable, commandObj, cr, msgbuf.str(), state);
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, msgbuf.str(), state);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class IdoCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
IdoCheckTask();
|
||||
|
Loading…
x
Reference in New Issue
Block a user