Różnice między wybraną wersją a wersją aktualną.
Nowa wersja | Poprzednia wersja | ||
dzienne_użycie_łącza [2018/12/07 08:20] – utworzono kamil | dzienne_użycie_łącza [2019/05/31 11:06] (aktualna) – kamil | ||
---|---|---|---|
Linia 1: | Linia 1: | ||
====== Dzienne użycie łącza ====== | ====== Dzienne użycie łącza ====== | ||
- | Dodajemy | + | Dodajemy |
- | < | + | |
- | /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: | + | |
< | < | ||
/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#add action=passthrough chain=forward comment=WAN-IN in-interface=ether1\r\ | + | \n#:global wan {\"ether1\"; |
- | | + | |
\n\r\ | \n\r\ | ||
- | \n:local BYTESOUT [/ip firewall filter get [/ip firewall filter find comment=\"WAN-OUT\" | + | \n:global url \"https://mt.orchia.pl/ |
- | \n:local BYTESIN [/ip firewall filter get [/ip firewall filter find comment=\" | + | |
\n\r\ | \n\r\ | ||
- | | + | \n:global removeSpace do={ : |
- | | + | \n :for i from=0 to=([:len \$t] - 1) do={ : |
- | \n:local curYear | + | \n :if (\$char = \" \") do={ :set \$char \" |
- | \n: | + | \n :set temp (\$temp . \$char); }\r\ |
- | \n:local curDay [:pick \$curDate 4 6]\r\ | + | \n :return |
- | \n:local CURRENTDATE \"\$curYear-\$curMon-\$curDay\" | + | |
- | \n:local FILENAME \"\$curYear\$curMon.txt\" | + | |
\n\r\ | \n\r\ | ||
- | \n:if ([: | + | \n:global ident [/system identity get name];\r\ |
- | \n/file set \" | + | |
- | \n} else {\r\ | + | |
- | \n/file print file=\$FILENAME\r\ | + | |
- | \n/delay delay-time=2\r\ | + | |
- | \n/file set \" | + | |
- | \n}\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 46: | Linia 32: | ||
</ | </ | ||
- | Raz na 24h będzie | + | Raz na 24h będzie |