Git Product home page Git Product logo

junoscriptorium's Introduction

Welcome to the JUNOScriptorium!

The JUNOS operating system includes a scripting mechanism. Scripts perform a variety of jobs:

  • enforce configuration constraints
  • detect configuration errors
  • correct configuration errors
  • automatically generate configuration data
  • define custom configuration syntax
  • perform standard procedures
  • diagnose problems
  • respond in realtime to events
  • save debugging information when events occur
  • deduplicate events
  • generate SNMP traps
  • populate SNMP MIBs
  • create custom display output
  • and much more!!

This project is a repository for scripts developed by the community of script writers, both Juniper staff and customers.

Scripts are arranged according to source, type, and area of interest.

junoscriptorium's People

Contributors

astiphout avatar crmcguire11 avatar dshokarev avatar dssatya avatar erdems avatar francisluong avatar jessicagarrison avatar jlcross avatar msudhee avatar mtucker502 avatar philshafer avatar rboldy avatar rvandegrift avatar sgocken avatar ydnath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

junoscriptorium's Issues

op/display/

Hey there nice juniper scripting folks,

I'm trying to correct an error here. Can you please delete the file "snapshot" at this level of the hierarchy and rename the folder snapshot2 to just snapshot.

Thanks Rich

Does not import

Searching code for this error:
No file(s) imported.due to java.util.NoSuchElementException

problem to graph in MRTG software

HI,

At first thank for such helpful script. recently i have graphed Optical power in a MRTG software. but its posible for only one device.
i got OID for a single interface by snmpwalk(1.3.6.1.4.1.2636.3.47.1.1.5.1.2.111.112.116.105.99.115.68.53.51.56).
as per your script 1.3.6.1.4.1.2636.3.47.1.1.5.1.2.111.112.116.105.99.115 is fixed, 68 is for Receive Power dBm. what is for 53.51 ? is this possible to remove? because device to device its vary.

Not Able to Display Policy Lookup

Hello All

Can somebody Please help in correcting the issue. I am running this below Script but not getting lookup output.

SCRIPT:


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";
ns ext = "http://xmlsoft.org/XSLT/namespace";

match / {

<op-script-results> {

var $cmd = <command> "show security policies detail"; /* get policy hit count */
var $out = jcs:invoke($cmd);
var $totalCharsPerField = 20;


var $formatFields = "%20-s%20-s%20-s%20-s%20-s%20-s%20-s"; /* format for column headers display */
var $formatFieldsData = "%20-s%20-s%20-s%20-s%20-s%28-s%20-s"; /* format for actually data display */

<output> jcs:printf($formatFields,"Policy name","Source Zone","Destination Zone","Source Address",                                  "Destination Address","Application","   Policy Lookups");

for-each($out/security-context/policies/policy-information) { /* get all policy info such as name, source address, destination address, zone, application and * count
*/

    var $sourceZone = context-information/source-zone-name;  
    var $destinationZone = context-information/destination-zone-name;  


    var $sourceAddress := { for-each( source-addresses/source-address) {

            <output> address-name _ " ";

    }}

    var $destinationAddress := { for-each(destination-addresses/destination-address) {

            <output> address-name _ " ";


    }}

    var $application := { for-each(applications/application) {

                            <output> application-name _ " ";

            }}  

    var $pattern = " ";
    var $array;

    /* Create arrays out of all data that can have multiple values */
    var $destinationArray = jcs:split( $pattern , $destinationAddress);         
    var $sourceArray = jcs:split( $pattern , $sourceAddress);           
    var $applicationArray = jcs:split( $pattern , $application);        

    /*Get size of each array */ 
    var $destinationCount = {call returnArrayCount($array = $destinationArray);}
    var $sourceCount = {call returnArrayCount($array = $sourceArray);}
    var $applicationCount = {call returnArrayCount($array = $applicationArray);}
    var $allCounts = $applicationCount _ " " _ $sourceCount _ " " _ $destinationCount;
    var $maxString = $allCounts;

    /*Get the size of the larget array*/
    var $maxOfCounts = {call  returnMax($maxString);}
    var $splitOfAllCounts = jcs:split(" ", $allCounts);

    if ( policy-statistics-information/policy-lookups) { /* iterate through all the policies with count enabled */ 

            <output> jcs:printf ($formatFieldsData,policy-name, $sourceZone,$destinationZone,$sourceArray[1],                                   $destinationArray[1],$applicationArray[1],policy-statistics-information/policy-lookups);

        var $loopCounter := { call create-loop-counter( $counter = $maxOfCounts ); }

            for-each( $loopCounter/counter ) { /*Loop through each array and print out the data*/ 

            var $index = position();

            if ( $index != 1 ) {

                <output> jcs:printf ($formatFieldsData,policy-name, " "," ",$sourceArray[number($index)],                                       $destinationArray[number($index)],$applicationArray[number($index) ]," ");

            }

        }


    }else {

        <output> "Count not enabled for policy: " _ policy-name; 

    }


} /* end of foreach */

} /* End of op script results */

} /* End of match / */

template returnMax ($maxString="Nothing specified") { /* Return the max number in a string of numbers */

<op-script-results> {

    var $splitOfAllCounts = jcs:split(" ", $maxString);

    for-each($splitOfAllCounts) {

                    <xsl:sort select = "." data-type = "number" order = "descending">;

                    if (position() == 1) {
                           <output> .;
                    }

            }
}

}

template returnArrayCount ($array="Nothing defined") { /*return the size of an array */

    if(count($array) > 1) {

        var $count = count($array) - 1;
        <output> $count;

    }else if(count($array) == 0){

        <output> 0;



    }else{

        <output> 1;

    }

}

template create-loop-counter( $counter ) {

if( $counter > 0 ) {

    <counter>; 
    call create-loop-counter( $counter = $counter - 1 );

}

}

Multicast route slax

Hello I need automatic using slax script, to run the command: "show multicast route extension"
If the multicast group is in forwarding (multicast-route-forwarding-state), print me the group with forwarding-rate-kilobytes. There will be two entry of the same group.
I'm totally new to this slax.

<rpc-reply xmlns:junos="http://xml.juniper.net/junos/14.1X53/junos"> <multicast-route-information xmlns="http://xml.juniper.net/junos/14.1X53/junos-routing"> <route-family> <multicast-instance>master</multicast-instance> <address-family>INET</address-family> <multicast-route junos:style="extensive"> <multicast-group-address>232.0.1.0</multicast-group-address> <multicast-source-address>192.168.2.5</multicast-source-address> <multicast-source-prefix-length>32</multicast-source-prefix-length> <upstream-interface-name>ae1.0</upstream-interface-name> <downstream-interface-names> <interface-name>irb.1</interface-name> </downstream-interface-names> <outgoing-interface-count>1</outgoing-interface-count> <session-name>Source specific multicast</session-name> <forwarding-rate-kilobytes>1465</forwarding-rate-kilobytes> <forwarding-rate-packets>982</forwarding-rate-packets> <forwarded-packet-count>224636156</forwarded-packet-count> <next-hop-id>131076</next-hop-id> <upstream-protocol>Upstream protocol: PIM</upstream-protocol> <multicast-route-state>Active</multicast-route-state> <multicast-route-forwarding-state>Forwarding</multicast-route-forwarding-state> <multicast-route-timeout>forever</multicast-route-timeout> <interface-mismatch-count>0</interface-mismatch-count> <multicast-route-uptime junos:seconds="169249">1d 23:00:49</multicast-route-uptime> </multicast-route> <multicast-route junos:style="extensive"> <multicast-group-address>232.0.1.0</multicast-group-address> <multicast-source-address>10.10.10.5</multicast-source-address> <multicast-source-prefix-length>32</multicast-source-prefix-length> <upstream-interface-name>xe-0/0/1.0</upstream-interface-name> <downstream-interface-names> <interface-name>ae1.0</interface-name> </downstream-interface-names> <outgoing-interface-count>1</outgoing-interface-count> <session-name>Source specific multicast</session-name> <forwarding-rate-kilobytes>0</forwarding-rate-kilobytes> <forwarding-rate-packets>587</forwarding-rate-packets> <forwarded-packet-count>193339235</forwarded-packet-count> <next-hop-id>131090</next-hop-id> <upstream-protocol>Upstream protocol: PIM</upstream-protocol> <multicast-route-state>Active</multicast-route-state> <multicast-route-forwarding-state>Forwarding</multicast-route-forwarding-state> <multicast-route-timeout>forever</multicast-route-timeout> <interface-mismatch-count>0</interface-mismatch-count> <multicast-route-uptime junos:seconds="252649">2d 22:10:49</multicast-route-uptime> </multicast-route> </route-family> </multicast-route-information> </rpc-reply>

address-range

Hi All,

My customer is running 12.1 and did the config as "old style" , please see below:

set security zones security-zone corporate-to-mgmt1 address-book address rimnet-addm-deployment-1 range-address 10.27.126.179 to 10.27.126.188
set security zones security-zone corporate-to-mgmt1 address-book address rimnet-addm-deployment-2 range-address 10.27.63.14 to 10.27.63.17
set security zones security-zone corporate-to-mgmt1 address-book address rimnet-addm-deployment-3 range-address 10.27.63.8 to 10.27.63.12

Then, the script was ignoring these lines and breaking the connection with the address-set, generating the following error:

address-set rimnet-addm-deployment {
##
## Warning: referenced address must be defined under address-book
## Warning: referenced address must be defined under address-book
##

Thus, I added in the "upgrade script file" a new "if case" in the template gen-upgrade-cfg to cover this situation:

                                } else if ( ./range-address ) {
                                                    <range-address> {
                                                            <name> ./range-address/name;
                                                            <to> {
                                                                if ( ./range-address/to/range-high ){    
                                                                  <range-high> ./range-address/to/range-high;
                                                                }
                                                            }
                                                    } 
                                            }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.