65 lines
1.2 KiB
Python
65 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 = _subprocess.run(
|
|
[parameters["path"]] + parameters["arguments"],
|
|
capture_output = True
|
|
)
|
|
if (result.returncode == 0):
|
|
condition = enum_condition.ok
|
|
elif (result.returncode == 1):
|
|
condition = enum_condition.unknown
|
|
elif (result.returncode == 2):
|
|
condition = enum_condition.warning
|
|
elif (result.returncode == 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.decode(),
|
|
"stderr": result.stderr.decode(),
|
|
},
|
|
}
|
|
|