Search

1 to 10 of 36
Sort by

Blog Entry
Scripting How-To: Using the link-up script

Source Code GitHub Links The source code below is also available from GitHub at the following locations: link-up in Junoscriptorium on GitHub Example Configuration Example Output SLAX Script Contents XML Script Contents Example Configuration 01 You invoke it by adding the following to the switch's configuration: 02 03 event-options ( 04 policy LINK-UP ( 05 events snmp trap link up; 06 then ( 07 event-script link-up.slax ( 08 arguments ( 09 ifname "($$.interface-name)"; 10 ) 11 ) 12 ) 13 ) 14 ) 15 16 17 The output is SYSLOG will look like: 18 19 Aug 1 16:14:37 cscript: link-up.slax: IFNAME ge-0/0/3 MAC 00:1e:37:86:13:30 20 21 22 This was tested on EX4200 running JUNOS 9.6. 23 24 Note: To allow time for the ethernet switching table to populate, I had to add a delay once the event triggers. Example Output 1 Aug 1 16:14:37 cscript: link-up.slax: IFNAME ge-0/0/3 MAC 00:1e:37:86:13:30 SLAX Script Contents 001 /* 002 * 003 * NAME: link-up.slax 004 * PURPOSE: The requirement is that when a link becomes 005 * active, a message needs to be written to 006 * syslog indicating the interface name and 007 * the MAC addresses of the device(s) plugged 008 * into the interface. 009 * 010 * CREATED: 08/10/09 011 * BY: Jay Wilson (Solutions Architect - Western Area) 012 * LAST MOD: 08/11/09 013 * BY: Jay Wilson 014 * VERSION: 1.00 015 * 016 * MODIFICATION HISTORY: 017 * V1.00 = Initial release 018 * V1.01 = Added delay to allow MAC table to 019 * be populated. 020 * 021 */ 022 version 1.0; 023 ns junos = "http://xml.juniper.net/junos/*/junos"; 024 ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; 025 ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; 026 import "../import/junos.xsl"; 027 028 /* 029 * 030 * Define the argument that will be passed into the script. 031 * This argument is by the event attribute "interface-name" 032 * when the event triggers. 033 * 034 */ 035 var $arguments = <argument> ( 036 <name> "ifname"; 037 <description> "Interface to report about


Blog Entry
Scripting How-To: Prevent Parallel Execution of SLAX Scripts

Overview Sometimes you have the requirement to prevent that multiple instances of a single SLAX script run in parallel. This might be the case, when an event-script is called by interval (e.g. every 60 seconds) but was not finished before next interval. In this article I would like to explain one proposal to prevent multiple parallel executions of a SLAX script


Blog Entry
Scripting How-To: Configure and execute an event script

The script needs to be configured in the following configuration hierarchy: 1 [edit event-options event-script file <script-name>] An event script is executed on the occurrence of a system event matching the configuration selected. The configuration to associate an event script with a system event is as follows: 1 [edit] 2 user@host # show event-options 3 policy <policy-name> ( 4 events <system-event>; 5 then ( 6 event-script <script-name>; 7 ) 8 ) 9 10 [edit] 11 user@host # #How-To #eventscript #ScriptingHow-To


Blog Entry
Scripting How-To: Use event and op script boilerplates

Use event and op script Boilerplates For SLAX version 1.0 and higher, you can use new script boilerplates with SLAX 1.1 in Junos OS 12.2 Release and later


Blog Entry
Scripting How-To: Configure and execute an event script

The script needs to be configured in the following configuration hierarchy: 1 [edit event-options event-script file <script-name>] An event script is executed on the occurrence of a system event matching the configuration selected. The configuration to associate an event script with a system event is as follows: 1 [edit] 2 user@host# show event-options 3 policy <policy-name> ( 4 events <system-event>; 5 then ( 6 event-script <script-name>; 7 ) 8 ) 9 10 [edit] 11 user@host# #eventscript #ScriptingHow-To #Slax #How-To


Blog Entry
Scripting How-To: Where can I find a boilerplate op script?

The Event and Op Script Boilerplates page contains a boilerplate for event and op scripts for use with SLAX 1.1 in Junos OS Release 12.2 and later


Blog Entry
Scripting How-To: Demonstrate how a configuration can be committed from an op script

Demonstrate How to Commit a Configuration from an Op Script For SLAX version 1.0 and higher, you can use the disable-interface script to demonstrate how you can commit a configuration from an op script. The disable-interface script deactivates interface 'ge-0/0/2' upon receiving a PING TEST FAILED event, which is generated by rpm when the ping test fails. The ability to commit configuration from an op script is effective in Junos OS Release 9.3


Blog Entry
Scripting How-To: Get the same functionality as Cisco's absolute vty timeout

Overview This event script mimics Cisco's absolute vty timeout functionality...Description This script works in Junos 9.2 or later. It uses jade auth success as the generated event to cause the script to be run every 60 seconds


Blog Entry
Scripting How-To: Use pseudo-events

*"; 5 ) 6 then ( 7 event-script daemon-crash.slax ( 8 arguments ( 9 message "($$.message)"; 10 ) 11 output-filename test; 12 destination foo; 13 ) 14 ) 15 ) This policy will match for pseudo-event SYSTEM and the line matching the above regular expression. As an action, the policy event-script is executed and the error message is passed as an argument to the event-script. Within the event-script, using the error message argument, you can determine the daemon name and the signal number


Blog Entry
How can I commit a configuration using an op script?

The disable-interface script is an example that demonstrates how a configuration can be committed from an op-script. This script will deactivate interface 'ge-0/0/2' upon receiving a PING TEST FAILED event, which is generated by rpm when the ping test fails. The ability to commit configuration from an op-script is effective in Junos 9.3