Community discussions

MikroTik App
 
randyloveless
Member Candidate
Member Candidate
Topic Author
Posts: 207
Joined: Thu Sep 30, 2004 10:14 am
Location: california
Contact:

record traffic script not working

Sat May 07, 2005 10:29 am

cannot seem to get this script to work wont run . what is wrong with it ( what did i do incorrectly)

:global tmp :global tx :global rx :foreach i in [/interface find] do={/interface monitor-traffic $i once do={:set tx ($sent-bits-per-second/1048576):set rx ($received-bits-per-second/1048576):if ([/system scheduler get record run-count]=1) do={:global ttx :set ttx $tx :global trx :set trx $rx}:if ($tx>$ttx) do={/tool e-mail send to=example@example.com subject="Script message" body=("The transmission traffic on " .[/interface get $i name] . " got up to " . $tx . "Mbps"):set ttx $tx}:if ($rx>$trx) do={/tool e-mail send to=example@example.com subject="Script message" body=("The receiving traffic on " . [/interface get $i name] . " got up to " . $rx . "Mbps"):set trx $rx}}}

Randy
 
User avatar
Eugene
Forum Veteran
Forum Veteran
Posts: 986
Joined: Mon May 31, 2004 5:06 pm
Location: Cranfield, UK

Mon May 09, 2005 10:43 am

body=("The transmission traffic on " .[/interface get $i
missed space before [/interface get $i...]
 
randyloveless
Member Candidate
Member Candidate
Topic Author
Posts: 207
Joined: Thu Sep 30, 2004 10:14 am
Location: california
Contact:

Mon May 09, 2005 12:05 pm

thanks fixed the script

is there a way to watch the script to see each step works or doesnt?
 
edzix
Member
Member
Posts: 333
Joined: Thu Jul 01, 2004 3:01 pm
Location: Latvia

Mon May 09, 2005 2:02 pm

you can use ':log' command after each step. In the '/log' then see whether every :log is executed correctly.

Edgars
 
randyloveless
Member Candidate
Member Candidate
Topic Author
Posts: 207
Joined: Thu Sep 30, 2004 10:14 am
Location: california
Contact:

Tue May 10, 2005 2:37 am

do i put the :log after each command?

Randy
 
randyloveless
Member Candidate
Member Candidate
Topic Author
Posts: 207
Joined: Thu Sep 30, 2004 10:14 am
Location: california
Contact:

Tue May 10, 2005 2:41 am

do i put the :log after each command?

Randy
 
User avatar
Eugene
Forum Veteran
Forum Veteran
Posts: 986
Joined: Mon May 31, 2004 5:06 pm
Location: Cranfield, UK

Tue May 10, 2005 10:30 am

The best way would be regression testing :)
----------------------------------------------------------

Start with the general statement like:
:foreach i in [/interface find] do={:put $i}
Then add some more complexity:
:foreach i in [/interface find] do={/interface monitor-traffic $i once do={:put $i; :environment print;}}
Fix the code before doing something else:
:foreach i in [/interface find running=yes] do={/interface monitor-traffic $i once do={:put $i; :environment print;}}

Hint: you can run the script direcly from the console, without creating /system script entry. Just copy-paste the code to the console

Test individual pieces of code separately.
 
randyloveless
Member Candidate
Member Candidate
Topic Author
Posts: 207
Joined: Thu Sep 30, 2004 10:14 am
Location: california
Contact:

Tue May 10, 2005 11:56 am

thanks for the info . will play with this in the morning

Randy
 
OrCAD
Member Candidate
Member Candidate
Posts: 133
Joined: Wed Apr 20, 2005 12:37 pm

Wed May 11, 2005 12:51 am

This script send to log source address and destination address?
For each lan port or wireless?

10x.
OrCAD