Page 1 of 1

write into th log bytes in /out on user logout

Posted: Wed Nov 26, 2014 4:15 pm
by MBAGA
I have a hotspot user profile with on login and on logout scripts which write into th log information about user .
is it possible to write also bytes in /out on logout ?

Re: write into th log bytes in /out on user logout

Posted: Wed Nov 26, 2014 6:01 pm
by boen_robot
If you can get those during a logout script (I don't have a hotspot to actually try...), you should be able to then log them by issuing the "/log info" command.

You can try to get the bytes with
:local bytesOut [/ip hotspot active get [find $user] bytes-out];
/log info "User $user had sent $bytesOut bytes during his last session that ended just now.";

Re: write into th log bytes in /out on user logout

Posted: Thu Nov 27, 2014 7:00 am
by MBAGA
Seems that it can't be get on a on logout script . Nothing happen

There are other solution s?

Re: write into th log bytes in /out on user logout

Posted: Thu Nov 27, 2014 5:45 pm
by boen_robot
The only other option I can think of would only give you an estimate, rather than an accurate value:

On login, create a scheduler script that populates a new global variable with the current bytes-out at regular intervals. On logout, write out the global variable, and then remove the scheduler script and variable.

This will only give you an estimate, since you won't get any bytes that have been downloaded between the last scheduler invocation and the logout.

The only way to get a "true" value is if MikroTik modify RouterOS to either keep the "active" entry present during the logout script (and only remove it afterwards) OR if they modify RouterOS to supply the last state of the active entry in a variable.