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;
|
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(
|
static void ReportIdoCheck(
|
||||||
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj,
|
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj, const CheckResult::Ptr& cr,
|
||||||
const CheckResult::Ptr& cr, String output, ServiceState state = ServiceUnknown
|
const CheckResultProducer::Ptr& producer, String output, ServiceState state = ServiceUnknown
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
||||||
@ -36,12 +36,12 @@ static void ReportIdoCheck(
|
|||||||
} else {
|
} else {
|
||||||
cr->SetState(state);
|
cr->SetState(state);
|
||||||
cr->SetOutput(output);
|
cr->SetOutput(output);
|
||||||
checkable->ProcessCheckResult(cr);
|
checkable->ProcessCheckResult(cr, producer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
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;
|
ServiceState state;
|
||||||
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
|
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
|
||||||
@ -88,19 +88,19 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (idoType.IsEmpty()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idoName.IsEmpty()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type::Ptr type = Type::GetByName(idoType);
|
Type::Ptr type = Type::GetByName(idoType);
|
||||||
|
|
||||||
if (!type || !DbConnection::TypeInstance->IsAssignableFrom(type)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,14 +110,14 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
|||||||
DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));
|
DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));
|
||||||
|
|
||||||
if (!conn) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double qps = conn->GetQueryCount(60) / 60.0;
|
double qps = conn->GetQueryCount(60) / 60.0;
|
||||||
|
|
||||||
if (conn->IsPaused()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,10 +125,10 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
|||||||
|
|
||||||
if (!conn->GetConnected()) {
|
if (!conn->GetConnected()) {
|
||||||
if (conn->GetShouldConnect()) {
|
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 {
|
} else {
|
||||||
ReportIdoCheck(
|
ReportIdoCheck(
|
||||||
checkable, commandObj, cr,
|
checkable, commandObj, cr, producer,
|
||||||
"Not currently enabled: Another cluster instance is responsible for the IDO database.", ServiceOK
|
"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) }
|
{ 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:
|
public:
|
||||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
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:
|
private:
|
||||||
IdoCheckTask();
|
IdoCheckTask();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user