diff --git a/lib/methods/icingachecktask.cpp b/lib/methods/icingachecktask.cpp index 0c85de6d4..c5832aebe 100644 --- a/lib/methods/icingachecktask.cpp +++ b/lib/methods/icingachecktask.cpp @@ -174,9 +174,13 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes cr->SetState(ServiceWarning); } - /* Return an error if the version is less than specified (optional). */ - String parsedAppVersion = appVersion.SubStr(1,5); + /* Extract the version number of the running Icinga2 instance. + * We assume that appVersion will allways be something like 'v2.10.1-8-gaebe6da' and we want to extract '2.10.1'. + */ + int endOfVersionNumber = appVersion.FindFirstOf("-") - 1; + String parsedAppVersion = appVersion.SubStr(1, endOfVersionNumber); + /* Return an error if the version is less than specified (optional). */ if (missingIcingaMinVersion.IsEmpty() && !icingaMinVersion.IsEmpty() && Utility::CompareVersion(icingaMinVersion, parsedAppVersion) < 0) { output += "; Minimum version " + icingaMinVersion + " is not installed."; cr->SetState(ServiceCritical);