Community discussions

MikroTik App
 
MBAGA
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 53
Joined: Fri Oct 03, 2014 1:07 pm

write into th log bytes in /out on user logout

Wed Nov 26, 2014 4:15 pm

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 ?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

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

Wed Nov 26, 2014 6:01 pm

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.";
 
MBAGA
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 53
Joined: Fri Oct 03, 2014 1:07 pm

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

Thu Nov 27, 2014 7:00 am

Seems that it can't be get on a on logout script . Nothing happen

There are other solution s?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

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

Thu Nov 27, 2014 5:45 pm

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.