08-11-2013 08:01 PM
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
Solved! Go to Solution.
08-11-2013 09:50 PM
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
08-11-2013 09:32 PM
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.
08-11-2013 09:50 PM
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
08-11-2013 09:54 PM
That's perfect, you've put me in the right direction. Thank You!
By the way, massive fan mate!
08-12-2013 12:28 AM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide