Reply
Highlighted

CCS Netmri Trigger template question

csi-net
Techie
Posts: 14
2802     0

Hello I'm wriring a script that look at the output command below:

Switch#sh cdp nei | i Nexus
                 Gig 2/0/1         162              S I   Nexus1000 control0
                 Gig 2/0/35        162              S I   Nexus1000 Eth 13/4
                 Gig 2/0/42        162              S I   Nexus1000 Eth 13/3
                 Gig 2/0/6         162              S I   Nexus1000 Eth 14/4
                 Gig 2/0/2         162              S I   Nexus1000 Eth 14/3

 

And on trigger I have

 

Trigger-Variables:
    $sx_mod int
    $sx_port int
    $sxn1k_vem int
    $sxn1k_nic /\d+/ number

Trigger-Template:
       Gig [[$sx_mod]]/0/[[$sx_port]].*Eth [[$sxn1k_vem]]/[[$sxn1k_nic]]

 

When the regular expression is matched aginst the "sh cdp nei | i Nexus" Command (I used the Regular Expression Test Tool), since the first line contain control0 and not a number the match is:

 

16:21:27      Trigger-Template
16:21:27       Template matches
16:21:27       Gig (2)/0/(1).*Eth (13)/(4)
 16:21:27      Trigger-Variables
 16:21:27           $sx_mod = '2'
 16:21:27           $sx_port = '1'
 16:21:27           $sxn1k_vem = '13'
 16:21:27           $sxn1k_nic = '4'
 16:21:27      Trigger-Commands
 16:21:27           SET: $donothing = "true"

 

 

As you see Gig 2/0/1 is not on the same line as Eth 13/4.

From my point of view is that I should define the regular expression with end of line caracter, I tried with $ (as in regex but is not working. It seams that Trigger-Template expression is not matched agains each line but on the whole text.

 

Where I'm wrong ?

Re: CCS Netmri Trigger template question

Expert
Posts: 124
2803     0

The .* in regex will include end of line.  Try using .+ instead.  I am assuming you don't want any match on the first line.

 

http://www.tutorialspoint.com/ruby/ is a pretty good resource.

 

Let us know if this works, I didn't try it.

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You