Rename "optional" attribute to "required" and change the default value.

Fixes #6069
This commit is contained in:
Gunnar Beutner 2014-04-29 10:41:32 +02:00
parent 50b878c3f3
commit 1c9e985f1d
3 changed files with 14 additions and 40 deletions

View File

@ -28,14 +28,8 @@ template CheckCommand "ping-common" {
"-H" = "$ping_address$" "-H" = "$ping_address$"
"-w" = "$ping_wrta$,$ping_wpl$%" "-w" = "$ping_wrta$,$ping_wpl$%"
"-c" = "$ping_crta$,$ping_cpl$%" "-c" = "$ping_crta$,$ping_cpl$%"
"-p" = { "-p" = "$ping_packets$"
value = "$ping_packets$" "-t" = "$ping_timeout$"
optional = true
}
"-t" = {
value = "$ping_timeout$"
optional = true
}
} }
vars.ping_wrta = 100 vars.ping_wrta = 100
@ -120,30 +114,15 @@ object CheckCommand "http" {
command = PluginDir + "/check_http" command = PluginDir + "/check_http"
arguments = { arguments = {
"-H" = { "-H" = "$http_vhost$"
value = "$http_vhost$"
optional = true
}
"-I" = "$http_address$" "-I" = "$http_address$"
"-u" = { "-u" = "$http_uri$"
value = "$http_uri$" "-p" = "$http_port$"
optional = true
}
"-p" = {
value = "$http_port$"
optional = true
}
"-S" = { "-S" = {
set_if = "$http_ssl$" set_if = "$http_ssl$"
} }
"-w" = { "-w" = "$http_warn_time$"
value = "$http_warn_time$" "-c" = "$http_critical_time$"
optional = true
}
"-c" = {
value = "$http_critical_time$"
optional = true
}
} }
vars.http_address = "$address$" vars.http_address = "$address$"
@ -169,10 +148,7 @@ object CheckCommand "ssmtp" {
arguments = { arguments = {
"-H" = "$ssmtp_address$" "-H" = "$ssmtp_address$"
"-p" = { "-p" = "$ssmtp_port$"
value = "$ssmtp_port$"
optional = true
}
} }
vars.ssmtp_address = "$address$" vars.ssmtp_address = "$address$"
@ -196,10 +172,7 @@ object CheckCommand "ssh" {
command = PluginDir + "/check_ssh" command = PluginDir + "/check_ssh"
arguments = { arguments = {
"-p" = { "-p" = "$ssh_port$"
value = "$ssh_port$"
optional = true
}
"host" = { "host" = {
value = "$ssh_address$" value = "$ssh_address$"
skip_key = true skip_key = true

View File

@ -207,7 +207,7 @@
%attribute %dictionary "*" { %attribute %dictionary "*" {
%attribute %string "value" %attribute %string "value"
%attribute %string "description" %attribute %string "description"
%attribute %number "optional" %attribute %number "required"
%attribute %number "skip_key" %attribute %number "skip_key"
%attribute %string "set_if" %attribute %string "set_if"
%attribute %number "order" %attribute %number "order"

View File

@ -89,13 +89,14 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
CommandArgument arg; CommandArgument arg;
arg.Key = kv.first; arg.Key = kv.first;
bool optional = false; bool required = false;
String argval; String argval;
if (arginfo.IsObjectType<Dictionary>()) { if (arginfo.IsObjectType<Dictionary>()) {
Dictionary::Ptr argdict = arginfo; Dictionary::Ptr argdict = arginfo;
argval = argdict->Get("value"); argval = argdict->Get("value");
optional = argdict->Get("optional"); if (argdict->Contains("required"))
required = argdict->Get("required");
arg.SkipKey = argdict->Get("skip_key"); arg.SkipKey = argdict->Get("skip_key");
arg.Order = argdict->Get("order"); arg.Order = argdict->Get("order");
@ -121,7 +122,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
checkable->GetLastCheckResult(), &missingMacro); checkable->GetLastCheckResult(), &missingMacro);
if (!missingMacro.IsEmpty()) { if (!missingMacro.IsEmpty()) {
if (!optional) { if (required) {
String message = "Non-optional macro '" + missingMacro + "' used in argument '" + String message = "Non-optional macro '" + missingMacro + "' used in argument '" +
arg.Key + "' is missing while executing command '" + commandObj->GetName() + arg.Key + "' is missing while executing command '" + commandObj->GetName() +
"' for object '" + checkable->GetName() + "'"; "' for object '" + checkable->GetName() + "'";