Log in to ask questions, share your expertise, or stay connected to content you value. Don’t have a login? Learn how to become a member.
Overview This script is for performance monitoring on the SRX
The results of these scripts can then be displayed directly within Junos Space (or within Job Management) in raw format, embedded within <op-script-results> tags, or with a little tweaking inside the script as HTML. Shown below is a simple slax script that can be imported into Junos Space to display the output of a "show system processes extensive" command. This particular script does not need to be staged or enabled on a device, as it includes the @ISLOCAL = "true" annotation
Overview An op-script to combine the output of two different EX operational commands and present it "your" way
Overview Commit script boilerplate recommended for SLAX 1.1 use in Junos OS Release 12.2 or later
In the case of developing an op-script, from an existing op-script you can call another op-script as below. Utility.slax is the other op-script enabled in the system. You can pass an argument ($arg) as the command-line argument to run the utility script, if required. 1 var $call -another-script-rpc := <op-script> ( 2 <script> "utility" ; 3 <arg> $arg ; 4 ) 5 var $rpc -result = jcs:invoke( $call -another-script-rpc); #ScriptingHow-To #How-To #Slax #opscript
If you want spaced columns then you will want to use the jcs: printf() function. This returns a correctly spaced string which can then be displayed on the console through the jcs: output() function. The following page has an example from eol-scanner.slax that uses jcs: printf(): ...
Script Format Options For SLAX version 1.0 and higher, you can format script output options...Here is an example from eol-scanner.slax that uses jcs:printf(): NOTE: The following script example is obsolete and repeated as an example only
I want to discover OP Scripts arguments. If the arguments are declared in the configuration tree, this is very easy using these commands: 1 edit 2 show system scripts op file my script.slax arguments However, if the arguments are not declared there, how can I discover OP Script arguments?
Overview An example script uses the snmp.slax library
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