cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2072
Views
0
Helpful
4
Replies

List interface names only without any additional information.

bennyvdotcom
Level 1
Level 1

Hey All,

I'm wanting to create an applet that lists all non trunk ports on a switch, however I need the interface name only, I don't want the interface description, status, VLAN etc. Does anyone have any idea if its possible? 

Cheers,
BennyV       

Cheers, BennyV
1 Accepted Solution

Accepted Solutions

This won't give you non-trunk ports.  It will give you all ports.  And you likely want:

action 101 foreach line $_cli_result "\n"

action 110 regexp "^(.*Ethernet[^ ]+) " $line match intf

action 150 if $_regexp_result eq 1

action 160 puts "*$intf*"

action 170 end

action 180 end

View solution in original post

4 Replies 4

bennyvdotcom
Level 1
Level 1

Just to add I was hoping something like this would help.

event manager applet get_if

event none

action 100 cli command "show ip interface brief"

action 110 regexp " FastEthernet\d\/\d\/\d* " $_cli_result result

action 150 if $_regexp_result eq 1

action 160  puts "*$result*"

action 170 else

action 180  puts "No Results"

action 190 end

But the regex does not match for whatever reason.

Cheers, BennyV

This won't give you non-trunk ports.  It will give you all ports.  And you likely want:

action 101 foreach line $_cli_result "\n"

action 110 regexp "^(.*Ethernet[^ ]+) " $line match intf

action 150 if $_regexp_result eq 1

action 160 puts "*$intf*"

action 170 end

action 180 end

bennyvdotcom
Level 1
Level 1

That's perfect, you've put me in the right direction. Thank You!

By the way, massive fan mate!

Cheers, BennyV

So this was to update all non trunk ports with some new QoS Config across multiple stacks. We have multiple trunk ports on each switch, so a range command was unlikley to work. This runs a "show interface status | e trunk" then for each result applies the config on the device. Its not the cleanest way to do this but it was sucessful.

event manager applet get_if

event none maxrun 60.00

action 100 cli command "show int status | e trunk"

action 120 foreach line $_cli_result "\n"

action 130 regexp "^(.*Fa[^ ]+|.*Gi[^ ]+) " $line match intf

action 140 if $_regexp_result eq 1

action 150 cli command "enable"

action 151 cli command "config t"

action 152 cli command "interface $intf"

action 153 cli command "no auto qos voip cisco-phone"

action 154 cli command "mls qos trust device cisco-phone"

action 155 cli command "auto qos trust cos"

action 156 puts "Update Sucessful $intf"

action 170 end

action 180 end

end

event manager run get_if

Cheers, BennyV