Page 1 of 1

total download for hotspot users

Posted: Sat Jan 29, 2011 5:37 pm
by namo
I have Mikrotik RouterOS v4,16.
I ise the fallowing code to calculate the total download for the hotspot users, but there is errors:
:local bytesin 0;
:local bytesout 0;
/ip hotspot user {
   :foreach u in=[find] do={
      :set bytesin ($bytesin + [get $u bytes-in]);
      :set bytesout ($bytesout + [get $u bytes-out]);
   }
}
:set bytesin ($bytesin / (1024 * 1024 * 1024));
:set bytesout ($bytesout / (1024 * 1024 * 1024));
:put ("Bytes-In(GB): " . $bytesin);
:put ("Bytes-Out(GB): " . $bytesout);
where is wrong about it

Re: total download for hotspot users

Posted: Sun Jan 30, 2011 12:57 pm
by multipath
Study this link very well:

http://wiki.mikrotik.com/wiki/Manual:Scripting

Don't forget to set the variable "u" to 0 or nothing on script load as "u" is still considered a variable. Also start and stop the script with a { and } encapsulating the script. It will make debugging in the terminal window much easier.

Re: total download for hotspot users

Posted: Mon Jan 31, 2011 1:21 pm
by namo
I change :local to :global and now it is working in the new terminal