Skip to content
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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 = {
<get-interface-information> {
<terse>;
}
}
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 := {
<configuration> {
for-each ( $down-interfaces ) {
<interfaces> {
<interface> {
<name> name;
<disable>;
}
}
}
}
}

/* Use load then commit the configuration */
var $results := {
call jcs:load-configuration($connection = $con, $configuration = $xml);
}

/* Close the mgd connection */
expr jcs:close($con);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<script>
<title>disable-the-down-down-interfaces.slax</title>
<synopsis>
This event script disables the interfaces which are already down.
</synopsis>
<coe>event</coe>
<type>interfaces</type>

<description>
This event script is confiigured to run on a weekly basis. It grabs the "show interfaces terse" command and checks for the Admin and Link statuses to be down. If they are both down, it disables the interfaces configuration.
</description>

<example>
<title>Config</title>
<config>disable-the-down-down-interfaces.conf</config>
</example>

<xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml"
src="../../../../../web/leaf.js"
type="text/javascript"/>
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<script>
<author>jgarrison</author>
<title>show-interface-status.slax</title>
<synopsis>
Grabs information from show interfaces and show ethernet-switching commands and places then into one output.
</synopsis>
<coe>op</coe>
<type>display</type>

<description>
This op script outputs Port, Description, Status, VLAN ID, Tagging, Duplex, and Speed for each VLAN by interface.
</description>

<xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml"
src="../../../../../web/leaf.js"
type="text/javascript"/>
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version 1.2;

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 / {
<op-script-results> {

/* show interfaces extensive to capture description, status, duplex, and speed */
var $rpc1 = {
<get-interface-information> {
<extensive>;
}
}
var $int = jcs:invoke( $rpc1 );

/* show ethernet-switching interfaces to capture port, vlan id, and tagging */
var $rpc2 = {
<get-ethernet-switching-interface-details> {
<detail>;
}
}
var $eth = jcs:invoke( $rpc2 );

/* print the header */
<output> 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,".");

/* 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 */
<output> 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);
}
}
}
}
31 changes: 31 additions & 0 deletions library/juniper/op/display/storm-control/storm-control.slax
Original file line number Diff line number Diff line change
@@ -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 / {
<op-script-results> {

/* show interfaces extensive to capture unicast, broadcast, and multicast traffic */
var $rpc = {
<get-interface-information> {
<extensive>;
}
}
var $int = jcs:invoke( $rpc );

var $eth = jcs:invoke( "get-ethernet-switching-interface-details" );
<output> 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;

<output> 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);

}
}
}
18 changes: 18 additions & 0 deletions library/juniper/op/display/storm-control/storm-control.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<script>
<author>jgarrison</author>
<title>storm-control.slax</title>
<synopsis>
Outputs packet information for storm control tagged interfaces.
</synopsis>
<coe>op</coe>
<type>display</type>

<description>
This op script takes the SCTL (storm control flagged) interfaces from the "show ethernet-swtiching interface" command and outputs the unicast, broadcast, and multicast traffic data.
</description>

<xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml"
src="../../../../../web/leaf.js"
type="text/javascript"/>
</script>