[fix] [#1] lib:shell_command, check:generic_remote

This commit is contained in:
Christian Fraß 2023-03-03 15:27:43 +01:00
parent ff032c832e
commit 27b8ed017b
2 changed files with 10 additions and 3 deletions

View file

@ -11,6 +11,10 @@ class implementation_check_kind_generic_remote(interface_check_kind):
"host" : {
"type" : "string"
},
"port": {
"type": "integer",
"default": 22
},
"user" : {
"type" : "string"
},
@ -45,6 +49,8 @@ class implementation_check_kind_generic_remote(interface_check_kind):
or not "user" in node \
or not "ssh_key" in node:
raise ValueError("MISSING STUFF!")
if not "port" in node:
node["port"] = 22
if not "mount_point" in node:
node["mount_point"] = "/"
if not "threshold" in node:
@ -58,7 +64,7 @@ class implementation_check_kind_generic_remote(interface_check_kind):
[implementation]
'''
def run(self, parameters):
SSH_COMMAND=string_coin("ssh -i {{ssh_key}} {{user}}@{{host}} \"df {{mount_point}} | tr -s ' '\"", parameters)
SSH_COMMAND = string_coin("ssh -i {{ssh_key}} -p {{port}} {{user}}@{{host}} \"df {{mount_point}} | tr -s ' '\"", parameters)
retval=shell_command(SSH_COMMAND)
@ -70,7 +76,7 @@ class implementation_check_kind_generic_remote(interface_check_kind):
}
}
else:
parts=retval["stdout"].split("\n")[-1].split(" ")
parts=retval["stdout"].split("\n")[-2].split(" ")
ret={
"device" : parts[0],
"used" : parts[2],

View file

@ -51,7 +51,8 @@ def env_get_language():
def shell_command(command):
result = _subprocess.run(
command,
capture_output = True
capture_output = True,
shell = True,
)
return {
"return_code": result.returncode,