Reply

CCS Script Regex Help

Techie
Posts: 15
4050     0

I want to do a show int status and match the port and the VLAN in a trigger template.    

Port      Name                    Status          Vlan       Duplex  Speed Type
Gi1/0/1  Description           connected    123        a-full  a-100 10/100/1000BaseTX
Gi1/0/2  Description           connected    123        a-full a-1000 10/100/1000BaseTX
Gi1/0/3  Description           connected    123        a-full a-1000 10/100/1000BaseTX

I came up with this, but it doesn't work:

Trigger-Variables:

$c3750port /((Gi|Fa)+\d+\/\d\/\d{1,2})/ 
$vlan /([1-9]|[1-9][0-9]|[1-2][0-3][0-2])/

Trigger-Template: 
[[$c3750port]].*[[$vlan]].*

Do you guys have any ideas?

 

 

Try the following:

Adviser
Posts: 472
4051     0

Try the following:

Trigger-Variables:

$vlan /\d{1,3}/

Trigger-Template:

Gi.*connected\s.+\s.+[[$vlan]]\s

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com

That works for just the VLAN,

Techie
Posts: 15
4051     0

That works for just the VLAN, but I'm trying to get the port as well which does not seem to work for some reason.

This is what I ended up doing

Techie
Posts: 15
4051     0

This is what I ended up doing and it seems to work.  Please let me know if you can think of something better.

Trigger-Variables:
$c3750port /\w\d+\/\d\/\d{1,2}/ 
$c3750vlan /\d{1,3}/

Trigger-Template: 
(G|F)[[$c3750port]].*(connected\s|notconnect)\s.+[[$c3750vlan]]\s

Trigger-Commands: {$c3750port like /i/}
SET: $gifName = G$c3750port

Trigger-Commands: {$c3750port like /a/}
SET: $gifName = F$c3750port

Trigger-Commands: {$c3750vlan like /(9[6-9]|1[0-9][0-9]|2[0-3][0-2])/}

The few I tried was picking

Adviser
Posts: 472
4051     0

The few I tried was picking up the wrong thing not sure why.

Also to test use the following : http://netmriIP/netmri/ccs/tx/regex_test/index.tdf

I will trying sure I missed something.

 

Sif

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com

Yeah, I couldn't get it to

Techie
Posts: 15
4051     0

Yeah, I couldn't get it to pick it up right either.  I didn't know about that regex tester, that's pretty neat.  Thanks!

I'm trying to do something

Techie
Posts: 15
4051     0

I'm trying to do something similar now and not having much luck.  I want to match the device ID and the local interface in the 'show cdp neighbor' command but it will only let me match on one or the other.

sw#           sh cdp nei
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,
                  D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
SEP0004f2000001 Gig 1/1          159              H P   IP Phone  port 1
SEP0004f2000002  Gig 1/2          153              H P   IP Phone  port 1
SEP0004f2000003  Gig 2/10          150              H P   IP Phone  Port 1

I've tried a bunch of variations on variables and templates but I can't seem to match both device ID and interface ID.

Variables:

$deviceid /(\d|\w){12}/
$interface /\w.+\s\d\/\d{1,2}/

or

$interface /\d+\/\d{1,2}/

Templates:
SEP[[$deviceid]]\s.+(G|F)[[$interface]]

or

SEP[[$deviceid]]\s.*Gig\s.*[[$interface]]

or

[[$deviceid]]\s.*[[$interface]]

I had to do it this way, but

Techie
Posts: 15
4051     0

I had to do it this way, but I got it working:

$deviceid /SEP.{12}/

$interface /\w{3}\s\d\/\d{1,2}/

[[$deviceid]]\s+[[$interface]]

Showing results for 
Search instead for 
Did you mean: 

Recommended for You