Skip to content

Commit 170e7cf

Browse files
committed
*Check*::ScriptFunc(): take CheckResultProducer::Ptr
1 parent c124f4b commit 170e7cf

24 files changed

+75
-74
lines changed

lib/db_ido/idochecktask.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
using namespace icinga;
1818

19-
REGISTER_FUNCTION_NONCONST(Internal, IdoCheck, &IdoCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
19+
REGISTER_FUNCTION_NONCONST(Internal, IdoCheck, &IdoCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
2020

2121
static void ReportIdoCheck(
22-
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj,
23-
const CheckResult::Ptr& cr, String output, ServiceState state = ServiceUnknown
22+
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj, const CheckResult::Ptr& cr,
23+
const CheckResultProducer::Ptr& producer, String output, ServiceState state = ServiceUnknown
2424
)
2525
{
2626
if (Checkable::ExecuteCommandProcessFinishedHandler) {
@@ -36,12 +36,12 @@ static void ReportIdoCheck(
3636
} else {
3737
cr->SetState(state);
3838
cr->SetOutput(output);
39-
checkable->ProcessCheckResult(cr);
39+
checkable->ProcessCheckResult(cr, producer);
4040
}
4141
}
4242

4343
void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
44-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
44+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
4545
{
4646
ServiceState state;
4747
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
@@ -88,19 +88,19 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
8888
return;
8989

9090
if (idoType.IsEmpty()) {
91-
ReportIdoCheck(checkable, commandObj, cr, "Attribute 'ido_type' must be set.");
91+
ReportIdoCheck(checkable, commandObj, cr, producer, "Attribute 'ido_type' must be set.");
9292
return;
9393
}
9494

9595
if (idoName.IsEmpty()) {
96-
ReportIdoCheck(checkable, commandObj, cr, "Attribute 'ido_name' must be set.");
96+
ReportIdoCheck(checkable, commandObj, cr, producer, "Attribute 'ido_name' must be set.");
9797
return;
9898
}
9999

100100
Type::Ptr type = Type::GetByName(idoType);
101101

102102
if (!type || !DbConnection::TypeInstance->IsAssignableFrom(type)) {
103-
ReportIdoCheck(checkable, commandObj, cr, "DB IDO type '" + idoType + "' is invalid.");
103+
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO type '" + idoType + "' is invalid.");
104104
return;
105105
}
106106

@@ -110,25 +110,25 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
110110
DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));
111111

112112
if (!conn) {
113-
ReportIdoCheck(checkable, commandObj, cr, "DB IDO connection '" + idoName + "' does not exist.");
113+
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO connection '" + idoName + "' does not exist.");
114114
return;
115115
}
116116

117117
double qps = conn->GetQueryCount(60) / 60.0;
118118

119119
if (conn->IsPaused()) {
120-
ReportIdoCheck(checkable, commandObj, cr, "DB IDO connection is temporarily disabled on this cluster instance.", ServiceOK);
120+
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO connection is temporarily disabled on this cluster instance.", ServiceOK);
121121
return;
122122
}
123123

124124
double pendingQueries = conn->GetPendingQueryCount();
125125

126126
if (!conn->GetConnected()) {
127127
if (conn->GetShouldConnect()) {
128-
ReportIdoCheck(checkable, commandObj, cr, "Could not connect to the database server.", ServiceCritical);
128+
ReportIdoCheck(checkable, commandObj, cr, producer, "Could not connect to the database server.", ServiceCritical);
129129
} else {
130130
ReportIdoCheck(
131-
checkable, commandObj, cr,
131+
checkable, commandObj, cr, producer,
132132
"Not currently enabled: Another cluster instance is responsible for the IDO database.", ServiceOK
133133
);
134134
}
@@ -193,5 +193,5 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
193193
{ new PerfdataValue("pending_queries", pendingQueries, false, "", pendingQueriesWarning, pendingQueriesCritical) }
194194
}));
195195

196-
ReportIdoCheck(checkable, commandObj, cr, msgbuf.str(), state);
196+
ReportIdoCheck(checkable, commandObj, cr, producer, msgbuf.str(), state);
197197
}

lib/db_ido/idochecktask.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class IdoCheckTask
1818
{
1919
public:
2020
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
21-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
21+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
2222

2323
private:
2424
IdoCheckTask();

lib/icingadb/icingadbchecktask.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
using namespace icinga;
1515

16-
REGISTER_FUNCTION_NONCONST(Internal, IcingadbCheck, &IcingadbCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
16+
REGISTER_FUNCTION_NONCONST(Internal, IcingadbCheck, &IcingadbCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
1717

1818
static void ReportIcingadbCheck(
1919
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj,
20-
const CheckResult::Ptr& cr, String output, ServiceState state)
20+
const CheckResult::Ptr& cr, const CheckResultProducer::Ptr& producer, String output, ServiceState state)
2121
{
2222
if (Checkable::ExecuteCommandProcessFinishedHandler) {
2323
double now = Utility::GetTime();
@@ -32,7 +32,7 @@ static void ReportIcingadbCheck(
3232
} else {
3333
cr->SetState(state);
3434
cr->SetOutput(output);
35-
checkable->ProcessCheckResult(cr);
35+
checkable->ProcessCheckResult(cr, producer);
3636
}
3737
}
3838

@@ -43,7 +43,7 @@ double GetXMessageTs(const Array::Ptr& xMessage)
4343
}
4444

4545
void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
46-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
46+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
4747
{
4848
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
4949

@@ -87,21 +87,21 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
8787
return;
8888

8989
if (icingadbName.IsEmpty()) {
90-
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB UNKNOWN: Attribute 'icingadb_name' must be set.", ServiceUnknown);
90+
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB UNKNOWN: Attribute 'icingadb_name' must be set.", ServiceUnknown);
9191
return;
9292
}
9393

9494
auto conn (IcingaDB::GetByName(icingadbName));
9595

9696
if (!conn) {
97-
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB UNKNOWN: Icinga DB connection '" + icingadbName + "' does not exist.", ServiceUnknown);
97+
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB UNKNOWN: Icinga DB connection '" + icingadbName + "' does not exist.", ServiceUnknown);
9898
return;
9999
}
100100

101101
auto redis (conn->GetConnection());
102102

103103
if (!redis || !redis->GetConnected()) {
104-
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB CRITICAL: Not connected to Redis.", ServiceCritical);
104+
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB CRITICAL: Not connected to Redis.", ServiceCritical);
105105
return;
106106
}
107107

@@ -136,15 +136,15 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
136136
xReadHistoryBacklog = std::move(replies.at(4));
137137
} catch (const std::exception& ex) {
138138
ReportIcingadbCheck(
139-
checkable, commandObj, cr,
139+
checkable, commandObj, cr, producer,
140140
String("Icinga DB CRITICAL: Could not query Redis: ") + ex.what(), ServiceCritical
141141
);
142142
return;
143143
}
144144

145145
if (!xReadHeartbeat) {
146146
ReportIcingadbCheck(
147-
checkable, commandObj, cr,
147+
checkable, commandObj, cr, producer,
148148
"Icinga DB CRITICAL: The Icinga DB daemon seems to have never run. (Missing heartbeat)",
149149
ServiceCritical
150150
);
@@ -511,5 +511,5 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
511511
}
512512

513513
cr->SetPerformanceData(perfdata);
514-
ReportIcingadbCheck(checkable, commandObj, cr, msgbuf.str(), state);
514+
ReportIcingadbCheck(checkable, commandObj, cr, producer, msgbuf.str(), state);
515515
}

lib/icingadb/icingadbchecktask.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class IcingadbCheckTask
1818
{
1919
public:
2020
static void ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
21-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
21+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
2222

2323
private:
2424
IcingadbCheckTask();

lib/methods/clusterchecktask.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
using namespace icinga;
1919

20-
REGISTER_FUNCTION_NONCONST(Internal, ClusterCheck, &ClusterCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
20+
REGISTER_FUNCTION_NONCONST(Internal, ClusterCheck, &ClusterCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
2121

2222
void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
23-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
23+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
2424
{
2525
REQUIRE_NOT_NULL(checkable);
2626
REQUIRE_NOT_NULL(cr);
@@ -47,7 +47,7 @@ void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRe
4747
} else {
4848
cr->SetOutput(output);
4949
cr->SetState(ServiceUnknown);
50-
checkable->ProcessCheckResult(cr);
50+
checkable->ProcessCheckResult(cr, producer);
5151
}
5252

5353
return;
@@ -92,7 +92,7 @@ void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRe
9292
cr->SetState(state);
9393
cr->SetOutput(output);
9494

95-
checkable->ProcessCheckResult(cr);
95+
checkable->ProcessCheckResult(cr, producer);
9696
}
9797
}
9898

lib/methods/clusterchecktask.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ClusterCheckTask
1717
{
1818
public:
1919
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
20-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
20+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
2121

2222
private:
2323
ClusterCheckTask();

lib/methods/clusterzonechecktask.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
using namespace icinga;
1414

15-
REGISTER_FUNCTION_NONCONST(Internal, ClusterZoneCheck, &ClusterZoneCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
15+
REGISTER_FUNCTION_NONCONST(Internal, ClusterZoneCheck, &ClusterZoneCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
1616

1717
void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
18-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
18+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
1919
{
2020
REQUIRE_NOT_NULL(checkable);
2121
REQUIRE_NOT_NULL(cr);
@@ -42,7 +42,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
4242
cr->SetCommand(commandName);
4343
cr->SetOutput(output);
4444
cr->SetState(state);
45-
checkable->ProcessCheckResult(cr);
45+
checkable->ProcessCheckResult(cr, producer);
4646
}
4747

4848
return;
@@ -97,7 +97,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
9797
cr->SetCommand(commandName);
9898
cr->SetOutput(output);
9999
cr->SetState(state);
100-
checkable->ProcessCheckResult(cr);
100+
checkable->ProcessCheckResult(cr, producer);
101101
}
102102

103103
return;
@@ -123,7 +123,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
123123
cr->SetCommand(commandName);
124124
cr->SetOutput(output);
125125
cr->SetState(state);
126-
checkable->ProcessCheckResult(cr);
126+
checkable->ProcessCheckResult(cr, producer);
127127
}
128128
return;
129129
}
@@ -213,6 +213,6 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
213213
new PerfdataValue("sum_bytes_received_per_second", bytesReceivedPerSecond)
214214
}));
215215

216-
checkable->ProcessCheckResult(cr);
216+
checkable->ProcessCheckResult(cr, producer);
217217
}
218218
}

lib/methods/clusterzonechecktask.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ClusterZoneCheckTask
1717
{
1818
public:
1919
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
20-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
20+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
2121

2222
private:
2323
ClusterZoneCheckTask();

lib/methods/dummychecktask.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
using namespace icinga;
1515

16-
REGISTER_FUNCTION_NONCONST(Internal, DummyCheck, &DummyCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
16+
REGISTER_FUNCTION_NONCONST(Internal, DummyCheck, &DummyCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
1717

1818
void DummyCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
19-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
19+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
2020
{
2121
REQUIRE_NOT_NULL(checkable);
2222
REQUIRE_NOT_NULL(cr);
@@ -70,6 +70,6 @@ void DummyCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResu
7070
cr->SetExecutionEnd(now);
7171
cr->SetCommand(commandName);
7272

73-
checkable->ProcessCheckResult(cr);
73+
checkable->ProcessCheckResult(cr, producer);
7474
}
7575
}

lib/methods/dummychecktask.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DummyCheckTask
1919
{
2020
public:
2121
static void ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
22-
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
22+
const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
2323

2424
private:
2525
DummyCheckTask();

0 commit comments

Comments
 (0)