Compare commits
No commits in common. "37d091c3daacca94feefe3dfb3fa14a131f24f17" and "75da5babd0cc371825c2a456244a039b413b255a" have entirely different histories.
37d091c3da
...
75da5babd0
@ -66,7 +66,6 @@ class AttributeFilter:
|
|||||||
class Entities(nagiosplugin.Resource):
|
class Entities(nagiosplugin.Resource):
|
||||||
url: str
|
url: str
|
||||||
token: str
|
token: str
|
||||||
domain: str
|
|
||||||
device_class: str
|
device_class: str
|
||||||
numeric: bool
|
numeric: bool
|
||||||
area: str
|
area: str
|
||||||
@ -149,13 +148,7 @@ class Entities(nagiosplugin.Resource):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def probe(self):
|
def probe(self):
|
||||||
template_filter = "states"
|
template_filter = f"states|selectattr('attributes.device_class', 'eq', '{ self.device_class }')"
|
||||||
if self.domain:
|
|
||||||
template_filter += f"|selectattr('domain', 'eq', '{ self.domain }')"
|
|
||||||
if self.device_class:
|
|
||||||
template_filter += (
|
|
||||||
f"|selectattr('attributes.device_class', 'eq', '{ self.device_class }')"
|
|
||||||
)
|
|
||||||
for f in self.filters:
|
for f in self.filters:
|
||||||
op = "ne" if f.negated else "eq"
|
op = "ne" if f.negated else "eq"
|
||||||
template_filter += (
|
template_filter += (
|
||||||
@ -354,17 +347,11 @@ def main():
|
|||||||
common_args = shared_parser.add_argument_group(
|
common_args = shared_parser.add_argument_group(
|
||||||
"Common Arguments", "Arguments shared between metric types"
|
"Common Arguments", "Arguments shared between metric types"
|
||||||
)
|
)
|
||||||
common_args.add_argument(
|
|
||||||
"--domain",
|
|
||||||
type=str,
|
|
||||||
required=False,
|
|
||||||
help="domain of entities to monitor",
|
|
||||||
)
|
|
||||||
common_args.add_argument(
|
common_args.add_argument(
|
||||||
"-d",
|
"-d",
|
||||||
"--device-class",
|
"--device-class",
|
||||||
type=str,
|
type=str,
|
||||||
required=False,
|
required=True,
|
||||||
help="device class of entities to monitor",
|
help="device class of entities to monitor",
|
||||||
)
|
)
|
||||||
common_args.add_argument(
|
common_args.add_argument(
|
||||||
@ -482,7 +469,7 @@ def main():
|
|||||||
max=args.max,
|
max=args.max,
|
||||||
**parsed_common_args,
|
**parsed_common_args,
|
||||||
),
|
),
|
||||||
ScalarOrUnknownContext("scalar_entities", args.warning, args.critical),
|
ScalarOrUnknownContext(args.device_class, args.warning, args.critical),
|
||||||
)
|
)
|
||||||
elif args.subparser_name == "text":
|
elif args.subparser_name == "text":
|
||||||
check = nagiosplugin.Check(
|
check = nagiosplugin.Check(
|
||||||
@ -492,7 +479,7 @@ def main():
|
|||||||
numeric=False,
|
numeric=False,
|
||||||
**parsed_common_args,
|
**parsed_common_args,
|
||||||
),
|
),
|
||||||
RegexContext("text_entities", args.ok, args.warning, args.critical),
|
RegexContext(args.device_class, args.ok, args.warning, args.critical),
|
||||||
)
|
)
|
||||||
|
|
||||||
check.main(args.verbose)
|
check.main(args.verbose)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user