2022-11-29 23:53:14 +01:00
|
|
|
class implementation_check_kind_script(interface_check_kind):
|
|
|
|
|
|
2022-11-30 23:03:24 +01:00
|
|
|
'''
|
|
|
|
|
[implementation]
|
|
|
|
|
'''
|
|
|
|
|
def parameters_schema(self):
|
|
|
|
|
return {
|
|
|
|
|
"type": "object",
|
|
|
|
|
"additionalProperties": False,
|
|
|
|
|
"properties": {
|
|
|
|
|
"path": {
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"arguments": {
|
|
|
|
|
"type": "array",
|
|
|
|
|
"item": {
|
|
|
|
|
"type": "string"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"path"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-11-29 23:53:14 +01:00
|
|
|
'''
|
|
|
|
|
[implementation]
|
|
|
|
|
'''
|
|
|
|
|
def normalize_conf_node(self, node):
|
|
|
|
|
return dict_merge(
|
|
|
|
|
{
|
|
|
|
|
},
|
|
|
|
|
node
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
[implementation]
|
|
|
|
|
'''
|
2022-11-30 08:15:35 +01:00
|
|
|
def run(self, parameters):
|
2022-11-29 23:53:14 +01:00
|
|
|
result = _subprocess.run(
|
2022-11-30 08:15:35 +01:00
|
|
|
[parameters["path"]] + parameters["arguments"],
|
2022-11-29 23:53:14 +01:00
|
|
|
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)
|
|
|
|
|
return {
|
|
|
|
|
"condition": condition,
|
2022-11-30 23:14:38 +01:00
|
|
|
"info": result.stdout.decode(),
|
2022-11-29 23:53:14 +01:00
|
|
|
}
|
|
|
|
|
|