Difference between revisions of "Ros3 Traffic Limit"
From CTWUG Wiki
ScarFreewill (talk | contribs) (New page: I hope this article will grow as people read it. For now this is how I limit my pptp and yes I'm refusing to use radius. ==Scar's Interface traffic limiter (Fail cake edition)== This is t...) |
ScarFreewill (talk | contribs) |
||
Line 13: | Line 13: | ||
:local limit 30; | :local limit 30; | ||
− | :local bool [/interface get | + | :local bool [/interface get $interface disabled]; |
:if ($bool = false) do={ | :if ($bool = false) do={ | ||
:local usage [/interface get $interface bytes]; | :local usage [/interface get $interface bytes]; |
Revision as of 14:40, 29 September 2009
I hope this article will grow as people read it. For now this is how I limit my pptp and yes I'm refusing to use radius.
Scar's Interface traffic limiter (Fail cake edition)
This is the script checks how much data has been used on the interface, if it is over the limit it will disable the interface.
# Interface limit for pptp # Written by Willem "ScarFreewill" Dreyer # Date 28/09/2009 # interface you want to limit :local interface "yourinterfacegoeshere"; # limit in mb :local limit 30; :local bool [/interface get $interface disabled]; :if ($bool = false) do={ :local usage [/interface get $interface bytes]; :local ulen [:len $usage]; :local rx; :local tx; :local total; :local totalmb; # Mufasa's example next line: # :put [:pick [ /interface get $interface bytes] 0 [ :find [ /interface get interface bytes ] "/" ] ]; :for j from=( $ulen ) to=0 do={ :if ( [:pick $usage $j] = "/") do={ :set rx [:pick $usage 0 $j]; :set tx [:pick $usage ($j+1) $ulen]; } } :set total ($rx+tx); :set totalmb (($total/1024)/1024); :log info ($interface . ": rx:" . (($rx/1024)/1024) . "mb + tx:" . (($tx/1024)/1024) . "mb = total:" . $totalmb . "mb"); :if ($totalmb>$limit) do={ :log info ($interface . ": is over the limit, disabling..."); /interface set $interface disabled=yes; } } else={ # :log info ($interface . ": disabled"); }