From 809569796288c45367ad501977e63aebbc171a4c Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Tue, 14 May 2024 23:25:29 -0700 Subject: [PATCH 01/10] Add a directory for disabling interface configs This directory contains the conf, slax, and xml files related to a slax script that disables the interface configuration of an interface when the Admin and Link statuses are both down. --- .../disable-the-down-down-interfaces.conf | 14 ++++++ .../disable-the-down-down-interfaces.slax | 48 +++++++++++++++++++ .../disable-the-down-down-interfaces.xml | 23 +++++++++ 3 files changed, 85 insertions(+) create mode 100644 library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.conf create mode 100644 library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.slax create mode 100644 library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.xml diff --git a/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.conf b/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.conf new file mode 100644 index 0000000..2ef64c7 --- /dev/null +++ b/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.conf @@ -0,0 +1,14 @@ +event-options { + generate-event { + weekly time-interval 604800 no-drift; + } + inactive: policy weekly-disable-interfaces { + events weekly; + then { + event-script disable-the-down-down-interfaces.slax; + } + } + event-script { + file disable-the-down-down-interfaces.slax; + } +} diff --git a/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.slax b/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.slax new file mode 100644 index 0000000..def586c --- /dev/null +++ b/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.slax @@ -0,0 +1,48 @@ +/* +* Disables interfaces that are showing a down/down status +*/ + +version 1.0; +ns junos = "http://xml.juniper.net/junos/*/junos"; +ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; +ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; + +import "../import/junos.xsl"; + +match / { + + /* Open connection with mgd and show interfaces terse */ + var $rpc = { + { + ; + } + } + var $con = jcs:open(); + var $int = jcs:execute($con, $rpc); + + /* Only down down interfaces */ + var $down-interfaces = $int/physical-interface[admin-status == 'down' && oper-status == 'down']; + + /* Disable configuration for only the down/down interfaces */ + var $xml := { + { + for-each ( $down-interfaces ) { + { + { + name; + ; + } + } + } + } + } + + /* Use load then commit the configuration */ + var $results := { + call jcs:load-configuration($connection = $con, $configuration = $xml); + } + + /* Close the mgd connection */ + expr jcs:close($con); + +} \ No newline at end of file diff --git a/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.xml b/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.xml new file mode 100644 index 0000000..3dfcde7 --- /dev/null +++ b/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.xml @@ -0,0 +1,23 @@ + + \ No newline at end of file From a5da8d406d60c2512d8d6e26391e3fb4af9a5dc7 Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Wed, 15 May 2024 09:07:14 -0700 Subject: [PATCH 02/10] Adding jgarrison Adding Jessica Garrison to the directory of authors --- library/juniper/Authors/jgarrison.xml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 library/juniper/Authors/jgarrison.xml diff --git a/library/juniper/Authors/jgarrison.xml b/library/juniper/Authors/jgarrison.xml new file mode 100644 index 0000000..b4c2e57 --- /dev/null +++ b/library/juniper/Authors/jgarrison.xml @@ -0,0 +1,27 @@ +{\rtf1\ansi\ansicpg1252\cocoartf2709 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 Lato-Regular;\f1\froman\fcharset0 Times-Roman;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue0; +} +{\*\expandedcolortbl;;\cssrgb\c0\c1\c1;\cssrgb\c100000\c100000\c99985\c0;\cssrgb\c0\c0\c0; +} +\margl1440\margr1440\vieww19080\viewh12260\viewkind0 +\deftab720 +\pard\pardeftab720\partightenfactor0 + +\f0\fs37\fsmilli18667 \cf2 \cb3 \expnd0\expndtw0\kerning0 +\ +\ + Jessica Garrison\ + Juniper Networks\ + jessica@juniper.net\ + USA\ + +\f1\fs24 \cf2 \cb3 \ +\ +\ +\pard\pardeftab720\partightenfactor0 +\cf4 \cb2 \ +\ +\cb1 \ +\ +} \ No newline at end of file From a750db8621167e08d97793e3cad319edab04282c Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Wed, 15 May 2024 09:08:46 -0700 Subject: [PATCH 03/10] Update jgarrison.xml Remove garbage --- library/juniper/Authors/jgarrison.xml | 32 +++++---------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/library/juniper/Authors/jgarrison.xml b/library/juniper/Authors/jgarrison.xml index b4c2e57..d56d170 100644 --- a/library/juniper/Authors/jgarrison.xml +++ b/library/juniper/Authors/jgarrison.xml @@ -1,27 +1,7 @@ -{\rtf1\ansi\ansicpg1252\cocoartf2709 -\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 Lato-Regular;\f1\froman\fcharset0 Times-Roman;} -{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue0; -} -{\*\expandedcolortbl;;\cssrgb\c0\c1\c1;\cssrgb\c100000\c100000\c99985\c0;\cssrgb\c0\c0\c0; -} -\margl1440\margr1440\vieww19080\viewh12260\viewkind0 -\deftab720 -\pard\pardeftab720\partightenfactor0 - -\f0\fs37\fsmilli18667 \cf2 \cb3 \expnd0\expndtw0\kerning0 -\ -\ - Jessica Garrison\ - Juniper Networks\ - jessica@juniper.net\ - USA\ + + + Jessica Garrison + Juniper Networks + jessica@juniper.net + USA -\f1\fs24 \cf2 \cb3 \ -\ -\ -\pard\pardeftab720\partightenfactor0 -\cf4 \cb2 \ -\ -\cb1 \ -\ -} \ No newline at end of file From bffbc2c6b9ad58cb3b6324e49f5c0f9b7fb21b0e Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Wed, 15 May 2024 16:35:26 -0700 Subject: [PATCH 04/10] Adding slax for storm control and interface status Adding only slax scripts for two directories - storm control for "casts" packets with SCTL - show interface status 2, another variation --- .../show-interfaces-status-2.slax | 35 +++++++++++++++++++ .../display/storm-control/storm-control.slax | 31 ++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax create mode 100644 library/juniper/op/display/storm-control/storm-control.slax diff --git a/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax b/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax new file mode 100644 index 0000000..2849b91 --- /dev/null +++ b/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax @@ -0,0 +1,35 @@ +version 1.0; + +ns junos = "http://xml.juniper.net/junos/*/junos"; +ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; +ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; + +import "../import/junos.xsl"; + +match / { + { + + /* show interfaces extensive to capture description, status, duplex, and speed */ + var $rpc1 = { + { + ; + } + } + var $int = jcs:invoke( $rpc1 ); + + /* show ethernet-switching interfaces to capture port, vlan id, and tagging */ + var $rpc2 = { + { + ; + } + } + var $eth = jcs:invoke( $rpc2 ); + + /* print the header */ + jcs:printf( "%-20s%-27s%-11s%-12s%-20s%-16s%-18s", "Port", "Description", "Status", "VLAN ID", "Tagging", "Duplex", "Speed"); + + for-each ( $eth/l2ng-l2ald-iff-interface-entry[string-length(l2iff-interface-vlan-id) > 0] ) { + jcs:printf( "%-20s%-27s%-11s%-12s%-20s%-16s%-18s", l2iff-interface-name, $int/physical-interface/link-level-type, $int/physical-interface/oper-status, l2iff-interface-vlan-id, l2iff-interface-vlan-member-tagness, $int/physical-interface/link-type, $int/physical-interface/speed); + } + } +} \ No newline at end of file diff --git a/library/juniper/op/display/storm-control/storm-control.slax b/library/juniper/op/display/storm-control/storm-control.slax new file mode 100644 index 0000000..8894fb4 --- /dev/null +++ b/library/juniper/op/display/storm-control/storm-control.slax @@ -0,0 +1,31 @@ +version 1.0; + +ns junos = "http://xml.juniper.net/junos/*/junos"; +ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; +ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; + +import "../import/junos.xsl"; + +match / { + { + + /* show interfaces extensive to capture unicast, broadcast, and multicast traffic */ + var $rpc = { + { + ; + } + } + var $int = jcs:invoke( $rpc ); + + var $eth = jcs:invoke( "get-ethernet-switching-interface-details" ); + jcs:printf( "%-23s%-18s%-18s%-18s%-18s%-18s%-18s", "Interface Name", "Unicast RX", "Unicast TX", "Broadcast RX", "Broadcast TX", "Multicast RX", "Multicast TX"); + + for-each ( $eth/l2ng-l2ald-iff-interface-entry/l2ng-l2ald-iff-interface-entry[l2iff-interface-flags == "SCTL"] ) { + var $sto-con-int = substring-before ( l2iff-interface-name, '.' ); + var $int-eth = $int/physical-interface[name == $sto-con-int ]/ethernet-mac-statistics; + + jcs:printf( "%-23s%-18s%-18s%-18s%-18s%-18s%-18s", $sto-con-int, $int-eth/input-unicasts, $int-eth/output-unicasts, $int-eth/input-broadcasts, $int-eth/output-broadcasts, $int-eth/input-multicasts, $int-eth/output-multicasts); + + } + } +} \ No newline at end of file From c544a47679612d1600850115f67464db46b19996 Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Wed, 22 May 2024 08:10:45 -0700 Subject: [PATCH 05/10] Update disable-the-down-down-interfaces.xml Remove author into --- .../disable-the-down-down-interfaces.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.xml b/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.xml index 3dfcde7..9011fa4 100644 --- a/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.xml +++ b/library/juniper/event/interfaces/disable-the-down-down-interfaces/disable-the-down-down-interfaces.xml @@ -1,6 +1,5 @@ \ No newline at end of file + From d8a5bbd2c8c5411c468e81622ccd8345a21765a9 Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Wed, 22 May 2024 08:19:15 -0700 Subject: [PATCH 06/10] Delete library/juniper/Authors/jgarrison.xml delete author info --- library/juniper/Authors/jgarrison.xml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 library/juniper/Authors/jgarrison.xml diff --git a/library/juniper/Authors/jgarrison.xml b/library/juniper/Authors/jgarrison.xml deleted file mode 100644 index d56d170..0000000 --- a/library/juniper/Authors/jgarrison.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - Jessica Garrison - Juniper Networks - jessica@juniper.net - USA - From a74f9bcb7b544305930651c9ff96d5bc724d350a Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Tue, 4 Jun 2024 10:59:26 -0700 Subject: [PATCH 07/10] Create storm-control.xml xml file with description of what the slax script does --- .../op/display/storm-control/storm-control.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 library/juniper/op/display/storm-control/storm-control.xml diff --git a/library/juniper/op/display/storm-control/storm-control.xml b/library/juniper/op/display/storm-control/storm-control.xml new file mode 100644 index 0000000..01b9cc7 --- /dev/null +++ b/library/juniper/op/display/storm-control/storm-control.xml @@ -0,0 +1,18 @@ + + From 204c2fbf0c78e45b16c9e2e86023709a6f0ca6ea Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Tue, 4 Jun 2024 11:03:49 -0700 Subject: [PATCH 08/10] Create show-interface-status-2.xml xml file for show interface status command --- .../show-interface-status-2.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 library/juniper/op/display/show-interface-status-2/show-interface-status-2.xml diff --git a/library/juniper/op/display/show-interface-status-2/show-interface-status-2.xml b/library/juniper/op/display/show-interface-status-2/show-interface-status-2.xml new file mode 100644 index 0000000..76dec92 --- /dev/null +++ b/library/juniper/op/display/show-interface-status-2/show-interface-status-2.xml @@ -0,0 +1,18 @@ + + From 2e239a9bb62771ac8493866bdce9ccb108f3b82e Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Wed, 5 Jun 2024 09:40:09 -0700 Subject: [PATCH 09/10] Update show-interfaces-status-2.slax Added the up and up for oper-status and admin-status --- .../show-interfaces-status-2.slax | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax b/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax index 2849b91..8b7a764 100644 --- a/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax +++ b/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax @@ -1,4 +1,4 @@ -version 1.0; +version 1.2; ns junos = "http://xml.juniper.net/junos/*/junos"; ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; @@ -29,7 +29,10 @@ match / { jcs:printf( "%-20s%-27s%-11s%-12s%-20s%-16s%-18s", "Port", "Description", "Status", "VLAN ID", "Tagging", "Duplex", "Speed"); for-each ( $eth/l2ng-l2ald-iff-interface-entry[string-length(l2iff-interface-vlan-id) > 0] ) { - jcs:printf( "%-20s%-27s%-11s%-12s%-20s%-16s%-18s", l2iff-interface-name, $int/physical-interface/link-level-type, $int/physical-interface/oper-status, l2iff-interface-vlan-id, l2iff-interface-vlan-member-tagness, $int/physical-interface/link-type, $int/physical-interface/speed); + var $etname = substring-before(l2iff-interface-name,"."); + if (($int/physical-interface[name==$etname]/admin-status=="up") && ($int/physical-interface[name==$etname]/oper-status=="up")) { + jcs:printf( "%-20s%-27s%-11s%-12s%-20s%-16s%-18s", l2iff-interface-name, $int/physical-interface[name==$etname]/link-level-type, $int/physical-interface[name==$etname]/oper-status, l2iff-interface-vlan-id, l2iff-interface-vlan-member-tagness, $int/physical-interface[name==$etname]/link-type, $int/physical-interface[name==$etname]/speed); + } } } -} \ No newline at end of file +} From 08714cd9dc0cd62bd73dd317f8c304dc2e644f57 Mon Sep 17 00:00:00 2001 From: Jessica Garrison Date: Wed, 5 Jun 2024 09:56:18 -0700 Subject: [PATCH 10/10] Update show-interfaces-status-2.slax added comments --- .../show-interfaces-status-2.slax | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax b/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax index 8b7a764..8ab4ed4 100644 --- a/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax +++ b/library/juniper/op/display/show-interface-status-2/show-interfaces-status-2.slax @@ -28,9 +28,16 @@ match / { /* print the header */ jcs:printf( "%-20s%-27s%-11s%-12s%-20s%-16s%-18s", "Port", "Description", "Status", "VLAN ID", "Tagging", "Duplex", "Speed"); + /* for loop with the vlan ids, ignore the empty ones */ for-each ( $eth/l2ng-l2ald-iff-interface-entry[string-length(l2iff-interface-vlan-id) > 0] ) { + + /* grabbing the name of the physical interface ignoring the .0 */ var $etname = substring-before(l2iff-interface-name,"."); - if (($int/physical-interface[name==$etname]/admin-status=="up") && ($int/physical-interface[name==$etname]/oper-status=="up")) { + + /* confirmation of Admin and Link status, only print when both are up */ + if (($int/physical-interface[name==$etname]/admin-status=="up") && ($int/physical-interface[name==$etname]/oper-status=="down")) { + + /* print each line */ jcs:printf( "%-20s%-27s%-11s%-12s%-20s%-16s%-18s", l2iff-interface-name, $int/physical-interface[name==$etname]/link-level-type, $int/physical-interface[name==$etname]/oper-status, l2iff-interface-vlan-id, l2iff-interface-vlan-member-tagness, $int/physical-interface[name==$etname]/link-type, $int/physical-interface[name==$etname]/speed); } }