Hi, I used this excellent LTELimiter script for several weeks on 2 SXT’s. Keeping an eye on the data volumes. It works excellent. Thanks for sharing!
I made it only run every 10 minutes not to damage the flash with too many write operations. The reset of the interface counters in an SXT LTE kit is also done when you disable/enable the interface (or switch between the SIM cards). Yesterday we had a power failure, and the counters that have been incremented over a long time, were reduced to some value of an earlier interface reset. The calculation of the “correct” counter value is mistakenly subtracting the “ref” value in the case of a counter reset.. Anything accumulated in this period is subtracted. So I modified the script to avoid this substraction of the accumulated value.
The script reads in that lower part now as:
:log info “Clear int counters - reboot”
#TODO find another method for interf clear counters
#/system reboot
#resetting interface will clear counters
/interface lte set $interf disabled=yes
/delay delay-time=2;
/interface lte set $interf disabled=no
/delay delay-time=2;
}
:if ( $day != $dayresetlimit ) do={
/file set $reblock contents=0
}
:local before
:local correct
:local ref
:local newdata
:local tx [/interface get $interf tx-byte]
:local rx [/interface get $interf rx-byte]
:set $newdata (( $rx + $tx ) / 1024 / 1024 )
:set $before [/file get $filename contents]
delta count ?
:if ( $newdata < $before ) do={
:set $ref [/file get $fileref contents]
# BPWL by counter reset then zero out old ref value
:if ( $newdata < $ref ) do={
set $ref (0)
}
:set $correct ( $before + $newdata - $ref )
/file set $fileref contents=$newdata
/file set $filename contents=$correct
}
regular count
:if ( $newdata >= $before ) do={
/file set $filename contents=$newdata
}
:local traffic ([/file get $filename contents])
:local percent ($traffic*100 / $limit)
:log warning “Limit: $limit MB Traffic: $traffic MB Used: $percent%”
/file set $filewarn contents=$percent
:if ($percent >= 100) do={
/file set $filewarn contents=$percent
/interface lte set $interf disabled=yes
}
:if ($percent < 100 and $autointon = true) do={
:set $status [/interface get $interf value-name=disabled]
:if ($status = true) do={
/interface lte set $interf disabled=no
}
}
} on-error={ :log error "Error LTELimiter "};