| 21 | REGISTER_FUNCTION_NONCONST(Internal, IcingaCheck, &IcingaCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros"); |
| 22 | |
| 23 | void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, |
| 24 | const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros) |
| 25 | { |
| 26 | REQUIRE_NOT_NULL(checkable); |
| 27 | REQUIRE_NOT_NULL(cr); |
| 28 | |
| 29 | CheckCommand::Ptr command = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand(); |
| 30 | |
| 31 | Host::Ptr host; |
| 32 | Service::Ptr service; |
| 33 | tie(host, service) = GetHostService(checkable); |
| 34 | |
| 35 | MacroProcessor::ResolverList resolvers; |
| 36 | |
| 37 | if (MacroResolver::OverrideMacros) |
| 38 | resolvers.emplace_back("override", MacroResolver::OverrideMacros); |
| 39 | |
| 40 | if (service) |
| 41 | resolvers.emplace_back("service", service); |
| 42 | resolvers.emplace_back("host", host); |
| 43 | resolvers.emplace_back("command", command); |
| 44 | |
| 45 | String missingIcingaMinVersion; |
| 46 | |
| 47 | String icingaMinVersion = MacroProcessor::ResolveMacros("$icinga_min_version$", resolvers, checkable->GetLastCheckResult(), |
| 48 | &missingIcingaMinVersion, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros); |
| 49 | |
| 50 | if (resolvedMacros && !useResolvedMacros) |
| 51 | return; |
| 52 | |
| 53 | double interval = Utility::GetTime() - Application::GetStartTime(); |
| 54 | |
| 55 | if (interval > 60) |
| 56 | interval = 60; |
| 57 | |
| 58 | /* use feature stats perfdata */ |
| 59 | std::pair<Dictionary::Ptr, Array::Ptr> feature_stats = CIB::GetFeatureStats(); |
| 60 | |
| 61 | Array::Ptr perfdata = feature_stats.second; |
| 62 | |
| 63 | perfdata->Add(new PerfdataValue("active_host_checks", CIB::GetActiveHostChecksStatistics(interval) / interval)); |
| 64 | perfdata->Add(new PerfdataValue("passive_host_checks", CIB::GetPassiveHostChecksStatistics(interval) / interval)); |
| 65 | perfdata->Add(new PerfdataValue("active_host_checks_1min", CIB::GetActiveHostChecksStatistics(60))); |
| 66 | perfdata->Add(new PerfdataValue("passive_host_checks_1min", CIB::GetPassiveHostChecksStatistics(60))); |
| 67 | perfdata->Add(new PerfdataValue("active_host_checks_5min", CIB::GetActiveHostChecksStatistics(60 * 5))); |
| 68 | perfdata->Add(new PerfdataValue("passive_host_checks_5min", CIB::GetPassiveHostChecksStatistics(60 * 5))); |
| 69 | perfdata->Add(new PerfdataValue("active_host_checks_15min", CIB::GetActiveHostChecksStatistics(60 * 15))); |
| 70 | perfdata->Add(new PerfdataValue("passive_host_checks_15min", CIB::GetPassiveHostChecksStatistics(60 * 15))); |
| 71 | |
| 72 | perfdata->Add(new PerfdataValue("active_service_checks", CIB::GetActiveServiceChecksStatistics(interval) / interval)); |
| 73 | perfdata->Add(new PerfdataValue("passive_service_checks", CIB::GetPassiveServiceChecksStatistics(interval) / interval)); |
| 74 | perfdata->Add(new PerfdataValue("active_service_checks_1min", CIB::GetActiveServiceChecksStatistics(60))); |
| 75 | perfdata->Add(new PerfdataValue("passive_service_checks_1min", CIB::GetPassiveServiceChecksStatistics(60))); |
| 76 | perfdata->Add(new PerfdataValue("active_service_checks_5min", CIB::GetActiveServiceChecksStatistics(60 * 5))); |
| 77 | perfdata->Add(new PerfdataValue("passive_service_checks_5min", CIB::GetPassiveServiceChecksStatistics(60 * 5))); |
| 78 | perfdata->Add(new PerfdataValue("active_service_checks_15min", CIB::GetActiveServiceChecksStatistics(60 * 15))); |
| 79 | perfdata->Add(new PerfdataValue("passive_service_checks_15min", CIB::GetPassiveServiceChecksStatistics(60 * 15))); |
| 80 |
nothing calls this directly
no test coverage detected