Reply

NetMRI Trigger Template - Filter on beginning of the line

Posts: 75
4011     0

Hi Guys,

 

I am working on a very simple trigger template for  CCS script.

 

I want to match on:

ip http server

 

but I don't want to match on:

no ip http server

 

I tried using a ^ at the beginning of the trigger template, but NetMRI is sending back an error to say this is not supported.

 

Is there another way to indicate the beginning of the line?  Please see my script attached.  Thanks in advance for your help with this.

 

Script:

Script-Filter:
    $Vendor eq "Cisco" and $sysDescr like /IOS/

########################################################################
Action:
    Get http

Action-Commands:
SET: $UpdateMade = "no"
sho run | inc http

Output-Triggers:
    Update HTTP
        Update HTTPS
     
##########################################################################
Trigger:
Update HTTP

Trigger-Template:
ip http server

Trigger-Commands: {$UpdateMade eq "no"}
config t
SET: $UpdateMade = "yes"

Trigger-Commands:
DEBUG: no ip http server

########################################################################
Trigger:
    Update HTTPS

Trigger-Template:
 ip http secure-server

Trigger-Commands: {$UpdateMade eq "no"}
config t
SET: $UpdateMade = "yes"

Trigger-Commands:
DEBUG: no ip http secure-server

#########################################################################
Action:
End and Write Memory

Action-Commands: {$UpdateMade eq "yes"}
DEBUG: end
DEBUG: write mem

Re: NetMRI Trigger Template - Filter on beginning of the line

[ Edited ]
Adviser
Posts: 472
4012     0

Use one trigger and create the following

 

Trigger-Variables:

$sif /ip\shttp\sserver|ip\shttp\ssecure\-server/

 

Trigger-Template:

[[$sif]]

 

Trigger-Commands:
DEBUG: no $sif

 

Tested it on Version 7.0.1 Smiley Wink using the Regex Tool Tester in NetMRI

http://netmri/netmri/ccs/tx/regex_test/index.tdf

 

Let me if it works Smiley Happy

 

Sif

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

https://sifbaksh.com

Re: NetMRI Trigger Template - Filter on beginning of the line

Posts: 75
4012     0

Hi Sif,

 

First off, I like the Regular Expression Test page. I didn't know abou that! Awesome!

 

The trigger template does work, but not the way I would expect it.  For example, in the output below it matches on ip http server and ip http secure-server.  This part makes sense.  I want to force it to match the string only if starts at the beginning of the line.  Even though the CCS documentation says it supports Perl Regex, when I tried to use the ^ to indicate the beginning of a line, I get an error.

 

The first line "no ip http server" has been disabled.  This one I do not want to make the change on because it is already done.  With the script updated, it still runs the command "no ip http server". 

 

Thoughts?  Script and script output is below.

 

Thanks for the help!

 

router#sho run | inc http

no ip http server

ip http secure-server

 

UPDATED SCRIPT:

Script-Filter:
    $Vendor eq "Cisco" and $sysDescr like /IOS/

########################################################################
Action:
    Get http

Action-Commands:
SET: $UpdateMade = "no"
sho run | inc http

Output-Triggers:
    Update HTTP
        Update HTTPS
     
##########################################################################
Trigger:
Update HTTP

Trigger-Variables:
$fix /ip\shttp\sserver/

Trigger-Template:
[[$fix]]

Trigger-Commands: {$UpdateMade eq "no"}
config t
SET: $UpdateMade = "yes"

Trigger-Commands:
no ip http server

########################################################################
Trigger:
    Update HTTPS

Trigger-Variables:
$fixit /ip\shttp\ssecure\-server/

Trigger-Template:
[[$fixit]]

Trigger-Commands: {$UpdateMade eq "no"}
config t
SET: $UpdateMade = "yes"

Trigger-Commands:
no ip http secure-server

#########################################################################
Action:
End and Write Memory

Action-Commands: {$UpdateMade eq "yes"}
end
write mem

 

SESSION LOG

router#sho run | inc http

no ip http server

ip http secure-server

router#config t

Enter configuration commands, one per line. End with CNTL/Z.

router(config)#no ip http server

router(config)#no ip http secure-server

router(config)#end

router#write mem

 

 

Re: NetMRI Trigger Template - Filter on beginning of the line

Adviser
Posts: 472
4012     0

Some more RegEx for you Smiley Wink

Look behind Positive(?<=)

Find expression A where expression B precedes

  • (?<=B)A

 

$fix /(?<=no\s)ip\shttp\sserver/

 

$fixit /(?<=no\s)ip\shttp\ssecure\-server/

Tested it in the RegEx Tester, let me know if it works

 

Enjoy and have a great weekend

Sif

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

https://sifbaksh.com

Re: NetMRI Trigger Template - Filter on beginning of the line

Expert
Posts: 244
4012     0

You could also let the CLI parser do the work:

  show runn | inc ^ip http

 

That will only produce output for the lines you desire.

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You