03-21-2014 07:54 AM
Here's my scenario. One router with dual circuits...both are active with OSPF routing across. What I want to happen is, when a circuit starts taking more than 1000 errors in a minute...make that interface passive. But once that happens...I don't want to shoot myself in the foot if the other circuit starts taking errors. I don't want the other circuit to go passive and effectively bring down the site.
I currently have two independent scripts...one for circuit1, one for circuit2. I thought about this solution: if one script is invoked, within THAT script, automatically remove the OTHER script so there's no chance it can run and shutdown the site...but that's not really a clean solution, and would require me to come back later to manually restore the removed script.
Any other ideas to accomplish this requirement? Thank you.
03-21-2014 10:41 PM
What would be interesting to do is use a tracked object to store the current state. Create a stub tracked object, then set it in your first script and check it in your second script.
track 1 stub-object
default-state up
To set:
track set 1 state down
To read:
track read 1
if $_track_state eq down
! Exit here
end
03-24-2014 11:58 AM
Thanks, Joseph! Your response really got my gears turning, and I was able to get it working perfectly. Here's what it ended up looking like:
track 1 stub-object
!
track 2 stub-object
!
event manager applet CIRUIT1_OSPF_DOWN
event syslog pattern "%OSPF-5-ADJCHG.*Serial0/1/0.*to DOWN"
action 10 track set 1 state down
event manager applet CIRUIT1_OSPF_UP
event syslog pattern "%OSPF-5-ADJCHG.*Serial0/1/0.*to FULL"
action 10 track set 1 state up
event manager applet CIRUIT2_OSPF_DOWN
event syslog pattern "%OSPF-5-ADJCHG.*Serial0/0/0.*to DOWN"
action 10 track set 2 state down
event manager applet CIRUIT2_OSPF_UP
event syslog pattern "%OSPF-5-ADJCHG.*Serial0/0/0.*to FULL"
action 10 track set 2 state up
!
event manager applet DIRTY_CIRCUIT1
event interface name Serial0/1/0 parameter input_errors entry-op ge entry-val 100 entry-type increment poll-interval 60
action 06 track read 2
action 08 if $_track_state eq up
action 10 if $_interface_delta_value ge 1000
action 20 syslog msg "$_interface_delta_value $_interface_parameter on $_interface_name in the past minute (MAKING INTERFACE PASSIVE)"
action 20.1 cli command "enable"
action 20.2 cli command "config t"
action 20.3 cli command "router ospf 1"
action 20.4 cli command "passive-interface Serial0/1/0"
action 20.5 cli command "end"
action 30 else
action 40 syslog msg "$_interface_delta_value $_interface_parameter on $_interface_name in the past minute"
action 50 end
action 60 elseif $_track_state eq down
action 70 if $_interface_delta_value ge 1000
action 80 syslog msg "$_interface_delta_value $_interface_parameter on $_interface_name in the past minute (CANT MAKE INTERFACE PASSIVE SINCE OTHER CIRCUIT ALREADY PASSIVE)"
action 90 else
action 92 syslog msg "$_interface_delta_value $_interface_parameter on $_interface_name in the past minute"
action 94 end
action 96 end
!
event manager applet DIRTY_CIRCUIT2
event interface name Serial0/0/0 parameter input_errors entry-op ge entry-val 100 entry-type increment poll-interval 60
action 06 track read 1
action 08 if $_track_state eq up
action 10 if $_interface_delta_value ge 1000
action 20 syslog msg "$_interface_delta_value $_interface_parameter on $_interface_name in the past minute (MAKING INTERFACE PASSIVE)"
action 20.1 cli command "enable"
action 20.2 cli command "config t"
action 20.3 cli command "router ospf 1"
action 20.4 cli command "passive-interface Serial0/0/0"
action 20.5 cli command "end"
action 30 else
action 40 syslog msg "$_interface_delta_value $_interface_parameter on $_interface_name in the past minute"
action 50 end
action 60 elseif $_track_state eq down
action 70 if $_interface_delta_value ge 1000
action 80 syslog msg "$_interface_delta_value $_interface_parameter on $_interface_name in the past minute (CANT MAKE INTERFACE PASSIVE SINCE OTHER CIRCUIT ALREADY PASSIVE)"
action 90 else
action 92 syslog msg "$_interface_delta_value $_interface_parameter on $_interface_name in the past minute"
action 94 end
action 96 end
!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide