]> granicus.if.org Git - icinga2/commitdiff
Log warning message if 'set_if' argument cannot be evaluated properly
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 27 Aug 2014 16:29:08 +0000 (18:29 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 27 Aug 2014 16:29:08 +0000 (18:29 +0200)
fixes #6968

lib/icinga/pluginutility.cpp
test/config/6968.conf [new file with mode: 0644]

index f2b28018446cc6e12b73d67ec48c968aa7321644..41ad0fa925599a87635372b3690a14b64b38eb6b 100644 (file)
@@ -94,8 +94,17 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
                                        String set_if_resolved = MacroProcessor::ResolveMacros(set_if, macroResolvers,
                                                cr, &missingMacro);
 
-                                       if (!missingMacro.IsEmpty() || !Convert::ToLong(set_if_resolved))
+                                       if (!missingMacro.IsEmpty())
                                                continue;
+
+                                       try {
+                                               if (!Convert::ToLong(set_if_resolved))
+                                                       continue;
+                                       } catch (const std::exception& ex) {
+                                               /* tried to convert a string */
+                                               Log(LogWarning, "PluginUtility", "Error evaluating set_if value '" + set_if_resolved + "': " + ex.what());
+                                               continue;
+                                       }
                                }
                        }
                        else
@@ -213,10 +222,10 @@ Value PluginUtility::ParsePerfdata(const String& perfdata)
 {
        try {
                Dictionary::Ptr result = make_shared<Dictionary>();
-       
+
                size_t begin = 0;
                String multi_prefix;
-               
+
                for (;;) {
                        size_t eqp = perfdata.FindFirstOf('=', begin);
 
diff --git a/test/config/6968.conf b/test/config/6968.conf
new file mode 100644 (file)
index 0000000..170eea6
--- /dev/null
@@ -0,0 +1,28 @@
+object Host "6968-server" {
+  import "test-generic-host"
+  address = "127.0.0.1"
+}
+
+object Service "6968-test" {
+  import "test-generic-service"
+
+  host_name = "6968-server"
+  check_command = "6968-check_vmware"
+  vars.vmware_check = "vCenter_License_Status"
+}
+
+object CheckCommand "6968-check_vmware" {
+  import "plugin-check-command"
+
+  command = [ PluginDir + "/check_vmware.pl" ]
+  arguments = {
+    "--server" = "$address$" 
+    "--username" = "***" 
+    "--password" = "***" 
+    "--check" = { 
+      set_if = "$vmware_check$" 
+    }
+  }
+}
+
+