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

View File

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

View File

@ -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>()) {
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() + "'";