Community discussions

 
afbonillac
just joined
Topic Author
Posts: 1
Joined: Wed Mar 21, 2018 3:48 pm

Bandwidth test daily

Wed Mar 21, 2018 5:14 pm

Hi friends,

I need create a script that satures the channel "Bandwith test" daily for 1 minute and this result save in a plane file during 1 mounth, and this file send to mail the last day of month,

I create a schelude with this script "/tool bandwidth-test address=207.32.195.2 user=btest password=btest duration=60 file=resultado" but generate this file with this information
"# mar/21/2018 10: 7: 7 by RouterOS 6.40.4
# software id = 9DKZ-R6YT
#
status: connecting
duration: 0s
rx-current: 0bps
rx-10-second-average: 0bps
rx-total-average: 0bps
lost-packets: 0
random-data: no
direction: receive
rx-size: 1500
"

Thanks.
 
punkaker
just joined
Posts: 13
Joined: Thu Apr 12, 2018 7:26 pm

Re: Bandwidth test daily

Thu Sep 06, 2018 4:21 pm

Hi! I am interested exactly in the same, to make some kind of script to schedule a Bandwith Test at night and save results in a text file to compare the available speed of a connection. Did you have any progress with this issue?
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 217
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Bandwidth test daily

Thu Sep 06, 2018 8:12 pm

first temp script
modify it as you need
:do {/tool

:local avrTX 0;
:local avrRX 0;
:local luser "";
:local lpass "";
:local Addr  "";

 bandwidth-test duration=60s user=$luser password=$lpass protocol=tcp address=$Addr direction=both do={
 :if ($status="done testing") do={
 :set $avrTX ("tx-total-average: " . ($"tx-total-average" / 1048576) . "." . ($"tx-total-average" % (1048576) / 1024) . " Mbps" );
 :set $avrRX ("rx-total-average: " . ($"rx-total-average" / 1048576) . "." . ($"rx-total-average" % (1048576) / 1024) . " Mbps" );
 }
}
:log info message=$avrTX;
:log info message=$avrRX;
} on-error={:log error message="script failed"}
 
punkaker
just joined
Posts: 13
Joined: Thu Apr 12, 2018 7:26 pm

Re: Bandwidth test daily

Fri Sep 21, 2018 11:03 am

Hi Adahi! Thanks for your reply.

I have tested your script, and apparently the bandwith test is running correctly (I see the traffic in the interface) but in the log, the displayed values are "0" and "0". Do you know what can be wrong?

Thanks in advance!
You do not have the required permissions to view the files attached to this post.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 217
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Bandwidth test daily

Fri Sep 21, 2018 11:25 am

it was working on bugfix versions
modify script required for stable versions
You do not have the required permissions to view the files attached to this post.
 
punkaker
just joined
Posts: 13
Joined: Thu Apr 12, 2018 7:26 pm

Re: Bandwidth test daily

Fri Sep 21, 2018 11:40 am

Dear Adahe,

Thanks, it seems that it did not work the first time but the next ones is working properly! :)

I think that I will modify it to divide into 2 parts so the test is performed separately in TX and RX (don´t like the "both" results), and so the results are recorded into a text file and stored in the Mikrotik.

Thanks for your help!!
You do not have the required permissions to view the files attached to this post.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 217
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Bandwidth test daily

Fri Sep 21, 2018 11:50 am

you welcome :D
 
punkaker
just joined
Posts: 13
Joined: Thu Apr 12, 2018 7:26 pm

Re: Bandwidth test daily

Fri Sep 21, 2018 3:27 pm

I have modified the script from Adahi so it stores the results in a text file, so the script can be scheduled daily to analyze the BW-test result on different days. I have added comments too. I share with the community, just in case! :)
:log info "------------ BW-TEST Starts--------------";

:local luser "BW Test Server USER";
:local lpass "BW TEST Server PASSWORD";
:local Addr  "BW TEST Server IP ADDRESS";

:local avrRX 0;
:local avrTX 0;


# DOWNLOAD TEST
:log info "----> Measuring RX (30 seg)........";
:do {/tool
   bandwidth-test duration=30s user=$luser password=$lpass protocol=tcp address=$Addr direction=receive do={
     :set $avrRX ("rx-total-average: " . ($"rx-total-average" / 1048576) . "." . ($"rx-total-average" % (1048576) / 1024) . " Mbps" );
   }
} on-error={:log error message="RX script failed"}

:delay 2s;

# UPLOAD TEST
:log info "----> Measuring TX (30 seg) ........";
:do {/tool
  bandwidth-test duration=30s user=$luser password=$lpass protocol=tcp address=$Addr direction=transmit do={
     :set $avrTX ("tx-total-average: " . ($"tx-total-average" / 1048576) . "." . ($"tx-total-average" % (1048576) / 1024) . " Mbps" );
  }
} on-error={:log error message="TX script failed"}

:log info message=$avrRX;
:log info message=$avrTX;
:log info "-------- End of  BW-TEST------------";


################# SAVING RESULTS WITH DATE ######################
:local filename2 "LOG_BW_TEST.txt"
:local ds [/system clock get date];
:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
:local month [ :pick $ds 0 3 ];
:local mm ([ :find $months $month -1 ] + 1);
:if ($mm < 10) do={ :set mm ("0" . $mm); };
:set ds ([:pick $ds 7 11] . $mm . [:pick $ds 4 6]);

:if  ( [:len [/file find name=$filename2]] = 0) do={
:log info "Log file does not exist. Creating a new one.....";
/file print file=$filename2 where name="";
}

:log info "Adding result to the end of the lof file......";
/file set $filename2 contents=([get $filename2 contents]  ."\n".$ds."-->" . $avrRX);
/file set $filename2 contents=([get $filename2 contents] ."    ". $avrTX);
}


 
jo2jo
Forum Veteran
Forum Veteran
Posts: 958
Joined: Fri May 26, 2006 1:25 am

Re: Bandwidth test daily

Mon Nov 26, 2018 12:52 am

cool, see this thread too, at the bottom i made a tiny modification to make it so repeated/scheduled BW test results can be pulled via SNMP (ie so they can be graphed over time).
viewtopic.php?f=9&t=129513&p=699739
:beep :beep :beep
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1310
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Bandwidth test daily

Mon Nov 26, 2018 8:23 am

I did send it over syslog to graph it. This way I do not need to tell the management tool (Splunk) to collect it and what mib to use.
Same script added to all routers, no need to tell one and one that I should collect anything.
Se graphs here: viewtopic.php?t=137338
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 15 guests