Ethernet Switching
Reply
Trusted Contributor
WadePrice-jnpr
Posts: 37
Registered: ‎11-06-2007
0

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:

 

[edit]

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 {

            /var/home/jnpr;

        }

    }

}

 

 

Verify output from event-options policy:

 

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

 

/var/home/juniper/:

.ssh/

EX1-RE0_re0-process_20100823_203357

EX1-RE0_re0-process_20100823_203455

EX1-RE0_re0-process_20100823_203555

 

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

Swap:

 

 

  PID USERNAME  THR PRI NICE   SIZE    RES STATE    TIME   WCPU COMMAND

   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”:

 

http://www.juniper.net/techpubs/en_US/junos10.2/topics/reference/configuration-statement/archive-sit...

 

 

The full documentation reference is seen here for configuring it:

 

http://www.juniper.net/techpubs/en_US/junos10.2/topics/reference/configuration-statement/event-optio...

 

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:

 

http://www.juniper.net/us/en/community/junos/training-certification/day-one/automation-series/

 

Regards,

Wade

***************************************************************************

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
tcalis
Posts: 9
Registered: ‎08-23-2010
0

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.

KR,

Thomas
Juniper Employee
roshan-joyce
Posts: 20
Registered: ‎10-09-2009
0

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

Hi,

 

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.

 

Thanks,

Roshan

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

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:

http://www.juniper.net/us/en/community/junos/script-automation/

 

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

 

JUNOS as a Switching Language:

http://www.juniper.net/us/en/training/elearning/junos_switching.html

 

JUNOS as a Second Language:

http://www.juniper.net/us/en/training/elearning/jsl.html

 

Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.