64 lines
1.2 KiB
Python
64 lines
1.2 KiB
Python
class implementation_check_kind_script(interface_check_kind):
|
|
|
|
'''
|
|
[implementation]
|
|
'''
|
|
def parameters_schema(self):
|
|
return {
|
|
"type": "object",
|
|
"additionalProperties": False,
|
|
"properties": {
|
|
"path": {
|
|
"type": "string"
|
|
},
|
|
"arguments": {
|
|
"type": "array",
|
|
"item": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"required": [
|
|
"path"
|
|
]
|
|
}
|
|
|
|
|
|
'''
|
|
[implementation]
|
|
'''
|
|
def normalize_conf_node(self, node):
|
|
return dict_merge(
|
|
{
|
|
},
|
|
node
|
|
)
|
|
|
|
|
|
'''
|
|
[implementation]
|
|
'''
|
|
def run(self, parameters):
|
|
result = shell_command(
|
|
" ".join([parameters["path"]] + parameters["arguments"])
|
|
)
|
|
if (result["return_code"] == 0):
|
|
condition = enum_condition.ok
|
|
elif (result["return_code"] == 1):
|
|
condition = enum_condition.unknown
|
|
elif (result["return_code"] == 2):
|
|
condition = enum_condition.concerning
|
|
elif (result["return_code"] == 3):
|
|
condition = enum_condition.critical
|
|
else:
|
|
# raise ValueError("invalid exit code: %i" % result.returncode)
|
|
condition = enum_condition.unknown
|
|
return {
|
|
"condition": condition,
|
|
"info": {
|
|
"stdout": result["stdout"],
|
|
"stderr": result["stderr"],
|
|
},
|
|
}
|
|
|