varbind based notification filtering doesn't support regular expression

Description

Hi guys,

According to http://www.opennms.org/wiki/Configuring_notifications:

When an event is received, a few evaluations are performed:

  • Are notifications turned on (the "status" attribute on the "notifd-configuration" element in notifd-configuration.xml)? If not, the event is discarded and a notification is not performed.

  • Does the UEI in the event match a UEI configured in an enabled notification and does the rule in the notification match the event (see Rule Matching below)? If not, the event is discarded and notification is not performed. Note: the special UEI string "MATCH-ANY-UEI" can be used to match all event UEIs (the rule still needs to match, as well).

  • If the notification has a <varbind> configured with a name and value, it is used for a case sensitive match against the beginning an event parameter of the same name.

If the above evaluations pass, one or more notifications are sent. If the "match-all" attribute on the "notifd-configuration" element is set to "true", every matching notification will be executed by walking its destination path, otherwise only the first matching notification will be executed.

The fact that <varbind> matching is only done against the beginning of an event parameter is a limitation that could probably easily be overcome:

If I'm not mistaken, this match is done in file opennms\opennms-services\src\main\java\org\opennms\netmgt\config\NotifdConfigManager.java, method matchNotificationParameters.

There is the following test:

if (parmName.equals(notfName) && parmContent.startsWith(notfValue)) {
parmmatch = true;
}

As parmContent and nofValue are regular java Strings, this could easily be replaced by:

if (parmName.equals(notfName) && parmContent.matches(notfValue)) {
parmmatch = true;
}

What do you think?

Is this enough information for you to patch onms quickly, or would it be quicker if I provided you with a proper git-like patch?

BR,

Cyrille

Acceptance / Success Criteria

None

Attachments

1
  • 18 Jun 2012, 08:23 AM

Lucidchart Diagrams

Activity

Show:

Jeff Gehlbach February 27, 2013 at 5:32 PM

I cherry-picked this commit to 1.10 since I've bumped up against the limitation a couple times lately.

Seth Leger August 7, 2012 at 3:59 PM

I've applied this patch, marking as fixed.

commit 2030592ef7a712343c5e16ee9d5820e93a472d9d

Cyrille Bollu June 18, 2012 at 8:24 AM

Hi Jeff,

I've attached a patch against remotes/origin/1.10

I hope it's ok.

Cyrille

Cyrille Bollu June 18, 2012 at 8:23 AM

patch for adding support for regular expression in varbind-based notification filtering.

Jeff Gehlbach June 15, 2012 at 11:19 AM

Thanks for the report, Cyrille.

We have a fairly consistent convention of treating match strings as regexes only if they start with a ~ character, so there will be a slightly larger change set than just changing startsWith(notfValue) to matches(notfValue). See org.opennms.netmgt.eventd.datablock.EventConfData.eventValuePassesMaskValue(String, List<String>) for an example.

Still a pretty trivial yet high-value enhancement, though.

Fixed

Details

Assignee

Reporter

Fix versions

Affects versions

Priority

PagerDuty

Created June 15, 2012 at 11:12 AM
Updated January 27, 2017 at 4:20 PM
Resolved August 7, 2012 at 3:59 PM

Flag notifications