This article will provide an example of opConfig collecting specific command output based on event characteristics. The command output becomes embedded into the event allowing network operators to more quickly identify root cause and affect resolution.
For this example we'll take actions if an event's stateful element is a BGP Peer. opEvents will fire scripts that result in useful information for engineers to follow up on.
In this case the necessary configuration for opEvents is contained in /usr/local/omk/conf/EventActions.nmis. There are two sections we will be concerned with; script and policy.
Let's have a look at the script section first. For this example we want to ping the node that reported the problem, the BGP peer it's having an issue with, and leverage opConfig to gather related command output. Notice the arguments passed to opconfig-cli.pl, there is a command set name; IOS_TS_BGP. In the opConfig step we'll define what these specific router commands are.
In the policy section we define a rule that matches stateful properties that contain 'BGP Peer'. If there's a match it will fire the scripts defined above.
The /usr/local/omk/conf/command_sets.d directory is where we have files detailing exec commands to be executed on nodes. For this example we are concerned with ios.nmis. Our IOS_TS_BGP command set will be running the following commands.
- show ip bgp
- show ip bgp summary
- show ip route summary
If you have a large number of BGP routes we do not recommended 'show ip bgp'.
Testing and Verification
The easiest way to test this configuration is to administratively shutdown a BGP peer. After the next NMIS collect cycle a BGP Peer Down alert will be processed by opEvents. Here's an example from our lab.
Notice the Actions section is notifying us that our scripts fired. Scrolling down we can view the script output; it's now embedded into the event.