Netsight ELRP script

  • 0
  • 1
  • Problem
  • Updated 2 years ago
  • Solved
Hi All

I need to change the settings of ELRP interval. I have found this script which i am sure can be used in Netsight.

disable clipaging

enable elrp-client

set var sv "#ELRP POLL STARTED#"

show var sv

set var cli.out 0

show vlan

set var sv $TCL(split ${cli.out} "\n")

set var e $TCL(lsearch $sv *(B)*)

set var i 5

set var e ($e - 1)

while ($i < $e) do

   set var cli.out 0

   set var v $TCL(lindex $sv $i)

   set var vn $TCL(lindex $v 0)

   set var z $TCL(regexp {Mgmt} $vn)

   if ($z == 0) then

         conf elrp-client one-shot $vn port all print

         set var p $TCL(split ${cli.out} "\n")

         set var p1 $TCL(lsearch $p *NO*)

         if ($p1 == -1) then

            set var p1 $TCL(lindex $p 2)

            set var p2 $TCL(lindex $p1 9)

            set var p1 $TCL(lrange $p1 0 6)

            set var p1 $TCL(concat $p1 $p2)

            set var p2 $TCL(lindex $p 3)

            set var p2 $TCL(lrange $p2 5 7)

            set var p $TCL(concat $p1 $p2)

            show var p

         else

            set var p1 $TCL(lindex $p 2)

            set var p2 $TCL(lindex $p1 10)

            set var p1 $TCL(lrange $p1 0 7)

            set var p1 $TCL(concat $p1 $p2)

            show var p1

         endif

   endif

   set var i ($i + 1)

endwhile

disable elrp-client

enable clipaging

set var sv "#ELRP POLL COMPLETED#"

show var sv



But am unsure as to how much of it i need. All I need to do is conf elrp-client periodic vlan ($variable) ports all interval 20

The above sript does way more, so i assume i can delete parts of it. Does anyone know which ones?

Also would i need to add excluded ports to the script even though it has already been defined.
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
Changing the interval is a bit more complicated. If you were to try to change the interval of an existing elrp-client configuration, you would get a error message like: "ERROR: An active session already exists for "CLI:Default" !" 

I can write a script that checks current configuration of elrp and changes the interval, if you'd like.
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
#This script updates the interval on eljrp-client sessions
# set the variable below
#This only works on EXOS 16.1 forward
set var int 3
disable clip
show elrp
set var CLI.OUT 0
show elrp 
set var s $TCL(split ${CLI.OUT} "\n")
set var i $TCL(lsearch $s *----*)
set var i ($i + 1)
set var e $TCL(lsearch $s *Print\,*)
set var e ($e - 1)
while ($i < $e) do
   set var l $TCL(lindex $s $i)
   set var v $TCL(lindex $l 1)
   set var p $TCL(lindex $l 2)
   set var n $TCL(lindex $l 3)
   set var a $TCL(lindex $l 8)
   set var d $TCL(lindex $l 9)
   set var t $TCL(regexp {\-} $d)
   set var t1 $TCL(regexp {L} $a)
   set var t2 $TCL(regexp {T} $a)
   set var t3 $TCL(regexp {E} $a)
   set var t4 $TCL(regexp {I} $a)
   set var t5 $TCL(expr $t1 && $t2)
   set var lt "log"
   set var ie ''
   if ($t2) then
      set var lt "trap"
   endif
   if ($t5) then
      set var lt "log-and-trap"
   endif
   if ($t3) then
      set var ie "egress"
   endif
   if ($t4) then
      set var ie "ingress"
   endif
   set var recmd $TCL(concat "config elrp-client periodic" $v "ports" $p "interval" $int $lt)
   if (!$t) then
      set var recmd $TCL(concat $recmd "disable-port" $ie)
      set var t $TCL(regexp {\d+} $d)
      if ($t) then
         set var d $TCL(concat "duration" $d)
      endif
      set var recmd $TCL(concat $recmd $d)
   endif
   unconfig elrp $v
   $recmd
   set var i ($i + 1)
endwhile
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb
Thanks for that, so i assume then the ELRP would need to be removed and then re-enabled with the different interval on each Vlan. As i am no scripting guru i assume that's what the script does.
(Edited)
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
Yes. It takes the int variable in at the top and makes that the interval for all ELRP VLAN instances. It assumes you are not running any one-shot instances of ELRP on a VLAN. It only works on 16.1 forward because the ports are shown in the output without spaces in that release of EXOS fwd, else it could get really messed up.
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb
Thanks for the explanation.
(Edited)
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb
Hi

Tested the script and it failed with the below error

*** Error at line - 59 ***
invalid command name "config elrp-client periodic <VLAN ID> ports All interval 5 log disable-port ingress 300"

Line 59 is
set var recmd $TCL(concat "config elrp-client periodic" $v "ports" $p "interval" $int $lt)

I am so confused. Doesn't seem to like the ingress 300 bit.

if (!$t) then
      set var recmd $TCL(concat $recmd "disable-port" $ie)
      set var t $TCL(regexp {\d+} $d)
      if ($t) then
         set var d $TCL(concat "duration" $d)

So i did


set var recmd $TCL(concat "config elrp-client periodic" $v "ports" $p "interval" $int $lt)
   if (!$t) then
      set var recmd $TCL(concat $recmd "disable-port" $ie "duration")
      set var t $TCL(regexp {\d+} $d)
      if ($t) then
         set var d $TCL(concat "duration" $d)
      endif
      set var recmd $TCL(concat $recmd $d)
   endif

But still get the error.

invalid command name "config elrp-client periodic Extreme1 ports All interval 3 log disable-port ingress duration 300"

The command works in the cli.
(Edited)
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
What version of EXOS are you running?
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb
XOS 16.1.1.4
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
Can you also send me the output of a "show vlan" command. Perhaps there is something in the vlan name triggering. Also a "show elrp". (It might be good to issue the "disable clip" command before doing these commands). I'll try to configure my switch to match yours as closely as possible and test it.
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
BTW, here is the ELRP configuration against which I tested the script:

# sho elrp
ELRP Standalone Client:       Enabled

Number of ELRP sessions:          4
Number of ELRP pkts transmitted:  397
Number of ELRP pkts received:     0

                                                       Pkts    Pkts        Disable
Client  VLAN        Ports   Interval Count Cyclic      Xmit    Rcvd Action Port (sec)
-------------------------------------------------------------------------------------
CLI     Default     1-2,4          3     0 Yes            3       0 LTI    Perm    
CLI     VLAN_0101   All            3     0 Yes            1       0 LE     20      
CLI     VLAN_0102   All            3     0 Yes            1       0 T      -       
CLI     VLAN_0103   All            3     0 Yes            1       0 L      -       
-------------------------------------------------------------------------------------
Action : (P) Print, (L) Log, (T) Trap, (C) Callback, (E) Egress, (I) Ingress

No errors detected.

Running 16.1.3,6-patch1-2
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb
I see you aren't using 16.1.1.4. Is it possibly a issue with 16.1.1.4?
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
Just tested on 16.1.1.4 and no errors either.
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb
show Vlan

Default         1    ------------------------------------------------- ANY    0 /0   VR-Default
Extreme1        25   ------------------------------------------------- ANY    0 /0   VR-Default
BB-MGMT       30   10.100.30.199   /24  -f--------------------------- ANY    1 /1   VR-Default
Mgmt            4095 ------------------------------------------------- ANY    0 /1   VR-Mgmt   
-----------------------------------------------------------------------------------------------

Show ELRP

Client  VLAN        Ports   Interval Count Cyclic      Xmit    Rcvd Action Port (sec)
-------------------------------------------------------------------------------------
CLI     Extreme1    All            3     0 Yes            0       0 LI     300    
-------------------------------------------------------------------------------------

The script ends up removing all Vlan's. I am using this from Netsight as a admin script.
(Edited)
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
I assume you mean the script ended up removing ELRP from all VLANs. I've been testing it from the CLI. I'll test it from NS when I have a chance.
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb
Yes, sorry mean elrp from the vlan's. I am running the script from Oneview so is not actually Netsight (6.3.0.168)
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
I modified it to work in as a OneView script:


#@MetaDataStart#############################################################################################
# Define your user parameters in this section. For reference, see bundled scripts.
#############################################################################################
# @VariableFieldLabel (description = "Interval (number > 0)")
set var int 1
#@MetaDataEnd
# Enter all CLI commands from here
disable clip
set var CLI.OUT 0
show elrp
set var s $TCL(split ${CLI.OUT} "\n")
set var i $TCL(lsearch $s *----*)
set var i ($i + 1)
set var e $TCL(lsearch $s *Print\,*)
set var e ($e - 1)
while ($i < $e) do
   set var l $TCL(lindex $s $i)
   set var v $TCL(lindex $l 1)
   set var p $TCL(lindex $l 2)
   set var n $TCL(lindex $l 3)
   set var a $TCL(lindex $l 8)
   set var d $TCL(lindex $l 9)
   set var t $TCL(regexp {\-} $d)
   set var t1 $TCL(regexp {L} $a)
   set var t2 $TCL(regexp {T} $a)
   set var t3 $TCL(regexp {E} $a)
   set var t4 $TCL(regexp {I} $a)
   set var t5 $TCL(expr $t1 && $t2)
   set var lt "log"
   set var ie ''
   if ($t2) then
      set var lt "trap"
   endif
   if ($t5) then
      set var lt "log-and-trap"
   endif
   if ($t3) then
      set var ie "egress"
   endif
   if ($t4) then
      set var ie "ingress"
   endif
   unconfig elrp $v
   if (!$t) then
         set var t $TCL(regexp {\d+} $d)
         if ($t) then
            configure elrp-client periodic $v ports $p interval $int $lt disable-port $ie duration $d
         else
            configure elrp-client periodic $v ports $p interval $int $lt disable-port $ie perm
         endif
   else
      configure elrp-client periodic $v ports $p interval $int $lt
   endif 
   set var i ($i + 1)
endwhile
Photo of Justsomebodi

Justsomebodi

  • 1,572 Points 1k badge 2x thumb
Thanks, i will give it a test.