How to trigger a script based on an event

I want to trigger a python script whenever I’ll get the event “A new node Added” / “uei.opennms.org/nodes/nodeAdded”. What configuration i need to do to achieve this.

1 Like

I think you need to create a custom command notification, and then set that event to trigger that notification.

1 Like

I’m bit confuse with “Custom command notification”, does it mean I need to create and configure a notification in opennms Admin page. (Home/Admin/Configure Notifications)

Yes, though instead of sending it to email, you need a custom Destination Path that targets a custom command notification to run your script.

I do something similar to trigger a webhook to send notices to a MS Teams channel.

1 Like

For reference, documentation on using notificationCommands.xml is currently at NotificationCommands - OpenNMS

You could also set an autoaction on the event.

Try adding <autoaction>/path/to/some/script.py</autoaction> to the event configuration.

2 Likes

TIL. <autoaction /> doesn’t appear in the docs.

1 Like

You are correct :slight_smile: I know something existed somewhere in the Wiki at some point. :man_shrugging:

Can’t we do this from “opennms.pollered.events.xml” file?
Suppose for the new node we want to execute a script, whenever the new node will create that time we will get the uei: “uei.opennms.org/nodes/nodeAdded” and based on this uei we will trigger a script.

@dino2gnt @mmahacek I’ve also never heard of this. Have you created an issue to add it?

It was in the wiki, and I’ve pinged the appropriate people to check on this.

1 Like

Did you fixed? Do you know how to send %interface% and %ifName% to the script?