Example #1
0
def event_match_exclude_services(rule, context):
    if context["WHAT"] != "SERVICE":
        return
    excludelist = rule.get("match_exclude_services", [])
    service = context["SERVICEDESC"]
    if config.in_extraconf_servicelist(excludelist, service):
        return "The service's description '%s' matches the list of excluded services" \
          % context["SERVICEDESC"]
Example #2
0
def event_match_exclude_services(rule: EventRule, context: EventContext) -> Optional[str]:
    if context["WHAT"] != "SERVICE":
        return None
    excludelist = rule.get("match_exclude_services", [])
    service = context["SERVICEDESC"]
    if config.in_extraconf_servicelist(excludelist, service):
        return ("The service's description '%s' matches the list of excluded services" %
                context["SERVICEDESC"])
    return None
Example #3
0
def event_match_services(rule, context):
    if "match_services" in rule:
        if context["WHAT"] != "SERVICE":
            return "The rule specifies a list of services, but this is a host notification."
        servicelist = rule["match_services"]
        service = context["SERVICEDESC"]
        if not config.in_extraconf_servicelist(servicelist, service):
            return "The service's description '%s' does not match by the list of " \
                   "allowed services (%s)" % (service, ", ".join(servicelist))
Example #4
0
def test_in_extraconf_servicelist(service_patterns, service, expected):
    assert config.in_extraconf_servicelist(service_patterns,
                                           service) == expected