Event-options is a feature that allows you to collect outputs and perform configuration changes in response to events. It works in conjunction with other features, including RPM probes to test connectivity among devices. It can also be used to schedule periodic activities for control or monitoring purposes.
Certain business polices require constant small configuration changes to be applied on EX and QFX platforms including bouncing interfaces, collecting outputs, clearing statistics and cache. Though there are different ways to approach this requirement, event-options offers an easy method to fulfill this task.
Below are the steps needed to perform periodic changes while collecting outputs.
In this sample scenario, interface ge-0/0/1 will be enabled from 8am to 4pm each day. Some outputs will be captured while performing these changes.
Indicate the destination folder to store the event outputs. For more URL options click here :
set event-options destinations MyFolder archive-sites /var/tmp
Create policy EnablePolicy related with event EnableInterface :
set event-options policy EnablePolicy events EnableInterface
Specify the configuration changes to be executed during the event. For this task, ge-0/0/1 will be re-enabled:
set event-options policy EnablePolicy then change-configuration commands "delete interfaces ge-0/0/1 disable"
Specify the outputs collected during the event. (Note: Junos executes any lines under " execute-commands " before those configured under " change-configuration " if both were configured under the same policy):
execute-commands
set event-options policy EnablePolicy then
commands "show interfaces ge-0/0/1 terse"
commands "show ethernet-switching table interface ge-0/0/1"
commands "show arp no-resolve interface irb.10"
Indicate the file name, type and destination (step 1) to store the event outputs:
output-filename _Show_Enable
destination MyFolder
output-format text
Indicate the time to schedule the event. If using " time-of-day " the switch will use its local time unless a different UTC offset is included (using 24-hour time format hh:mm:ss). If using " time-interval " indicate the frequency in seconds. Time-interval option will execute the events when committing and continue executing the events according to the specified time. For this task, time-of-day was use to run the event at 8am every day.
time-of-day
time-interval
Time-interval
set event-options generate-event EnableInterface time-of-day 08:00:00
Create a second policy to Disable the interface at 4pm every day:
set event-options policy DisablePolicy events DisableInterface set event-options policy DisablePolicy then
commands "set interfaces ge-0/0/1 disable" set event-options policy DisablePolicy then
commands "show interfaces ge-0/0/1 terse" set event-options policy DisablePolicy then
commands "show ethernet-switching table interface ge-0/0/1" set event-options policy DisablePolicy then
commands "show arp no-resolve interface irb.10" set event-options policy DisablePolicy then
output-filename _Show_Disable set event-options policy DisablePolicy then
destination MyFolder set event-options policy DisablePolicy then execute-commands output-format text set event-options generate-event DisableInterface time-of-day 16:00:00
Check configuration:
event-options { generate-event { DisableInterface time-of-day "16:00:00 -0800"; EnableInterface time-of-day "08:00:00 -0800"; }
policy EnablePolicy { events EnableInterface; then { change-configuration { commands { "delete interfaces ge-0/0/1 disable"; } } execute-commands { commands { "show interfaces ge-0/0/1 terse"; "show ethernet-switching table interface ge-0/0/1"; "show arp no-resolve interface irb.10"; } output-filename _Show_Enable; destination MyFolder; output-format text; } } } policy DisablePolicy { events DisableInterface; then { change-configuration { commands { "set interfaces ge-0/0/1 disable"; } } execute-commands { commands { "show interfaces ge-0/0/1 terse"; "show ethernet-switching table interface ge-0/0/1"; "show arp no-resolve interface irb.10"; } output-filename _Show_Disable; destination MyFolder; output-format text; } } } destinations { MyFolder { archive-sites { /var/tmp; } } } }
'file show
root@LAB_EX4300> file list /var/tmp/ /var/tmp/: .schema-cache/ .snap/ gres-tp/ install/ LAB_EX4300_20190218_080001__Show_Enable LAB_EX4300_20190218_160001__Show_Disable pics/ rtsdb/ vi.recover/