i have a problem for this script. CODE 1 script is working well it sends telegram message to me but i am tying to convert this code if bandwidth test result lower then 7 send message to me if not dont send any message. i tried in CODE 2 but it doesnt work. can u have any ideas for this
I record result’s of Bandwidth Test into logs, your script’s was convert into function and now is perfect.
The scheduler do every x time the “Bandwidth Test” via duration=15s and grab rx/tx-10-second-average data what is write into log’s like this:
by script:
local speedtest [tool bandwidth-test [:resolve btserver.domain.tld] protocol=tcp user=btest password=******* direction=both duration=15s as-value ] ;
local MyFuncDataToMKbps do={
local DataOriginal $1
set DataOriginal ($DataOriginal / 1000)
local Mbps ($DataOriginal / 1000 * 1000)
local Kbps ($DataOriginal - $Mbps)
set Mbps ($Mbps / 1000)
return ($Mbps."M ".$Kbps."K - bps")
}
local Rx [$MyFuncDataToMKbps ($speedtest->"rx-10-second-average")]
local Tx [$MyFuncDataToMKbps ($speedtest->"tx-10-second-average")]
local Time ([/system clock get date]." ".[/system clock get time])
put "$Time | Rx: $Rx | Tx: $Tx"
log warning "$Time | Rx: $Rx | Tx: $Tx"
I can easy display filtred results in CLI / Terminal via
thanx for your message but my first code is doing same thing too. i wanna do if bandwidth test result lower then 7 send message to me if not dont send any message
But this is so easy, at the end of my script I receive in $Rx the “18M 200K …” then i select first numbers and compare them, add this at the end of my script:
local DLMb [pick $Rx 0 [:find $Rx "M"]]
if ($DLMb < 7) do={/tool fetch keep-result=no url="https://api.telegram.org/xxxxxxxxxxxxx: ... STERI-TEST $Rx "}