cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

NCM policy rule creation for specific interfaces

Jump to solution

What I am looking to do is write a rule that checks three interfaces and looks for the shutdown command on those interfaces.

I wrote it like this initially

Must contain find string   Interface GigabitEthernet2/43

                                           Shutdown

That actually did work on a few, because there was no garbage in between.  but most of them have stuff in between.

If I do this with a config block it targets all the interfaces.

so what is the solution to write a simple rule that confirms or denies that only 7 specefic interfaces are in a shutdown state?

I need Interface GigabitEthernet2/41 through 2/47.

any advise suggestions would be very helpful.

thank you

0 Kudos
1 Solution

Hey Jacob,

Can you try this one out, I think it will do what you are asking.

pastedImage_0.png

Rules for easy copy and paste:

String Match

^interface GigabitEthernet 2/4[1-7]{1}

^\s{1,}shutdown[\r\n]*$

Search Config File/Block

^interface GigabitEthernet 2/4[1-7]{1}

If that works for you here is also a remediation script you can use.

pastedImage_1.png

Let me know if this works out for you or if you encounter any issues.

View solution in original post

7 Replies

jacob.johnson​,   If you are looking to do the entire device or multiple devices in your network you can use this as a sample and adjust from there. 

STIG-V8R19-CSCO-Port Management

0 Kudos

Hey Jacob,

Can you try this one out, I think it will do what you are asking.

pastedImage_0.png

Rules for easy copy and paste:

String Match

^interface GigabitEthernet 2/4[1-7]{1}

^\s{1,}shutdown[\r\n]*$

Search Config File/Block

^interface GigabitEthernet 2/4[1-7]{1}

If that works for you here is also a remediation script you can use.

pastedImage_1.png

Let me know if this works out for you or if you encounter any issues.

View solution in original post

Hello,

May someone help me with this same question but different port?

FastEthernet0/1-8

Every time I've tried I get

Pattern '^interface FastEthernet 0/4[1-7]{1}' was not found

and

Pattern '^\s{1,}shutdown[\r\n]*$' was not found

pastedImage_0.png

0 Kudos

tsanchez11​ try changing your first line for both to the below

^interface FastEthernet 0/[1-7]{1}

the way you had it originally would've looked for an interface with the name "interface FastEthernet 0/41 through 47" (per what you have in the post) or interface FastEthernet 0/01 through 07 (per what you have in the screenshot) if you want it to only look for "FastEthernet 0/1-7" you need to remove the first 4 per your post or 0 per your screenshots.

heres a pretty good regex tester I use to help validate my regex Regex tester

pastedImage_1.png

pastedImage_2.png

0 Kudos

okay, Might help if my config block was using regular expressions.

got it and it worked perfectly

thank you very much

0 Kudos

No problem at all, glad it worked for you.

Thank you very much for the infromation

when I set this up and test it, I get pattern  ^interface GigabitEthernet 2/4[1-7]{1} was not found

Pattern  ^\s{1,}shutdown[\r\n]*$ was not found.

I know that 2/45 is shutdown, and 2/44 is not.  so is this rule only going to be compliant if all 7 are down? and there is a way to get it to show me which is down and which is not of those seven in the policy results?