Changeset View
Changeset View
Standalone View
Standalone View
swh/icinga_plugins/base_check.py
Show All 12 Lines | class BaseCheck: | ||||
def get_status(self, value): | def get_status(self, value): | ||||
if self.critical_threshold and value >= self.critical_threshold: | if self.critical_threshold and value >= self.critical_threshold: | ||||
return (2, 'CRITICAL') | return (2, 'CRITICAL') | ||||
elif self.warning_threshold and value >= self.warning_threshold: | elif self.warning_threshold and value >= self.warning_threshold: | ||||
return (1, 'WARNING') | return (1, 'WARNING') | ||||
else: | else: | ||||
return (0, 'OK') | return (0, 'OK') | ||||
def print_result(self, status_type, status_string, **metrics): | |||||
print(f'{self.TYPE} {status_type} - {status_string}') | |||||
for (metric_name, metric_value) in sorted(metrics.items()): | |||||
print(f"| '{metric_name}' = {metric_value:.2f}s") |