08-23-2010 01:52 PM
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_203
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”:
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:
http://www.juniper.net/us/en/community/junos/train
Regards,
Wade
08-23-2010 03:01 PM
08-23-2010 09:07 PM
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
08-24-2010 12:03 AM
JUNOS Script Automation, Script Library & Junos as a Scripting Language e-Learning course:
http://www.juniper.net/us/en/community/junos/scrip
Speaking of e-Learning courses, you can also review:
JUNOS as a Switching Language:
http://www.juniper.net/us/en/training/elearning/ju
JUNOS as a Second Language:
http://www.juniper.net/us/en/training/elearning/js