Add ssh_port parameter for the ssh check command.

Refs #5933
This commit is contained in:
Gunnar Beutner 2014-04-26 18:19:12 +02:00
parent be4324c606
commit 9b9ee5c425
4 changed files with 19 additions and 6 deletions

View File

@ -163,6 +163,7 @@ Custom Attributes:
Name | Description Name | Description
----------------|-------------- ----------------|--------------
ssh_address | **Optional.** The host's address. Defaults to "$address$". ssh_address | **Optional.** The host's address. Defaults to "$address$".
ssh_port | **Optional.** The port that should be checked. Defaults to 22.
### <a id="itl-disk"></a> disk ### <a id="itl-disk"></a> disk

View File

@ -193,10 +193,18 @@ object CheckCommand "ntp_time" {
object CheckCommand "ssh" { object CheckCommand "ssh" {
import "plugin-check-command" import "plugin-check-command"
command = [ command = PluginDir + "/check_ssh"
PluginDir + "/check_ssh",
"$ssh_address$" arguments = {
] "-p" = {
value = "$ssh_port$"
optional = true
}
"host" = {
value = "$ssh_address$"
skip_key = true
}
}
vars.ssh_address = "$address$" vars.ssh_address = "$address$"
} }

View File

@ -208,6 +208,7 @@
%attribute %string "value" %attribute %string "value"
%attribute %string "description" %attribute %string "description"
%attribute %number "optional" %attribute %number "optional"
%attribute %number "skip_key"
%attribute %string "set_if" %attribute %string "set_if"
} }
}, },

View File

@ -59,13 +59,15 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
const Value& arginfo = kv.second; const Value& arginfo = kv.second;
bool optional = false; bool optional = false;
bool skip_key = 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"); optional = argdict->Get("optional");
skip_key = argdict->Get("skip_key");
String set_if = argdict->Get("set_if"); String set_if = argdict->Get("set_if");
if (!set_if.IsEmpty()) { if (!set_if.IsEmpty()) {
@ -106,7 +108,8 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
} }
Array::Ptr command_arr = command; Array::Ptr command_arr = command;
command_arr->Add(argname); if (!skip_key)
command_arr->Add(argname);
if (!argval.IsEmpty()) if (!argval.IsEmpty())
command_arr->Add(argresolved); command_arr->Add(argresolved);
} }