02-12-2015 05:53 AM
On a port channel (Etherchannel) the bandwidth changes based on how many links are in up state. The QoS shaper bandwidth on port channel sub-interfaces (VLAN's) need to be adjusted accordingly.
I'd like to have a script for IOS routers that runs every n seconds: reads the port-channel "show interface" bandwidth, and if different from last time: change some shape statements in QoS policies.
Alternatively:
I'd like to have a script for IOS routers that runs every n seconds: reads the port-channel "show interface" bandwidth, and if different from last time: change applied egress policies on sub-intefaces to different ones..
Solved! Go to Solution.
02-12-2015 06:06 PM
Here is an example of a policy that will run every 30 seconds look at the output bps and apply a shaped rate to the interface (gig0/0 in this example) that is twice the measured rate.
event manager environment qos_intf gig0/0
event manager environment firstrun 0
event manager applet qos
event timer watchdog time 30
action 001 if $firstrun eq 0
action 002 set prate "0"
action 003 context save key previousrate variable "prate"
action 010 cli command "enable"
action 012 cli command "conf t"
action 013 cli command "event manager environment firstrun 1"
action 014 cli command "end"
action 015 end
action 016 cli command "enable"
action 020 cli command "show int $qos_intf | inc output rate"
action 040 regexp "([0-9]+) bits" "$_cli_result" match rate
action 060 context retrieve key previousrate variable "prate"
action 065 cli command "conf t"
action 070 if $rate ne prate
action 075 multiply $rate 2
action 080 cli command "policy-map shaper"
action 090 cli command "class class-default"
action 100 cli command "shape average $rate"
action 110 cli command "interface $qos_intf"
action 120 cli command "service-policy out shaper"
action 150 syslog msg "Shaper on $qos_intf changed from $prate to $rate bps"
action 160 set prate "$rate"
action 170 context save key previousrate variable "prate"
action 200 end
event manager applet setfirstrun
event syslog pattern "SYS-5-RESTART"
action 010 cli command "enable"
action 020 cli command "conf t"
action 030 cli command "event manager environment firstrun 0"
02-12-2015 06:06 PM
Here is an example of a policy that will run every 30 seconds look at the output bps and apply a shaped rate to the interface (gig0/0 in this example) that is twice the measured rate.
event manager environment qos_intf gig0/0
event manager environment firstrun 0
event manager applet qos
event timer watchdog time 30
action 001 if $firstrun eq 0
action 002 set prate "0"
action 003 context save key previousrate variable "prate"
action 010 cli command "enable"
action 012 cli command "conf t"
action 013 cli command "event manager environment firstrun 1"
action 014 cli command "end"
action 015 end
action 016 cli command "enable"
action 020 cli command "show int $qos_intf | inc output rate"
action 040 regexp "([0-9]+) bits" "$_cli_result" match rate
action 060 context retrieve key previousrate variable "prate"
action 065 cli command "conf t"
action 070 if $rate ne prate
action 075 multiply $rate 2
action 080 cli command "policy-map shaper"
action 090 cli command "class class-default"
action 100 cli command "shape average $rate"
action 110 cli command "interface $qos_intf"
action 120 cli command "service-policy out shaper"
action 150 syslog msg "Shaper on $qos_intf changed from $prate to $rate bps"
action 160 set prate "$rate"
action 170 context save key previousrate variable "prate"
action 200 end
event manager applet setfirstrun
event syslog pattern "SYS-5-RESTART"
action 010 cli command "enable"
action 020 cli command "conf t"
action 030 cli command "event manager environment firstrun 0"
02-13-2015 05:56 AM
Thank you very much Dan. I will try it and let you know if I need more help.
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