我们有很多 Cisco 800 系列路由器和同样的问题。我创建了一个我计划在路由器上运行的 TCL 脚本,因此它会读出 xDSL 同步上传带宽并相应地配置策略映射。这是脚本:
# Create empty variables because TCLshell is not very bright
set errlevel 0
# Set the amount of percentage that the upload is utilizing from the total bandwidth
# Internal bandidth analisation of multiple branches have shown that currently (june 2020) about 22% of the bandidth is used for uploads
set uploadpercent 22
# Gets the hostname of the device
set rohostname [lindex [exec "show running-config | include ^hostname"] 1]
# Gets the current speed
set currentspeed [lindex [exec "show policy-map QOS_OUT | include cir"] 1]
# Gets the model of the router
set getModel [exec "show running-config | include license"]
if {[lindex $getModel 3] == "C892FSP-K9"} {
# We assume a bandwidth of at least 100Mbit/s and will configure a corresponding bandwidth of 80Mbit/s (80%)
set newspeed [expr 800000 * $uploadpercent]
# We calculate what amount of this speed falls to upload, as only the upload is limited
} elseif {[lindex $getModel 3] == "C897VA-K9"} {
# Checking, if VDSL is synchronized
set VDSLSTATUS [exec "show controllers vDSL 0 | include Modem Status:"]
if {[regexp {TC\sSync} $VDSLSTATUS]} {
set vdslupspeed [lindex [exec "show controllers vDSL 0 | include ^Speed"] 5]
set kbitfilling "000"
set newspeed [expr $vdslupspeed$kbitfilling / 100 *80]
} else {
# VDSL link is currently down, so there is no way to read the synched speed
set errlevel 1
set errdescription "VDSL Link down"
}
} else {
set errlevel 1
set errdescription "Unsupported model"
}
# Check if there is a speed difference and configure new speed
if {$errlevel == 0} {
if {$newspeed != $currentspeed} {
ios_config "policy-map QOS_OUT" "class class-default" "shape average $newspeed"
exec "write"
}
}
# Create human understandable speeds
if {$errlevel == 0} {
set currentspeedhuman [expr $currentspeed /1000]
if {[string length $currentspeedhuman] >= 4} {
set currentspeedhuman "[string range $currentspeedhuman 0 end-3]'[string range $currentspeedhuman end-2 end]"
}
set newspeedhuman [expr $newspeed /1000]
if {[string length $newspeedhuman] >= 4} {
set newspeedhuman "[string range $newspeedhuman 0 end-3]'[string range $newspeedhuman end-2 end]"
}
}
# Report back to Splunk
if {$errlevel == 0} {
if {$newspeed == $currentspeed} {
puts "The speed of the QoS policy remains unchanged at $newspeedhuman Kbit/s"
[exec "send log facility MANAGEMENT severity 6 mnemonics LOG The speed of the QoS policy remains unchanged at $newspeedhuman Kbit/s"]
} else {
puts "The speed of the QoS policy has been adjusted from $currentspeedhuman Kbit/s to $newspeedhuman Kbit/s"
[exec "send log facility MANAGEMENT severity 6 mnemonics LOG The speed of the QoS policy has been adjusted from $currentspeedhuman Kbit/s to $newspeedhuman Kbit/s"]
}
} else {
puts "The script encountered an issue and did not change anything. Error description: $errdescription"
[exec "send log facility MANAGEMENT severity 6 mnemonics LOG he script encountered an issue and did not change anything. Error description: $errdescription"]
}
当然,您需要调整设备和配置的值。然后,您可以创建一个 EEM 小程序,它每周运行一次脚本:
event manager applet SETQOSBANDWIDTH
event timer cron cron-entry "0 3 * * 1"
action 1.0 cli command "enable"
action 2.0 cli command "tclsh flash:qosbandwidth.tcl"
action 3.0 syslog priority informational msg "CronJob for setting QoS bandwidth ran successful" facility "MANAGEMENT"