String idoName = MacroProcessor::ResolveMacros("$ido_name$", resolvers, checkable->GetLastCheckResult(),
nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+ String missingQueriesWarning;
+ String missingQueriesCritical;
+ String missingPendingQueriesWarning;
+ String missingPendingQueriesCritical;
+
+ double queriesWarning = MacroProcessor::ResolveMacros("$ido_queries_warning$", resolvers, checkable->GetLastCheckResult(),
+ &missingQueriesWarning, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+
+ double queriesCritical = MacroProcessor::ResolveMacros("$ido_queries_critical$", resolvers, checkable->GetLastCheckResult(),
+ &missingQueriesCritical, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+
+ double pendingQueriesWarning = MacroProcessor::ResolveMacros("$ido_pending_queries_warning$", resolvers, checkable->GetLastCheckResult(),
+ &missingPendingQueriesWarning, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+
+ double pendingQueriesCritical = MacroProcessor::ResolveMacros("$ido_pending_queries_critical$", resolvers, checkable->GetLastCheckResult(),
+ &missingPendingQueriesCritical, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+
if (resolvedMacros && !useResolvedMacros)
return;
if (idoType.IsEmpty()) {
- cr->SetOutput("Macro 'ido_type' must be set.");
+ cr->SetOutput("Attribute 'ido_type' must be set.");
cr->SetState(ServiceUnknown);
checkable->ProcessCheckResult(cr);
return;
}
if (idoName.IsEmpty()) {
- cr->SetOutput("Macro 'ido_name' must be set.");
+ cr->SetOutput("Attribute 'ido_name' must be set.");
cr->SetState(ServiceUnknown);
checkable->ProcessCheckResult(cr);
return;
Type::Ptr type = Type::GetByName(idoType);
if (!type || !DbConnection::TypeInstance->IsAssignableFrom(type)) {
- cr->SetOutput("IDO type '" + idoType + "' is invalid.");
+ cr->SetOutput("DB IDO type '" + idoType + "' is invalid.");
cr->SetState(ServiceUnknown);
checkable->ProcessCheckResult(cr);
return;
DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));
if (!conn) {
- cr->SetOutput("IDO connection '" + idoName + "' does not exist.");
+ cr->SetOutput("DB IDO connection '" + idoName + "' does not exist.");
cr->SetState(ServiceUnknown);
checkable->ProcessCheckResult(cr);
return;
double qps = conn->GetQueryCount(60) / 60.0;
if (conn->IsPaused()) {
- cr->SetOutput("IDO connection is temporarily disabled on this cluster instance.");
+ cr->SetOutput("DB IDO connection is temporarily disabled on this cluster instance.");
cr->SetState(ServiceOK);
checkable->ProcessCheckResult(cr);
return;
}
+ double pendingQueries = conn->GetPendingQueryCount();
+
if (!conn->GetConnected()) {
if (conn->GetShouldConnect()) {
cr->SetOutput("Could not connect to the database server.");
cr->SetOutput("Not currently enabled: Another cluster instance is responsible for the IDO database.");
cr->SetState(ServiceOK);
}
+
+ checkable->ProcessCheckResult(cr);
+
+ return;
+ }
+
+ /* Schema versions. */
+ String schema_version = conn->GetSchemaVersion();
+ std::ostringstream msgbuf;
+
+ if (Utility::CompareVersion(IDO_CURRENT_SCHEMA_VERSION, schema_version) < 0) {
+ msgbuf << "Outdated schema version: '" << schema_version << "'. Latest version: '"
+ << IDO_CURRENT_SCHEMA_VERSION << "'."
+ << " Queries per second: " << std::fixed << std::setprecision(3) << qps
+ << " Pending queries: " << std::fixed << std::setprecision(3) << pendingQueries << ".";
+
+ cr->SetState(ServiceWarning);
} else {
- String schema_version = conn->GetSchemaVersion();
- std::ostringstream msgbuf;
+ msgbuf << "Connected to the database server (Schema version: '" << schema_version << "')."
+ << " Queries per second: " << std::fixed << std::setprecision(3) << qps
+ << " Pending queries: " << std::fixed << std::setprecision(3) << pendingQueries << ".";
- if (Utility::CompareVersion(IDO_CURRENT_SCHEMA_VERSION, schema_version) < 0) {
- msgbuf << "Outdated schema version: '" << schema_version << "'. Latest version: '" << IDO_CURRENT_SCHEMA_VERSION << "'.";
- cr->SetState(ServiceWarning);
- } else {
- msgbuf << "Connected to the database server (Schema version: '" << schema_version << "').";
- cr->SetState(ServiceOK);
- }
+ cr->SetState(ServiceOK);
+ }
+
+ /* Check whether the thresholds have been defined and match. */
+ if (missingQueriesCritical.IsEmpty() && qps < queriesCritical) {
+ msgbuf << " " << qps << " queries/s lower than critical threshold (" << queriesCritical << " queries/s).";
- msgbuf << " Queries per second: " << std::fixed << std::setprecision(3) << qps;
+ cr->SetState(ServiceCritical);
+ } else if (missingQueriesWarning.IsEmpty() && qps < queriesWarning) {
+ msgbuf << " " << qps << " queries/s lower than warning threshold (" << queriesWarning << " queries/s).";
- cr->SetOutput(msgbuf.str());
+ cr->SetState(ServiceWarning);
}
+ if (missingPendingQueriesCritical.IsEmpty() && pendingQueries > pendingQueriesCritical) {
+ msgbuf << " " << pendingQueries << " pending queries greater than critical threshold ("
+ << pendingQueriesCritical << " queries).";
+
+ cr->SetState(ServiceCritical);
+ } else if (missingPendingQueriesWarning.IsEmpty() && pendingQueries > pendingQueriesWarning) {
+ msgbuf << " " << pendingQueries << " pending queries greater than warning threshold ("
+ << pendingQueriesWarning << " queries).";
+
+ cr->SetState(ServiceWarning);
+ }
+
+ cr->SetOutput(msgbuf.str());
+
Array::Ptr perfdata = new Array();
- perfdata->Add(new PerfdataValue("queries", qps));
+ perfdata->Add(new PerfdataValue("queries", qps, false, "", queriesWarning, queriesCritical));
perfdata->Add(new PerfdataValue("queries_1min", conn->GetQueryCount(60)));
perfdata->Add(new PerfdataValue("queries_5mins", conn->GetQueryCount(5 * 60)));
perfdata->Add(new PerfdataValue("queries_15mins", conn->GetQueryCount(15 * 60)));
- perfdata->Add(new PerfdataValue("pending_queries", conn->GetPendingQueryCount()));
+ perfdata->Add(new PerfdataValue("pending_queries", pendingQueries, false, "", pendingQueriesWarning, pendingQueriesCritical));
+
cr->SetPerformanceData(perfdata);
checkable->ProcessCheckResult(cr);