[j-nsp] SLAX script, redefining variables
Tom Storey
tom at snnap.net
Fri Jun 7 04:54:59 EDT 2013
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
More information about the juniper-nsp
mailing list