Page 1 of 1

BandWidth Test for email

Posted: Thu Feb 27, 2014 1:11 am
by wagnernascimento
Pessoal gostaria de saber se alguém tem um script parecido como esse funcionando.
Seria o seguinte fazer o teste em outro mikrotik e mandar o resultado por email, sendo assim programo ele para ver se está passando a banda em determinado link.
Não estou conseguindo mandar o resultado do teste para o email.

:global i
/tool bandwidth-test 192.168.1.1 protocol=udp direction=both duration=12s local-tx-speed=50M remote-tx-speed=50M user=login password=senha
do={
:if ($status="running") do={
:set i $tx-current $rx-current
}
}
:delay 15s
/tool e-mail send to="usuario@gmail.com" subject="Bandwidth test results" body=("Transmitted bytes/s:" . $i)

Re: BandWidth Test for email

Posted: Thu Feb 27, 2014 6:55 pm
by skot
Make sure the "/tool bandwidth ... do={" is all on one line, and the variables with dashes are quoted. You could do something like this:

ros code

/tool bandwidth-test 192.168.1.1 protocol=udp direction=both duration=12s local-tx-speed=50M remote-tx-speed=50M user=login password=senha do={
  :if ($status="done testing") do={
	:local i ($"tx-current" . "/" . $"rx-current")
	/tool e-mail send to="usuario@gmail.com" subject="Bandwidth test results" body=("Transmitted bytes/s:" . $i)
  }
}

Re: BandWidth Test for email

Posted: Thu Feb 27, 2014 9:02 pm
by IHRMax
You can try my code, I just do. It sends information about the Bandwidth test and the name of the Board and the date / time.
Make sure you have set up a outgoing mail server
If you have information to improve the code, comment :D
:local txc
:local txcA
:local txcB
:local txcC

:local rxc
:local rxcA
:local rxcB
:local rxcC

:local rxta
:local rxtaA
:local rxtaB
:local rxtaC

:local txta
:local txtaA
:local txtaB
:local txtaC

:local sysname [/system identity get name]
:local datetime "$[/system clock get date] $[/system clock get time]"

:log info "Bandwidth-test start"

/tool bandwidth-test 1.1.1.2 protocol=udp direction=both duration=30s user=BWT password=BWT do={

:set txcA ($"tx-current" / 1000)
:set txcB ($txcA / 1000 * 1000)
:set txcC ($txcA - $txcB)
:set txcB ($txcB / 1000)
:set txc "$txcB.$txcC"

:set rxcA ($"rx-current" / 1000)
:set rxcB ($rxcA / 1000 * 1000)
:set rxcC ($rxcA - $rxcB)
:set rxcB ($rxcB / 1000)
:set rxc "$rxcB.$rxcC"

:set rxtaA ($"rx-total-average" / 1000)
:set rxtaB ($rxtaA / 1000 * 1000)
:set rxtaC ($rxtaA - $rxtaB)
:set rxtaB ($rxtaB / 1000)
:set rxta "$rxtaB.$rxtaC"

:set txtaA ($"tx-total-average" / 1000)
:set txtaB ($txtaA / 1000 * 1000)
:set txtaC ($txtaA - $txtaB)
:set txtaB ($txtaB / 1000)
:set txta "$txtaB.$txtaC"

}

:log info "Bandwidth-test done, sending info by e-mail"

/tool e-mail send to="your@email.com" subject="Bandwidth-test done : $sysname" body="$sysname \n  $datetime \n \n Result : \n TX speed $txc Mbps/s \n RX speed $rxc Mbps/s \n \n TX total average $txta Mbps/s \n RX total average $rxta Mbps/s"

Re: BandWidth Test for email

Posted: Fri Feb 28, 2014 1:20 am
by wagnernascimento
thank you

graciously

Wagner Nascimento

Re: BandWidth Test for email

Posted: Mon Sep 15, 2014 11:21 pm
by toboo
i have the menssage mikrotik>: invalid FROM adress

someone have the solution?

Re: BandWidth Test for email

Posted: Sun Feb 14, 2016 8:33 am
by BobcatGuy
This works pretty good. Thanks for the effort you put in creating it.

Wondering if there is a way to take this and create a file with the data.

What I would like to do is take the data and graph it in excel. Perhaps a script that runs the speed test and ands a line in a text file, with " , " as the delimeter, and place it on a USB drive connected to the routerboard. I have SMB sharing on so I can access that share over the network. Makes it easy to access the file.

The reason, I am trying to figure out when the wireless link gets bad. SO I want to run this every half hour and get some metrics as to what the speeds are during what time, and watch if there is any changes. Not a permanent running script, but only when I want to test the links.

Thanks for any help on that.

Re: BandWidth Test for email

Posted: Wed Feb 17, 2016 3:37 pm
by nelsito88
Hi,

I,m trying to run the script on a CCR with 6.34.1v

I can see the speed test running, them the log info: Bandwidth-test done, sending info by e-mail , but not email received at all. The /tool email configuration is ok, with other script we use works fine.

Could you help us?

Many thanks!

Best regards!!!
You can try my code, I just do. It sends information about the Bandwidth test and the name of the Board and the date / time.
Make sure you have set up a outgoing mail server
If you have information to improve the code, comment :D
:local txc
:local txcA
:local txcB
:local txcC

:local rxc
:local rxcA
:local rxcB
:local rxcC

:local rxta
:local rxtaA
:local rxtaB
:local rxtaC

:local txta
:local txtaA
:local txtaB
:local txtaC

:local sysname [/system identity get name]
:local datetime "$[/system clock get date] $[/system clock get time]"

:log info "Bandwidth-test start"

/tool bandwidth-test 1.1.1.2 protocol=udp direction=both duration=30s user=BWT password=BWT do={

:set txcA ($"tx-current" / 1000)
:set txcB ($txcA / 1000 * 1000)
:set txcC ($txcA - $txcB)
:set txcB ($txcB / 1000)
:set txc "$txcB.$txcC"

:set rxcA ($"rx-current" / 1000)
:set rxcB ($rxcA / 1000 * 1000)
:set rxcC ($rxcA - $rxcB)
:set rxcB ($rxcB / 1000)
:set rxc "$rxcB.$rxcC"

:set rxtaA ($"rx-total-average" / 1000)
:set rxtaB ($rxtaA / 1000 * 1000)
:set rxtaC ($rxtaA - $rxtaB)
:set rxtaB ($rxtaB / 1000)
:set rxta "$rxtaB.$rxtaC"

:set txtaA ($"tx-total-average" / 1000)
:set txtaB ($txtaA / 1000 * 1000)
:set txtaC ($txtaA - $txtaB)
:set txtaB ($txtaB / 1000)
:set txta "$txtaB.$txtaC"

}

:log info "Bandwidth-test done, sending info by e-mail"

/tool e-mail send to="your@email.com" subject="Bandwidth-test done : $sysname" body="$sysname \n  $datetime \n \n Result : \n TX speed $txc Mbps/s \n RX speed $rxc Mbps/s \n \n TX total average $txta Mbps/s \n RX total average $rxta Mbps/s"

Re: BandWidth Test for email

Posted: Wed Feb 17, 2016 3:42 pm
by BobcatGuy
Did you edit the line in the script
" /tool e-mail send to="your@email.com" subject="Bandwidth-test done..... "

to have your email address? Its near the bottom

Re: BandWidth Test for email

Posted: Tue Mar 15, 2016 8:42 pm
by plisken
Can be done this bandwidth test separately send and receive. (not both)
CPU load is too high for both measurements simultaneously
Thanks for your reply

You can try my code, I just do. It sends information about the Bandwidth test and the name of the Board and the date / time.
Make sure you have set up a outgoing mail server
If you have information to improve the code, comment :D
:local txc
:local txcA
:local txcB
:local txcC

:local rxc
:local rxcA
:local rxcB
:local rxcC

:local rxta
:local rxtaA
:local rxtaB
:local rxtaC

:local txta
:local txtaA
:local txtaB
:local txtaC

:local sysname [/system identity get name]
:local datetime "$[/system clock get date] $[/system clock get time]"

:log info "Bandwidth-test start"

/tool bandwidth-test 1.1.1.2 protocol=udp direction=both duration=30s user=BWT password=BWT do={

:set txcA ($"tx-current" / 1000)
:set txcB ($txcA / 1000 * 1000)
:set txcC ($txcA - $txcB)
:set txcB ($txcB / 1000)
:set txc "$txcB.$txcC"

:set rxcA ($"rx-current" / 1000)
:set rxcB ($rxcA / 1000 * 1000)
:set rxcC ($rxcA - $rxcB)
:set rxcB ($rxcB / 1000)
:set rxc "$rxcB.$rxcC"

:set rxtaA ($"rx-total-average" / 1000)
:set rxtaB ($rxtaA / 1000 * 1000)
:set rxtaC ($rxtaA - $rxtaB)
:set rxtaB ($rxtaB / 1000)
:set rxta "$rxtaB.$rxtaC"

:set txtaA ($"tx-total-average" / 1000)
:set txtaB ($txtaA / 1000 * 1000)
:set txtaC ($txtaA - $txtaB)
:set txtaB ($txtaB / 1000)
:set txta "$txtaB.$txtaC"

}

:log info "Bandwidth-test done, sending info by e-mail"

/tool e-mail send to="your@email.com" subject="Bandwidth-test done : $sysname" body="$sysname \n  $datetime \n \n Result : \n TX speed $txc Mbps/s \n RX speed $rxc Mbps/s \n \n TX total average $txta Mbps/s \n RX total average $rxta Mbps/s"

Re: BandWidth Test for email

Posted: Wed Feb 13, 2019 4:00 am
by dutq
Make sure the "/tool bandwidth ... do={" is all on one line, and the variables with dashes are quoted. You could do something like this:

ros code

/tool bandwidth-test 192.168.1.1 protocol=udp direction=both duration=12s local-tx-speed=50M remote-tx-speed=50M user=login password=senha do={
  :if ($status="done testing") do={
	:local i ($"tx-current" . "/" . $"rx-current")
	/tool e-mail send to="usuario@gmail.com" subject="Bandwidth test results" body=("Transmitted bytes/s:" . $i)
  }
}
Hi Guys,
I followed the instructions of @skot, It worked but I want ("Transmitted bytes/s:" . $i) to ("Transmitted Mpbs/s:" . $i)
Ex: Transmitted bytes/s:232836416/257019080 = Transmitted Mbps/s:23.2Mbps/25.7Mbps
Can someone please help me?
Thanks so much!!!!

Re: BandWidth Test for email

Posted: Thu Feb 14, 2019 5:59 am
by agenovez
Greetings,

Great work!, but it does not work on 6.43.12, I sent the original code with a small fix on the variables, then you will receive the email with the test results.


Code: Select all

:local txc
:local txcA
:local txcB
:local txcC

:local rxc
:local rxcA
:local rxcB
:local rxcC

:local rxta
:local rxtaA
:local rxtaB
:local rxtaC

:local txta
:local txtaA
:local txtaB
:local txtaC

:local sysname [/system identity get name]
:local datetime "$[/system clock get date] $[/system clock get time]"

:log info "Bandwidth-test start"

/tool bandwidth-test YOURIP protocol=tcp direction=both duration=30s user=YOURUSER password=YOURUSERPASSWORD do={

:set $txcA ($"tx-current" / 1000)
:set $txcB ($txcA / 1000 * 1000)
:set $txcC ($txcA - $txcB)
:set $txcB ($txcB / 1000)
:set $txc "$txcB.$txcC"

:set $rxcA ($"rx-current" / 1000)
:set $rxcB ($rxcA / 1000 * 1000)
:set $rxcC ($rxcA - $rxcB)
:set $rxcB ($rxcB / 1000)
:set $rxc "$rxcB.$rxcC"

:set $rxtaA ($"rx-total-average" / 1000)
:set $rxtaB ($rxtaA / 1000 * 1000)
:set $rxtaC ($rxtaA - $rxtaB)
:set $rxtaB ($rxtaB / 1000)
:set $rxta "$rxtaB.$rxtaC"

:set $txtaA ($"tx-total-average" / 1000)
:set $txtaB ($txtaA / 1000 * 1000)
:set $txtaC ($txtaA - $txtaB)
:set $txtaB ($txtaB / 1000)
:set $txta "$txtaB.$txtaC"

}

:log info "Bandwidth-test done, sending info by e-mail"

/tool e-mail send to="your@email.com" subject="Bandwidth-test done : $sysname" body="$sysname \n $datetime \n \n Result : \n TX speed $txc Mbps/s \n RX speed $rxc Mbps/s \n \n TX total average $txta Mbps/s \n RX total average $rxta Mbps/s"

Re: BandWidth Test for email

Posted: Thu Feb 14, 2019 6:22 am
by dutq
Make sure the "/tool bandwidth ... do={" is all on one line, and the variables with dashes are quoted. You could do something like this:

ros code

/tool bandwidth-test 192.168.1.1 protocol=udp direction=both duration=12s local-tx-speed=50M remote-tx-speed=50M user=login password=senha do={
  :if ($status="done testing") do={
	:local i ($"tx-current" . "/" . $"rx-current")
	/tool e-mail send to="usuario@gmail.com" subject="Bandwidth test results" body=("Transmitted bytes/s:" . $i)
  }
}
I edited post of @skot
/tool bandwidth-test your IP duration=20s direction=both local-udp-tx-size=1000 protocol=udp remote-udp-tx-size=1000 do={
  :if ($status="done testing") do={
	:local i ($"tx-total-average"/1048576 . "  / " . $"rx-total-average"/1048576 )
                :local download ($"tx-total-average"/1048576)
                :local upload ($"rx-total-average"/1048576)
                /tool e-mail send to="your email" subject="Bandwidth Metronet " body=("Download/Upload: " . $download ." Mbps / ".$upload . " Mbps")
  }
}
And this is result,
Download/Upload: 151 Mbps / 146 Mbps
Thanks all

Re: BandWidth Test for email

Posted: Thu Feb 14, 2019 12:05 pm
by Jotne
If you instead of email, send this using syslog, you can then graph every measure using Splunk.
See example in my signature.