Różnice między wybraną wersją a wersją aktualną.
| Poprzednia rewizja po obu stronachPoprzednia wersjaNowa wersja | Poprzednia wersja | ||
| dzienne_użycie_łącza [2019/05/27 09:56] – kamil | dzienne_użycie_łącza [2025/01/11 18:58] (aktualna) – edycja zewnętrzna 127.0.0.1 | ||
|---|---|---|---|
| Linia 1: | Linia 1: | ||
| ====== Dzienne użycie łącza ====== | ====== Dzienne użycie łącza ====== | ||
| - | Dodajemy dwie reguły firewalla oraz przenosimy je na samą górę: | + | Dodajemy skrypt i modyfikujemy w nim zmienną wan, która wskazuje |
| - | < | + | |
| - | /ip firewall filter | + | |
| - | add action=passthrough chain=forward comment=WAN-IN in-interface=ether1 | + | |
| - | add action=passthrough chain=forward comment=WAN-OUT out-interface=ether1 | + | |
| - | </ | + | |
| - | Gdzie ether1 to nasz WAN | + | |
| - | + | ||
| - | Dodajemy skrypt i modyfikujemy w nim frazę " | + | |
| < | < | ||
| /system script | /system script | ||
| - | add dont-require-permissions=no name=wanusage owner=admin policy=ftp, | + | add dont-require-permissions=no name=wanusage owner=admin policy=ftp, |
| - | \n:local BYTESIN [/ip firewall filter get [/ip firewall filter find comment=\" | + | \n#:global wan {\" |
| + | \n\r\ | ||
| + | \n:global url \" | ||
| \n\r\ | \n\r\ | ||
| - | \n:set \$str \" | + | \n:global removeSpace do={ :local temp;\r\ |
| + | \n :for i from=0 to=([: | ||
| + | \n :if (\$char = \" | ||
| + | \n :set temp (\$temp . \$char); }\r\ | ||
| + | \n :return \$temp; }\r\ | ||
| \n\r\ | \n\r\ | ||
| - | \n/tool fetch mode=https url=\" | + | \n:global ident [/system identity get name];\r\ |
| \n\r\ | \n\r\ | ||
| - | \n/ip firewall filter reset-counters | + | \n:foreach w in=\$wan do={\r\ |
| - | \n/ip firewall filter reset-counters [find comment=\"WAN-OUT\" | + | \n :set \$tx0 [\$removeSpace t=[:tostr [/interface ethernet get value-name=tx-bytes \$w]]]; |
| - | \n" | + | \n :set \$rx0 [\$removeSpace t=[:tostr [/interface ethernet get value-name=rx-bytes \$w]]]; |
| + | \n :set \$str \"device=\$ident-\$w& | ||
| + | \n /tool fetch mode=https url=\" | ||
| + | \n /interface ethernet reset-counters \$w;\r\ | ||
| + | \n}" | ||
| </ | </ | ||
| Linia 30: | Linia 32: | ||
| </ | </ | ||
| - | Raz na 24h będzie | + | Raz na 24h będzie |