Log warning message if 'set_if' argument cannot be evaluated properly

fixes #6968
This commit is contained in:
Michael Friedrich 2014-08-27 18:29:08 +02:00
parent 3d3ee08038
commit 094e964660
2 changed files with 40 additions and 3 deletions

View 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);

28
test/config/6968.conf Normal file
View File

@ -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$"
}
}
}