SNMP trap filtering by nodeid?

I’m running OpenNMS 25.2.1

I’d like to suppress SNMP traps coming from nodes that are not in OpenNMS. I know the preferred approach is to remove the OpenNMS server as a trap destination, but that is not an option at the moment.

I read through the Trap Configuration How-to and it looks like you can add a maskelement to the event definition to filter on nodeid as shown below. Looks straight-forward, but the problem is I want to match nodeid = null or nodeid != null and I can’t figure out how to do that.


Here’s what I have tried so far…


This matched nodes with valid nodeids and also those without

The How-To says you can use wildcard matching with % so I tried the following:


Once again, that matched events from all nodes.

Does anyone know if I’m missing something, or have any ideas for another way to do this?


I think I figured it out.

I added %nodeid% to the event logmsg to see what came though and to my surprise, nodes not in OpenNMS come through with nodeid = 0

I added the following maskelement and it picked off only events from nodes not in OpenNMS



That sounds reasonable. I think technically events that don’t correspond to a node don’t have any nodeid associated.