Community discussions

 
wagnernascimento
just joined
Topic Author
Posts: 5
Joined: Thu Dec 19, 2013 5:30 pm

BandWidth Test for email

Thu Feb 27, 2014 1:11 am

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)
 
User avatar
skot
Long time Member
Long time Member
Posts: 586
Joined: Wed Nov 30, 2011 3:05 am

Re: BandWidth Test for email

Thu Feb 27, 2014 6:55 pm

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 don't need any karma... I have Ιησους Χριστος!
 
IHRMax
just joined
Posts: 5
Joined: Thu Feb 27, 2014 6:35 pm

Re: BandWidth Test for email

Thu Feb 27, 2014 9:02 pm

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"
 
wagnernascimento
just joined
Topic Author
Posts: 5
Joined: Thu Dec 19, 2013 5:30 pm

Re: BandWidth Test for email

Fri Feb 28, 2014 1:20 am

thank you

graciously

Wagner Nascimento
 
toboo
just joined
Posts: 2
Joined: Mon Dec 17, 2012 9:38 pm

Re: BandWidth Test for email

Mon Sep 15, 2014 11:21 pm

i have the menssage mikrotik>: invalid FROM adress

someone have the solution?
 
BobcatGuy
Member Candidate
Member Candidate
Posts: 223
Joined: Thu Apr 19, 2007 7:41 am

Re: BandWidth Test for email

Sun Feb 14, 2016 8:33 am

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.
 
nelsito88
just joined
Posts: 8
Joined: Tue Mar 05, 2013 9:11 pm

Re: BandWidth Test for email

Wed Feb 17, 2016 3:37 pm

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"
 
BobcatGuy
Member Candidate
Member Candidate
Posts: 223
Joined: Thu Apr 19, 2007 7:41 am

Re: BandWidth Test for email

Wed Feb 17, 2016 3:42 pm

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
 
plisken
Forum Guru
Forum Guru
Posts: 2362
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: BandWidth Test for email

Tue Mar 15, 2016 8:42 pm

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"
 
dutq
just joined
Posts: 10
Joined: Mon Nov 20, 2017 4:31 pm

Re: BandWidth Test for email

Wed Feb 13, 2019 4:00 am

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!!!!
 
User avatar
agenovez
just joined
Posts: 6
Joined: Thu Jul 21, 2011 5:44 pm
Location: Cuenca - Ecuador
Contact:

Re: BandWidth Test for email

Thu Feb 14, 2019 5:59 am

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"
 
dutq
just joined
Posts: 10
Joined: Mon Nov 20, 2017 4:31 pm

Re: BandWidth Test for email

Thu Feb 14, 2019 6:22 am

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
 
User avatar
Jotne
Forum Veteran
Forum Veteran
Posts: 952
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: BandWidth Test for email

Thu Feb 14, 2019 12:05 pm

If you instead of email, send this using syslog, you can then graph every measure using Splunk.
See example in my signature.
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 3 guests