feat: Add check_ping
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
2ced5e5a40
commit
234c6c46db
5 changed files with 127 additions and 2 deletions
|
@ -1,6 +1,30 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from nagiosplugin import Context
|
||||
from nagiosplugin.state import Critical, Ok, Unknown, Warn
|
||||
|
||||
|
||||
class BooleanContext(Context):
|
||||
def __init__(self, name, expected=True, warning=False, critical=False):
|
||||
super().__init__(name)
|
||||
self.expected = expected
|
||||
self.warning = warning
|
||||
self.critical = critical
|
||||
|
||||
def evaluate(self, metric, resource):
|
||||
if not metric.value is self.expected:
|
||||
result_type = Ok
|
||||
if self.critical:
|
||||
result_type = Critical
|
||||
elif self.warning:
|
||||
result_type = Warn
|
||||
return self.result_cls(
|
||||
result_type, f"{metric.name} is not {self.expected}", metric
|
||||
)
|
||||
else:
|
||||
return self.result_cls(Ok, None, metric)
|
||||
|
||||
|
||||
def show_version():
|
||||
with open(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue