[j-nsp] SLAX script, redefining variables

Alex Arseniev alex.arseniev at gmail.com
Fri Jun 7 08:34:40 EDT 2013


The checks can be embedded into "if"/"for-each" constructs, see example here
https://code.google.com/p/junoscriptorium/source/browse/trunk/library/public/op/display/op-show-lsp-interface/op-show-lsp-interface.slax

               if ($ifdescrdb/logical-interface[name == $if]/description) {


The above means that only IFLs whose <name> XML tag matches a string stored 
in variable $if will be processed.
HTH
Thanks
Alex

----- Original Message ----- 
From: "Tom Storey" <tom at snnap.net>
To: <juniper-nsp at puck.nether.net>
Sent: Friday, June 07, 2013 9:54 AM
Subject: [j-nsp] SLAX script, redefining variables


> Hi all.
>
> It seems that older SLAX implementations dont have the ability to redefine
> variable (Juniper is calling them immutable variables). This is apparently
> fixed in 1.1 on JunOS12+ boxes with something called a mutable variable
> (defined with mvar instead of var) but all of the boxes I am using are not
> on JunOS12+ yet.
>
> Has anyone found a way to collect a whole bunch of information, and then
> display it at the end of the script, rather than duplicating their output
> code 50 times to handle the various exceptions?
>
> e.g. a script I am writing grabs the tx/rx figures for optics and lists
> them, along with the description of the interface, so I can run my op
> script and get a list of power levels, grep for destination devices etc 
> and
> see whats happening with my circuits.
>
> But there are a couple of exceptions that I hit along the way:
>
> 1) Descriptions arent always on the physical interface, so if theres no
> description there I need to look at a logical interface, which is usually
> unit 0 in my case
> 2) SONET interfaces dont use the same "variable" to store the rx power
> figure as ethernet interfaces, so depending on the interface type I need 
> to
> look at a different variable for the rx power figure
>
> To handle these exceptions would be quite easy if I could simply use a
> bunch of IF blocks to test for the various locations of the information I
> want, set them in to variables, and then at the end dump it out to the
> screen.
>
> But without being able to redefine a variable, and with variables defined
> inside an IF block not being accessible outside of that IF block, I will
> need to reproduce my output code numerous times.
>
> Anyone know of a solution?
>
> Thanks
> Tom
> _______________________________________________
> juniper-nsp mailing list juniper-nsp at puck.nether.net
> https://puck.nether.net/mailman/listinfo/juniper-nsp
> 



More information about the juniper-nsp mailing list