89 lines
2.6 KiB
Python
89 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# Copyright 2024 Spearhead Systems SRL
|
|
|
|
from cmk.gui.i18n import _
|
|
from cmk.gui.plugins.wato import (
|
|
rulespec_registry,
|
|
CheckParameterRulespecWithItem,
|
|
RulespecGroupCheckParametersEnvironment,
|
|
)
|
|
from cmk.gui.valuespec import (
|
|
Dictionary,
|
|
Integer,
|
|
)
|
|
|
|
|
|
def _valuespec_outlets_power_check():
|
|
return Dictionary(
|
|
optional_keys=[
|
|
'crit_watts_above',
|
|
'warn_watts_above',
|
|
'warn_watts_below',
|
|
'crit_watts_below'
|
|
],
|
|
elements=[
|
|
(
|
|
'crit_watts_above',
|
|
Integer(
|
|
minvalue=0,
|
|
title=_('Crit when above power'),
|
|
unit=_('Watts'),
|
|
help=_(
|
|
'If the Wattage of an outlet goes above this number, enter a critical state.'
|
|
),
|
|
),
|
|
),
|
|
(
|
|
'warn_watts_above',
|
|
Integer(
|
|
minvalue=0,
|
|
title=_('Warn when above power'),
|
|
unit=_('Watts'),
|
|
help=_(
|
|
'If the Wattage of an outlet goes above this number, enter a warning state.'
|
|
),
|
|
),
|
|
),
|
|
(
|
|
'warn_watts_below',
|
|
Integer(
|
|
minvalue=0,
|
|
title=_('Warn when below power'),
|
|
unit=_('Watts'),
|
|
help=_(
|
|
'If the Wattage of an outlet goes below this number, enter a warning state.'
|
|
),
|
|
),
|
|
),
|
|
(
|
|
'crit_watts_below',
|
|
Integer(
|
|
minvalue=0,
|
|
title=_('Crit when below power'),
|
|
unit=_('Watts'),
|
|
help=_(
|
|
'If the Wattage of an outlet goes below this number, enter a critical state.'
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
|
|
|
|
def _item_spec_outlets_power_check():
|
|
return TextAscii(title=_('Socket Name'),
|
|
help=_('The name of the socket'))
|
|
|
|
|
|
rulespec_registry.register(
|
|
CheckParameterRulespecWithItem(
|
|
check_group_name='sentry_pdu_outlets_power',
|
|
group=RulespecGroupCheckParametersEnvironment,
|
|
match_type='dict',
|
|
item_spec=_item_spec_outlets_power_check,
|
|
parameter_valuespec=_valuespec_outlets_power_check,
|
|
title=lambda: _('Sentry PDU Outlets Power Checks'),
|
|
)
|
|
)
|