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);
}