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.

<maskelement>
   <mename>nodeid</mename>
   <mevalue>5</mevalue>
</maskelement>

Here’s what I have tried so far…

<mevalue></mevalue>

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:

<mevalue>0%</mevalue>
<mevalue>1%</mevalue>
<mevalue>2%</mevalue>
<mevalue>3%</mevalue>
<mevalue>4%</mevalue>
<mevalue>5%</mevalue>
<mevalue>6%</mevalue>
<mevalue>7%</mevalue>
<mevalue>8%</mevalue>
<mevalue>9%</mevalue>

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?

Thanks

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

<maskelement>
   <mename>nodeid</mename>
   <mevalue>0</mevalue>
</maskelement>

Dave

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