From 1c9e985f1dcaf01e951c77ae46262ab46ea9fbfe Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 29 Apr 2014 10:41:32 +0200 Subject: [PATCH] Rename "optional" attribute to "required" and change the default value. Fixes #6069 --- itl/command-common.conf | 45 ++++++++---------------------------- lib/icinga/icinga-type.conf | 2 +- lib/icinga/pluginutility.cpp | 7 +++--- 3 files changed, 14 insertions(+), 40 deletions(-) diff --git a/itl/command-common.conf b/itl/command-common.conf index fa1a38974..16502c3c0 100644 --- a/itl/command-common.conf +++ b/itl/command-common.conf @@ -28,14 +28,8 @@ template CheckCommand "ping-common" { "-H" = "$ping_address$" "-w" = "$ping_wrta$,$ping_wpl$%" "-c" = "$ping_crta$,$ping_cpl$%" - "-p" = { - value = "$ping_packets$" - optional = true - } - "-t" = { - value = "$ping_timeout$" - optional = true - } + "-p" = "$ping_packets$" + "-t" = "$ping_timeout$" } vars.ping_wrta = 100 @@ -120,30 +114,15 @@ object CheckCommand "http" { command = PluginDir + "/check_http" arguments = { - "-H" = { - value = "$http_vhost$" - optional = true - } + "-H" = "$http_vhost$" "-I" = "$http_address$" - "-u" = { - value = "$http_uri$" - optional = true - } - "-p" = { - value = "$http_port$" - optional = true - } + "-u" = "$http_uri$" + "-p" = "$http_port$" "-S" = { set_if = "$http_ssl$" } - "-w" = { - value = "$http_warn_time$" - optional = true - } - "-c" = { - value = "$http_critical_time$" - optional = true - } + "-w" = "$http_warn_time$" + "-c" = "$http_critical_time$" } vars.http_address = "$address$" @@ -169,10 +148,7 @@ object CheckCommand "ssmtp" { arguments = { "-H" = "$ssmtp_address$" - "-p" = { - value = "$ssmtp_port$" - optional = true - } + "-p" = "$ssmtp_port$" } vars.ssmtp_address = "$address$" @@ -196,10 +172,7 @@ object CheckCommand "ssh" { command = PluginDir + "/check_ssh" arguments = { - "-p" = { - value = "$ssh_port$" - optional = true - } + "-p" = "$ssh_port$" "host" = { value = "$ssh_address$" skip_key = true diff --git a/lib/icinga/icinga-type.conf b/lib/icinga/icinga-type.conf index cedebc460..43e493ab4 100644 --- a/lib/icinga/icinga-type.conf +++ b/lib/icinga/icinga-type.conf @@ -207,7 +207,7 @@ %attribute %dictionary "*" { %attribute %string "value" %attribute %string "description" - %attribute %number "optional" + %attribute %number "required" %attribute %number "skip_key" %attribute %string "set_if" %attribute %number "order" diff --git a/lib/icinga/pluginutility.cpp b/lib/icinga/pluginutility.cpp index 8e1c04e99..6aafab903 100644 --- a/lib/icinga/pluginutility.cpp +++ b/lib/icinga/pluginutility.cpp @@ -89,13 +89,14 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab CommandArgument arg; arg.Key = kv.first; - bool optional = false; + bool required = false; String argval; if (arginfo.IsObjectType()) { Dictionary::Ptr argdict = arginfo; argval = argdict->Get("value"); - optional = argdict->Get("optional"); + if (argdict->Contains("required")) + required = argdict->Get("required"); arg.SkipKey = argdict->Get("skip_key"); arg.Order = argdict->Get("order"); @@ -121,7 +122,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab checkable->GetLastCheckResult(), &missingMacro); if (!missingMacro.IsEmpty()) { - if (!optional) { + if (required) { String message = "Non-optional macro '" + missingMacro + "' used in argument '" + arg.Key + "' is missing while executing command '" + commandObj->GetName() + "' for object '" + checkable->GetName() + "'";