Community discussions

MikroTik App
 
obadaabdullah
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 71
Joined: Wed Jan 08, 2014 7:41 pm

reading hotspot users details

Tue Apr 08, 2014 1:17 am

hi all
RB951 V6.7, hotspot ( username & password) i give my users a limit-bytes-total
i want to read my users remain bytes
i try this script but it was wrong

:foreach i in=[/ip hotspot user find] do={
local bi [/ip hotspot user get $i bytes-in]
local bo [/ip hotspot user get $i bytes-out]
local user [ip hotspot user get $i user]
log info "user $user and bi $bi and bi $bo"
}

any help pleas?
and if it is possible can i write this value to a txt file in the rb??
thanks
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2954
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: reading hotspot users details

Tue Apr 08, 2014 3:39 pm

Use right syntax (6.7+):
:foreach tmpI in=[/ip hotspot user find where (limit-bytes-total > 0)] do={
:local tmpName value=[/ip hotspot user get $tmpI value-name=name];
:local tmpLimitTotal value=[/ip hotspot user get $tmpI value-name=limit-bytes-total];
:local tmpIn value=[/ip hotspot user get $tmpI value-name=bytes-in];
:local tmpOut value=[/ip hotspot user get $tmpI value-name=bytes-out];
:local tmpRemaining value=($tmpLimitTotal - ($tmpIn + $tmpOut));
:local tmpMessage value=("User: ".$tmpName.", Limit Total: ".$tmpLimitTotal.", Used In: ".$tmpIn.", Used Out: ".$tmpOut.", Remaining Total:".$tmpRemaining);
:if ([/ip hotspot user get $tmpI value-name=disabled]) do={:set tmpMessage value=("USER DISABLED: ".$tmpMessage);};
:if ($tmpRemaining < 1) do={:set tmpMessage value=("USER OUT OF BYTES: ".$tmpMessage);};
:log info message=$tmpMessage;
}
Is possible to write output to text file, each 100 users, using different file names.
Is not possible to store, on each file, more than 4096 Characters.

If I helped you, please add Karma.
I'm Italian, not English. Sorry for my imperfect grammar.
 
obadaabdullah
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 71
Joined: Wed Jan 08, 2014 7:41 pm

Re: reading hotspot users details

Thu Apr 10, 2014 10:40 am

Use right syntax (6.7+):
:foreach tmpI in=[/ip hotspot user find where (limit-bytes-total > 0)] do={
:local tmpName value=[/ip hotspot user get $tmpI value-name=name];
:local tmpLimitTotal value=[/ip hotspot user get $tmpI value-name=limit-bytes-total];
:local tmpIn value=[/ip hotspot user get $tmpI value-name=bytes-in];
:local tmpOut value=[/ip hotspot user get $tmpI value-name=bytes-out];
:local tmpRemaining value=($tmpLimitTotal - ($tmpIn + $tmpOut));
:local tmpMessage value=("User: ".$tmpName.", Limit Total: ".$tmpLimitTotal.", Used In: ".$tmpIn.", Used Out: ".$tmpOut.", Remaining Total:".$tmpRemaining);
:if ([/ip hotspot user get $tmpI value-name=disabled]) do={:set tmpMessage value=("USER DISABLED: ".$tmpMessage);};
:if ($tmpRemaining < 1) do={:set tmpMessage value=("USER OUT OF BYTES: ".$tmpMessage);};
:log info message=$tmpMessage;
}

Is possible to write output to text file, each 100 users, using different file names.
Is not possible to store, on each file, more than 4096 Characters.

If I helped you, please add Karma.


thanx alot
1- how to wright this txt file? i got only the last user details?
2- i'v asked many times but no answer : can i send any kind of msg (or send txtfile over wifi) to my users when they r online and make it appear on their (mobiles-pc-laptops)
 
obadaabdullah
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 71
Joined: Wed Jan 08, 2014 7:41 pm

Re: reading hotspot users details

Sat Apr 12, 2014 6:34 pm

any new help??

Who is online

Users browsing this forum: SiB and 7 guests