[mod] "output" -> "info"
This commit is contained in:
parent
6e1fba9188
commit
839d6d1aaa
|
|
@ -75,7 +75,7 @@ class implementation_check_kind_file_timestamp(interface_check_kind):
|
||||||
if (not _os.path.exists(parameters["path"])):
|
if (not _os.path.exists(parameters["path"])):
|
||||||
return {
|
return {
|
||||||
"condition": condition_decode(parameters["condition_on_missing"]),
|
"condition": condition_decode(parameters["condition_on_missing"]),
|
||||||
"output": "file is missing"
|
"info": "file is missing"
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
result = _os.stat(parameters["path"])
|
result = _os.stat(parameters["path"])
|
||||||
|
|
@ -84,7 +84,7 @@ class implementation_check_kind_file_timestamp(interface_check_kind):
|
||||||
if (age < 0):
|
if (age < 0):
|
||||||
return {
|
return {
|
||||||
"condition": condition_decode(parameters["condition_on_implausible"]),
|
"condition": condition_decode(parameters["condition_on_implausible"]),
|
||||||
"output": string_coin(
|
"info": string_coin(
|
||||||
"file is apparently from the future; timestamp of checking instance: {{timestamp_this}}; timestamp of file: {{timestamp_that}} (age in seconds: {{age}})",
|
"file is apparently from the future; timestamp of checking instance: {{timestamp_this}}; timestamp of file: {{timestamp_that}} (age in seconds: {{age}})",
|
||||||
{
|
{
|
||||||
"timestamp_this": timestamp,
|
"timestamp_this": timestamp,
|
||||||
|
|
@ -104,7 +104,7 @@ class implementation_check_kind_file_timestamp(interface_check_kind):
|
||||||
raise ValueError("impossible state")
|
raise ValueError("impossible state")
|
||||||
return {
|
return {
|
||||||
"condition": condition,
|
"condition": condition,
|
||||||
"output": string_coin(
|
"info": string_coin(
|
||||||
"age in seconds: {{age}}",
|
"age in seconds: {{age}}",
|
||||||
{
|
{
|
||||||
"age": ("%u" % age),
|
"age": ("%u" % age),
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ class implementation_check_kind_http_request(interface_check_kind):
|
||||||
if (not method_handled):
|
if (not method_handled):
|
||||||
return {
|
return {
|
||||||
"condition": enum_condition.unknown,
|
"condition": enum_condition.unknown,
|
||||||
"output": ("invalid HTTP request method: %s" % parameters["request"]["method"])
|
"info": ("invalid HTTP request method: %s" % parameters["request"]["method"])
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
if (response is None):
|
if (response is None):
|
||||||
|
|
@ -130,7 +130,7 @@ class implementation_check_kind_http_request(interface_check_kind):
|
||||||
if parameters["as_warning"] else
|
if parameters["as_warning"] else
|
||||||
enum_condition.critical
|
enum_condition.critical
|
||||||
),
|
),
|
||||||
"output": "HTTP request failed",
|
"info": "HTTP request failed",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
lines = []
|
lines = []
|
||||||
|
|
@ -187,6 +187,6 @@ class implementation_check_kind_http_request(interface_check_kind):
|
||||||
enum_condition.critical
|
enum_condition.critical
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
"output": "\n".join(lines),
|
"info": "\n".join(lines),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,8 @@ class implementation_check_kind_script(interface_check_kind):
|
||||||
condition = enum_condition.critical
|
condition = enum_condition.critical
|
||||||
else:
|
else:
|
||||||
raise ValueError("invalid exit code: %i" % result.returncode)
|
raise ValueError("invalid exit code: %i" % result.returncode)
|
||||||
output = result.stdout.decode()
|
|
||||||
return {
|
return {
|
||||||
"condition": condition,
|
"condition": condition,
|
||||||
"output": output,
|
"info": result.stdout.decode(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,7 @@ def main():
|
||||||
check_data["name"],
|
check_data["name"],
|
||||||
check_data,
|
check_data,
|
||||||
new_item_state,
|
new_item_state,
|
||||||
result["output"]
|
result["info"]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise ValueError("invalid notification kind: %s" % notification["kind"])
|
raise ValueError("invalid notification kind: %s" % notification["kind"])
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@ class interface_notification_channel(object):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
def notify(self, parameters, name, data, state, output):
|
def notify(self, parameters, name, data, state, info):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,14 @@ class implementation_notification_channel_console(interface_notification_channel
|
||||||
'''
|
'''
|
||||||
[implementation]
|
[implementation]
|
||||||
'''
|
'''
|
||||||
def notify(self, parameters, name, data, state, output):
|
def notify(self, parameters, name, data, state, info):
|
||||||
_sys.stdout.write(
|
_sys.stdout.write(
|
||||||
string_coin(
|
string_coin(
|
||||||
"[{{title}}] <{{condition}}> {{output}}\n",
|
"[{{title}}] <{{condition}}> {{info}}\n",
|
||||||
{
|
{
|
||||||
"title": data["title"],
|
"title": data["title"],
|
||||||
"condition": condition_encode(state["condition"]),
|
"condition": condition_encode(state["condition"]),
|
||||||
"output": ("(no infos)" if (output is None) else output),
|
"info": ("(no info)" if (info is None) else info),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class implementation_notification_channel_email(interface_notification_channel):
|
||||||
'''
|
'''
|
||||||
[implementation]
|
[implementation]
|
||||||
'''
|
'''
|
||||||
def notify(self, parameters, name, data, state, output):
|
def notify(self, parameters, name, data, state, info):
|
||||||
smtp_connection = _smtplib.SMTP(
|
smtp_connection = _smtplib.SMTP(
|
||||||
parameters["access"]["host"]
|
parameters["access"]["host"]
|
||||||
)
|
)
|
||||||
|
|
@ -82,7 +82,7 @@ class implementation_notification_channel_email(interface_notification_channel):
|
||||||
)
|
)
|
||||||
message = MIMEText(
|
message = MIMEText(
|
||||||
string_coin(
|
string_coin(
|
||||||
("(no infos)" if (output is None) else output),
|
("(no info)" if (info is None) else info),
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -111,3 +111,4 @@ class implementation_notification_channel_email(interface_notification_channel):
|
||||||
message.as_string()
|
message.as_string()
|
||||||
)
|
)
|
||||||
smtp_connection.quit()
|
smtp_connection.quit()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,6 @@ class implementation_notification_channel_file_touch(interface_notification_chan
|
||||||
'''
|
'''
|
||||||
[implementation]
|
[implementation]
|
||||||
'''
|
'''
|
||||||
def notify(self, parameters, name, data, state, output):
|
def notify(self, parameters, name, data, state, info):
|
||||||
_os.path.touch(parameters["path"])
|
_os.path.touch(parameters["path"])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class implementation_notification_channel_libnotify(interface_notification_chann
|
||||||
'''
|
'''
|
||||||
[implementation]
|
[implementation]
|
||||||
'''
|
'''
|
||||||
def notify(self, parameters, name, data, state, output):
|
def notify(self, parameters, name, data, state, info):
|
||||||
def condition_translate(condition):
|
def condition_translate(condition):
|
||||||
if (condition == enum_condition.unknown):
|
if (condition == enum_condition.unknown):
|
||||||
return "normal"
|
return "normal"
|
||||||
|
|
@ -90,9 +90,9 @@ class implementation_notification_channel_libnotify(interface_notification_chann
|
||||||
)
|
)
|
||||||
## body
|
## body
|
||||||
parts.append(
|
parts.append(
|
||||||
"(no infos)"
|
"(no info)"
|
||||||
if (output == "") else
|
if (info == "") else
|
||||||
output
|
info
|
||||||
)
|
)
|
||||||
_subprocess.run(parts)
|
_subprocess.run(parts)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue