Creating a script for sending SMS

@ludycro, @hafte You can use one of these two scripts in scheduler event (startup with some interval, eg. 5min).

Script with interface rx/tx bytes with persistence in interface comment

:local smsSendThresholdMiB 9216
:local smsNumber "13880"
:local smsMessage "NASTAVI"
:local wanIf "lte1"

/interface
:if ([get $wanIf disabled] || ![get $wanIf running]) do={ :return [:nothing] }
:local rx [get $wanIf rx-byte]
:local tx [get $wanIf tx-byte]
:if ($rx = 0 && $tx = 0) do={ :return [:nothing] }
reset-counters $wanIf
:local bts ($rx + $tx + [:tonum [get $wanIf comment]])

:if (($bts / 1048576) > $smsSendThresholdMiB) do={
    set $wanIf comment=0
    /tool/sms/send phone-number=$smsNumber message=$smsMessage
} else={
    set $wanIf comment=$bts
}

Script with interface rx/tx bytes with persistence in file

:local smsSendThresholdMiB 9216
:local smsNumber "13880"
:local smsMessage "NASTAVI"
:local wanIf "lte1"
:local bytesFile "flash/$wanIf_bytes.txt"

/interface
:if ([get $wanIf disabled] || ![get $wanIf running]) do={ :return [:nothing] }
:local rx [get $wanIf rx-byte]
:local tx [get $wanIf tx-byte]
:if ($rx = 0 && $tx = 0) do={ :return [:nothing] }
reset-counters $wanIf

:local lastBytes 0
/file
:if ([find name=$bytesFile] != "") do={
    :set lastBytes [:tonum [get $bytesFile contents]]
} else={
    add name=$bytesFile contents=0
}

:local bts ($rx + $tx + $lastBytes)

:if (($bts / 1048576) > $smsSendThresholdMiB) do={
    set $bytesFile contents=0
    /tool/sms/send phone-number=$smsNumber message=$smsMessage
} else={
    set $bytesFile contents=$bts
}

If you have USB disk connected to device you can change bytesFile to be in usb drive path instead flash.

P.S.
Script doesn’t know how much traffic was before scheduler is initially created, so better reset interface counters (/interface/reset-counters lte1) and send manually sms to reset quota to be calibrated when scheduler is created. Generally to calibrate script if was already performed - just clear interface comment or delete bytes file (depends which script is used), reset interface counters and send sms manually assuming that provider will reset quota imidialty when sms is sent.