Reply

NetMRI Regex

Techie
Posts: 15
4930     0

Does anyone have any idea why the trigger template in the following script is grabbing the MAC address twice rather than the MAC address and the port?  I put the regex into https://regex101.com/ and it works just fine.

 

Script-Filter:
$Vendor eq "Cisco"

Script-timeout: 600

# 1 e839.35xx.xxxx static ip,ipx,assigned,other GigabitEthernet3/30

###############

Action:
Get Ports

Action-Commands:
SET: $conf_mode = "no"
sh mac address-table

Output-Triggers:
Process MACs

###############

Trigger:
Process MACs

Trigger-Variables:
$deviceMAC /((?:[0-9A-Fa-f]{4}\.){2}(?:[0-9A-Fa-f]{4}))/

$port /(\w+\d+\/\d\/\d{1,2}|\w+\d+\/\d{1,2})/

Trigger-Template:
[[$deviceMAC]] .* [[$port]]

Trigger-Commands: {$deviceMAC like /00:60:35.*/}
SET: $conf_mode = "yes"
DEBUG: conf t
DEBUG: interface $port
DEBUG: shut
DEBUG: no shut

Trigger-Commands: {$conf_mode eq "yes" and $deviceMAC like /00:60:35.*/}
DEBUG: interface $port
DEBUG: shut
DEBUG: no shut

 

Re: NetMRI Regex

Adviser
Posts: 453
4930     0

If you post an excerpt of "sh mac address-table" I can use the built-in RegEx checking in NetMRI

https://yournetmriip/netmri/ccs/tx/regex_test/index.tdf

 

 

This is where I always test my Triggers Smiley Happy also Somethings that work in the work of regex101.com does not always work in NetMRI, trust me I've open many cases cause of that

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

https://sifbaksh.com

Re: NetMRI Regex

Techie
Posts: 15
4930     0

Here's an example:

 

1 e839.35xx.xxxx static ip,ipx,assigned,other GigabitEthernet3/30

 

 

Even in the built-in regex checker it captures the MAC address twice rather than the MAC and then the port.

Re: NetMRI Regex

Adviser
Posts: 453
4930     0

Ok found your issue, it's the capture () you don't need to use it NetMRI 

 

Use this Smiley Happy

$deviceMAC /(?:[0-9A-Fa-f]{4}\.){2}(?:[0-9A-Fa-f]{4})/
$port /\w+\d+\/\d\/\d{1,2}|\w+\d+\/\d{1,2}/regex_help.png

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

https://sifbaksh.com

Re: NetMRI Regex

Techie
Posts: 15
4930     0

 That did the trick!  Thanks for figuring that out for me.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You