O que acabei fazendo foi:
Eu escrevi um script que é executado no roteador openwrt a cada minuto para obter a largura de banda atual do modem, subtrai algumas margens e aplica esse valor ao SQM-config
In case anyone else has this issue, here is the script I wrote. I am new to lua and programming on OpenWrt, so expect errors, but maybe it will help others.
http=require'socket.http'
body,c,l,h = http.request('http://modem/page_showing_current_speed')
bandwidth = "%[kbps/kbps%]:</td><td colspan='3'>[%d.]+ / [%d.]+</td></tr>"
bw_s = string.sub(body, string.find(body, bandwidth))
bandwidth = "[%d.]+ / [%d.]+"
bw_s = string.sub(bw_s, string.find(bw_s, bandwidth))
upload_r = "[%d.]+ "
upload = string.sub(bw_s, string.find(bw_s, upload_r))
upload_r = "[%d.]+"
upload = string.sub(upload, string.find(upload, upload_r))
upload = upload:gsub("%.", "")
download_r = " [%d.]+"
download = string.sub(bw_s, string.find(bw_s, download_r))
download_r = "[%d.]+"
download = string.sub(download, string.find(download, download_r))
download = download:gsub("%.", "")
print(upload)
print(download)
f = io.open("/etc/config/sqm", "rw")
content = f:read("*all")
f:close(f)
oldcontent = content
content = content:gsub("option download '%d+", "option download '" .. download)
content = content:gsub("option upload '%d+", "option upload '" .. upload)
if content == oldcontent
then
else
print(content)
f2 = io.open("/etc/config/sqm", "w")
f2:write(content)
f2:flush(f2)
f2:close(f2)
os.execute("/etc/init.d/sqm restart")
end
then run:
opkg update
opkg install luasocket
crontab -e
* * * * * lua /adjustsqm.lua
/etc/init.d/cron restart
it gets the current speed from the modem every minute and writes it into the sqm configuration