Ethernet Switching
Showing results for 
Search instead for 
Do you mean 
Trusted Contributor
Posts: 37
Registered: ‎11-06-2007
0 Kudos

Automating Data Collecting on the EX product line using Event-Options Policy

How to Automate (generate) Data Collection on EX device using Event-Options Policy:


When intermittent problems are seen in the network, you may want to schedule data collection on the EX for a particular show command. This can give you data points and allow you to trend counters that may help point to you to where things are having problems. It also give you options to send this collection of stats to an external server for archiving and data manipulation or saving it internally.


Here are the basics of a simple Event-Options Policy to collect CPU statistics and send that data to a external server. (you can also save the data to an internal device, however you may need to consider the amount of space taken).  You can change the "execute-commands"  to almost any CLI output you want to gather, not just CPU/process data:



juniper@EX1-RE0# show event-options

generate-event {

    RUN_EVERY_MIN time-interval 60;


policy TEST {

    events RUN_EVERY_MIN;

    then {

        execute-commands {

            commands {

                "show system process extensive";


            output-filename re0-process;

            destination local;

            output-format text;




destinations {                               

    local {

        archive-sites {







Verify output from event-options policy:


juniper@EX1-RE0# run file list /var/home/juniper/








You can verify output by “file show” and the file you saved:


root@EX-RE0# file show /var/home/juniper/EX1-RE0_re0-process_20100823_203357



juniper@ EX1-RE0> show system process extensive


last pid: 34621;  load averages:  0.87,  0.43,  0.20  up 10+01:37:41    20:33:57

165 processes: 9 running, 126 sleeping, 3 zombie, 27 waiting


Mem: 212M Active, 17M Inact, 132M Wired, 127M Cache, 112M Buf, 1502M Free





   11 root        1 171   52     0K    16K RUN    224.6H 68.46% idle

  757 root        2   8  -88 31972K 17112K nanslp 376:27  4.20% chassisd

34542 root        1  98    0 19716K 11820K select   0:00  1.33% cli

    8 root        1 171   52     0K    16K pgzero   1:20  0.83% pagezero




If you want to change the destination to a FTP o HTTP server you can change the archive-sites to “URL”:



The full documentation reference is seen here for configuring it:


This is a simple way to use just event-options policy without including any event scripts. However you can use event scripts which can give you even more power to do what you are looking for. There a few nice Day-One Article on Automating Junos. Please review as well:





If you find this post helpful, please show your appreciation by clicking the Kudos star at the left. If it provides you the solution, please click on the YELLOW Accept as Solution button at below.

Regular Visitor
Posts: 9
Registered: ‎08-23-2010
0 Kudos

Re: Automating Data Collecting on the EX product line using Event-Options Policy

Hi Wade,

Thanks for sharing that one.

Won't be using it every week, however will be very useful one day.


Trusted Contributor
Posts: 33
Registered: ‎10-09-2009
0 Kudos

Re: Automating Data Collecting on the EX product line using Event-Options Policy



I also wanted to highlight that the next release of Junos Space (1.4) plans to include workflows which automate deployment, enabling/disabling, and execution of such scripts. These workflows allow you to deploy scripts such as the example in this thread onto all your managed switches from a central management station. You can enable/disable the scripts on selected switches as needed, and even execute operational scripts remotely from the management station, as part of trouble-shooting.




Juniper Employee
Posts: 4
Registered: ‎03-11-2008
0 Kudos

Re: Automating Data Collecting on the EX product line using Event-Options Policy

JUNOS Script Automation, Script Library & Junos as a Scripting Language e-Learning course:


Speaking of e-Learning courses, you can also review:


JUNOS as a Switching Language:


JUNOS as a Second Language: