Ensure that icinga_min_version parameter is optional

Seen that here: https://github.com/Icinga/icinga2/issues/6319#issuecomment-390195058

refs #5960
refs #3998
This commit is contained in:
Michael Friedrich 2018-05-18 15:11:56 +02:00
parent 79b23fce3c
commit 4a68ed9a5f
1 changed files with 4 additions and 2 deletions

View File

@ -55,8 +55,10 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
resolvers.emplace_back("command", commandObj);
resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
String missingIcingaMinVersion;
String icingaMinVersion = MacroProcessor::ResolveMacros("$icinga_min_version$", resolvers, checkable->GetLastCheckResult(),
nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
&missingIcingaMinVersion, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
if (resolvedMacros && !useResolvedMacros)
return;
@ -175,7 +177,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
/* Return an error if the version is less than specified (optional). */
String parsedAppVersion = appVersion.SubStr(1,5);
if (!icingaMinVersion.IsEmpty() && Utility::CompareVersion(icingaMinVersion, parsedAppVersion) < 0) {
if (missingIcingaMinVersion.IsEmpty() && !icingaMinVersion.IsEmpty() && Utility::CompareVersion(icingaMinVersion, parsedAppVersion) < 0) {
output += "; Minimum version " + icingaMinVersion + " is not installed.";
cr->SetState(ServiceCritical);
}