Environment variables for use with EEM routing trigger?

Answered Question
Oct 5th, 2009

I've only recently started looking into EEM, and was hoping a guru here could clear something up for me:

The docs do not show there to be any environment variables that can be used with EEM's "routing" trigger, to determine which route was added, changed, or modified.

It seems odd that the trigger would allow you to fire specifically on adds or removes, but then give you no indication of the specific route that was added or removed. Is this info in some non-obvious generic variable?

Or, is the only available approach to cache the route table, and then parse the whole table when the event fires? I haven't seen any examples that use this trigger; maybe because of this lack of any documented routing-specific variables?

Thanks in advance!

I have this problem too.
0 votes
Correct Answer by Joe Clarke about 7 years 2 months ago

Every event detector has its own set of internal variables. These are different than environment variables. Environment variables are those you can modify in the config with "event manager environment". If you have a device which supports the routing event detector, you can run the command, "show event manager detector routing detailed" and that will show you all of the available internal variables.

I actually did a programmatic applet example using the oruting ED for my Networkers session this past year. This example doesn't use any of the internal variables, but it will give you an idea of how this ED works:

event manager applet route-watch

event routing network 10.1.1.0/24 type add protocol ospf

action 001 cli command "enable"

action 002 set done 0

action 003 while $done eq 0

action 004 wait 5

action 005 cli command "ping ip 10.1.1.1"

action 005 regexp "!!!!!" "$_cli_result"

action 006 if $_regexp_result eq 1

action 007 cli command "config t"

action 008 cli command "int Tunnel0"

action 009 cli command "shut"

action 010 cli command "end"

action 011 set done 1

action 012 end

action 013 end

This applet will be triggered when the route 10.1.1.0/24 is learned via OSPF. The applet will then try and ping 10.1.1.1, and when it is 100% successful, it will take down the backup tunnel interface. Because it may take a little while before the ping is 100% successful, the applet will loop until it gets a 100% success (or until the 20 second maxrun timer expires).

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
Joe Clarke Mon, 10/05/2009 - 16:43

Every event detector has its own set of internal variables. These are different than environment variables. Environment variables are those you can modify in the config with "event manager environment". If you have a device which supports the routing event detector, you can run the command, "show event manager detector routing detailed" and that will show you all of the available internal variables.

I actually did a programmatic applet example using the oruting ED for my Networkers session this past year. This example doesn't use any of the internal variables, but it will give you an idea of how this ED works:

event manager applet route-watch

event routing network 10.1.1.0/24 type add protocol ospf

action 001 cli command "enable"

action 002 set done 0

action 003 while $done eq 0

action 004 wait 5

action 005 cli command "ping ip 10.1.1.1"

action 005 regexp "!!!!!" "$_cli_result"

action 006 if $_regexp_result eq 1

action 007 cli command "config t"

action 008 cli command "int Tunnel0"

action 009 cli command "shut"

action 010 cli command "end"

action 011 set done 1

action 012 end

action 013 end

This applet will be triggered when the route 10.1.1.0/24 is learned via OSPF. The applet will then try and ping 10.1.1.1, and when it is 100% successful, it will take down the backup tunnel interface. Because it may take a little while before the ping is 100% successful, the applet will loop until it gets a 100% success (or until the 20 second maxrun timer expires).

9jlitton Tue, 10/06/2009 - 05:58

Ahhh... I knew there had to be be more than I was seeing.

Thank you VERY much; that was exactly what I needed to know!

WildCard81 Tue, 09/09/2014 - 06:56

Is it also possible to use a default routing event like 0.0.0.0/0 and thus every change will trigger the event. But then store the changed route into a variable to be used in an action cli command?

 

regards

 

W

Joe Clarke Tue, 09/09/2014 - 17:35

Yes.  The routing prefix will be stored in a variable, $_routing_prefix that you can feed into another action.  Look at "show event manager detector routing detail" for all of the available variables.

Actions

This Discussion