mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 21:24:41 +02:00
IcingadbCheck::ScriptFunc(): take CheckResultProducer::Ptr
This commit is contained in:
parent
bd95cdb468
commit
8e6061f11e
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_FUNCTION_NONCONST(Internal, IcingadbCheck, &IcingadbCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
REGISTER_FUNCTION_NONCONST(Internal, IcingadbCheck, &IcingadbCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||||
|
|
||||||
static void ReportIcingadbCheck(
|
static void ReportIcingadbCheck(
|
||||||
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj,
|
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj,
|
||||||
const CheckResult::Ptr& cr, String output, ServiceState state)
|
const CheckResult::Ptr& cr, const CheckResultProducer::Ptr& producer, String output, ServiceState state)
|
||||||
{
|
{
|
||||||
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
||||||
double now = Utility::GetTime();
|
double now = Utility::GetTime();
|
||||||
@ -32,7 +32,7 @@ static void ReportIcingadbCheck(
|
|||||||
} else {
|
} else {
|
||||||
cr->SetState(state);
|
cr->SetState(state);
|
||||||
cr->SetOutput(output);
|
cr->SetOutput(output);
|
||||||
checkable->ProcessCheckResult(cr);
|
checkable->ProcessCheckResult(cr, producer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ double GetXMessageTs(const Array::Ptr& xMessage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
void IcingadbCheckTask::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)
|
||||||
{
|
{
|
||||||
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
|
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
|
||||||
|
|
||||||
@ -87,21 +87,21 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (icingadbName.IsEmpty()) {
|
if (icingadbName.IsEmpty()) {
|
||||||
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB UNKNOWN: Attribute 'icingadb_name' must be set.", ServiceUnknown);
|
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB UNKNOWN: Attribute 'icingadb_name' must be set.", ServiceUnknown);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto conn (IcingaDB::GetByName(icingadbName));
|
auto conn (IcingaDB::GetByName(icingadbName));
|
||||||
|
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB UNKNOWN: Icinga DB connection '" + icingadbName + "' does not exist.", ServiceUnknown);
|
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB UNKNOWN: Icinga DB connection '" + icingadbName + "' does not exist.", ServiceUnknown);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto redis (conn->GetConnection());
|
auto redis (conn->GetConnection());
|
||||||
|
|
||||||
if (!redis || !redis->GetConnected()) {
|
if (!redis || !redis->GetConnected()) {
|
||||||
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB CRITICAL: Not connected to Redis.", ServiceCritical);
|
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB CRITICAL: Not connected to Redis.", ServiceCritical);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
|
|||||||
xReadHistoryBacklog = std::move(replies.at(4));
|
xReadHistoryBacklog = std::move(replies.at(4));
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
ReportIcingadbCheck(
|
ReportIcingadbCheck(
|
||||||
checkable, commandObj, cr,
|
checkable, commandObj, cr, producer,
|
||||||
String("Icinga DB CRITICAL: Could not query Redis: ") + ex.what(), ServiceCritical
|
String("Icinga DB CRITICAL: Could not query Redis: ") + ex.what(), ServiceCritical
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@ -144,7 +144,7 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
|
|||||||
|
|
||||||
if (!xReadHeartbeat) {
|
if (!xReadHeartbeat) {
|
||||||
ReportIcingadbCheck(
|
ReportIcingadbCheck(
|
||||||
checkable, commandObj, cr,
|
checkable, commandObj, cr, producer,
|
||||||
"Icinga DB CRITICAL: The Icinga DB daemon seems to have never run. (Missing heartbeat)",
|
"Icinga DB CRITICAL: The Icinga DB daemon seems to have never run. (Missing heartbeat)",
|
||||||
ServiceCritical
|
ServiceCritical
|
||||||
);
|
);
|
||||||
@ -511,5 +511,5 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
|
|||||||
}
|
}
|
||||||
|
|
||||||
cr->SetPerformanceData(perfdata);
|
cr->SetPerformanceData(perfdata);
|
||||||
ReportIcingadbCheck(checkable, commandObj, cr, msgbuf.str(), state);
|
ReportIcingadbCheck(checkable, commandObj, cr, producer, msgbuf.str(), state);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class IcingadbCheckTask
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
static void 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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IcingadbCheckTask();
|
IcingadbCheckTask();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user