I’m wondering if anyone has stumbled across a script that can do following:
I have a 3G Dongle with a 1Gb Cap, however after the gig is reached i get charged a premium…
I would like to use this dongle on my Mikrotik router (which isn’t an issue) , however i would like to set the max amount of traffic allowed over the pppoe client connection to 1Gb and allow no more… Or disable interface would even be better to avoid over usage…
Interface counters reset on reboot, so any internal mechanism is going to be unreliable and you could get hit with charges. The only clean solution is to monitor interface counters from an outside system and use the API to disable the interface once counters indicate you’re near your cap.
I understand that it would be unreliable to use interface counters, however the system is on a battery backup and in theory would be a simpler solution if I’m not mistaken.
I will accept the inherent issues associated with reboots…
Write a script that is scheduled to run every 5 minutes, and use “get” to fetch the “bytes” column of the interface you’re looking at. Something along the lines of:
:local bytes [/interface get [/interface find name="3g"] bytse;
Use “:pick” to split it into RX/TX and evaluate the resulting values against your cap. If it’s above your cap, or close to it, disable the interface (“/interface disable [/interface find name=“3g”]”), if it is below your cap or threshold, enable it.
Run a script scheduled on the day your cap resets that goes and resets the counters of the interface so that the first script re-enables the interface between 0-5 minutes later.