mirror of https://github.com/Icinga/icinga2.git
Log warning message if 'set_if' argument cannot be evaluated properly
fixes #6968
This commit is contained in:
parent
3d3ee08038
commit
094e964660
|
@ -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);
|
||||
|
||||
|
|
|
@ -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$"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue