Support Support Downloads Knowledge Base Service Request Manager My Juniper Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[EX/QFX] Schedule periodic configuration changes and collect outputs using event-options

0

0

Article ID: KB33945 KB Last Updated: 29 Mar 2019Version: 1.0
Summary:

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. 

Symptoms:

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.

Solution:

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.

  1. Indicate the destination folder to store the event outputs. For more URL options click here:

    set event-options destinations MyFolder archive-sites /var/tmp

  2. Create policy EnablePolicy related with event EnableInterface:

    set event-options policy EnablePolicy events EnableInterface
  3. 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"   
  4. 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):

    set event-options policy EnablePolicy then execute-commands commands "show interfaces ge-0/0/1 terse"
    set event-options policy EnablePolicy then execute-commands commands "show ethernet-switching table interface ge-0/0/1"
    set event-options policy EnablePolicy then execute-commands commands "show arp no-resolve interface irb.10"
  5. Indicate the file name, type and destination (step 1) to store the event outputs:   

    set event-options policy EnablePolicy then execute-commands output-filename _Show_Enable
    set event-options policy EnablePolicy then execute-commands destination MyFolder
    set event-options policy EnablePolicy then execute-commands output-format text
  6. 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.

    set event-options generate-event EnableInterface time-of-day 08:00:00
  7. 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
    change-configuration commands "set interfaces ge-0/0/1 disable"
    set event-options policy DisablePolicy then
    execute-commands commands "show interfaces ge-0/0/1 terse"
    set event-options policy DisablePolicy then
    execute-commands commands "show ethernet-switching table interface ge-0/0/1"
    set event-options policy DisablePolicy then
    execute-commands commands "show arp no-resolve interface irb.10"
    set event-options policy DisablePolicy then
    execute-commands output-filename _Show_Disable
    set event-options policy DisablePolicy then
    execute-commands 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
  8. 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;
                }
            }
        }
    }

Check Results

Once the events are executed, a file will be stored on the destination folder configured. The format of the file includes the name of the host, date, time and file name. The content of the files could be check using '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/
Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Security Alerts and Vulnerabilities

Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search