please help with [simple queue] based traffic counter

Is it possible to send reports via e-mail if user has downloaded(uploaded) certain amount of information? I need to use [/queue simple] counters if possible… I’ve tryed to modify the script based on [/ip firewall rule accounting], but no luck :frowning:
Please help!

My current (not working) script is:

:global tx
:foreach i in [/queue simple find] do={
/queue simple $i once do={
:set tx ($total-bytes/1048576)
:if ($tx > 0) do={
/tool e-mail send
to=xxxxx@xxxxx.com
subject=“data report”
body=("The traffic on " .
[/queue simple get $i name] . " got up to " . $tx . “Mbit”)
}
}
}

add server=xxx.xxx.xxx.xxx

the problem is not in mail server. It is set.

The following script works fine in v 2.9, but in 2.8 the value [total-bytes] is string! And I dont know how to convert it to integer.. Without this it’s impossible to get any calculations :frowning:

:local tx
:foreach i in [/queue simple find] do={
    :set tx ([queue simple get $i total-bytes]/1073741824)
    :if ($tx > 1) do={
          /tool e-mail send \
          to=a@a.com \
          subject="data rate report" \
          body=("The traffic on " . \
          [queue simple get $i name] . " got up to " . $tx . "Gb, in details it is " . \
          [queue simple get $i bytes])
          }
         }
/queue simple reset-counters

Anybody know how to translate the value [total-bytes] in to integer for use in v 2.8.x??

:set tx ([queue simple get $i total-bytes] / 1073741824)

Try this. I hope it will help.

sorry… But this string is equal to mine… In this case we’ll have an error in v 2.8.x (cannot divide string by integer number)

probably the upgrade to the newest 2.8 RouterOS version would help.

Edgars

Yes :slight_smile: Thanks!