Community discussions

MikroTik App
 
badza
just joined
Topic Author
Posts: 4
Joined: Mon Jun 22, 2009 1:47 pm

RouterOS HotSpot Status Page Variables

Mon Jun 22, 2009 1:55 pm

Hi,

Does anyone know of a way to have a friendly looking byte count of remaining quota, I can get a verbose count using $(remain-bytes-out), but I'm sure the users will go cross-eyed trying to count the decimal places.

Please assist if possible.

Thanks!
 
User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6703
Joined: Thu Mar 31, 2005 3:33 pm
Location: Riga, Latvia
Contact:

Re: RouterOS HotSpot Status Page Variables

Mon Jun 22, 2009 1:57 pm

There are following variables available,
bytes-in-nice - user-friendly form of number of bytes received from the user ("15423")
bytes-out-nice - user-friendly form of number of bytes sent to the user ("11352")
 
badza
just joined
Topic Author
Posts: 4
Joined: Mon Jun 22, 2009 1:47 pm

Re: RouterOS HotSpot Status Page Variables

Mon Jun 22, 2009 2:00 pm

Hi, thanks for the quick reply,

but is that total bytes sent to the users over all session or particular to individual sessions?
 
User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6703
Joined: Thu Mar 31, 2005 3:33 pm
Location: Riga, Latvia
Contact:

Re: RouterOS HotSpot Status Page Variables

Mon Jun 22, 2009 3:05 pm

I guess it should be total sessions value.
 
badza
just joined
Topic Author
Posts: 4
Joined: Mon Jun 22, 2009 1:47 pm

Re: RouterOS HotSpot Status Page Variables

Mon Jun 22, 2009 5:15 pm

Ok, don't suppose there is a "normal" remaining count, i.e. user x has y left of z.

i.e.

Quota : 100M $(limit-bytes-out) is great but is the actual remainder after a session has closed, not the total assigned quota value
Quota Used : 5M $(bytes-out-nice) about as useful as the previous, session specific
Quota Remaining : 95M $(remain-bytes-out) perfect except it's verbose, would be very nice to have a $(remain-bytes-out-nice) if you get my meaning.

any ideas?
 
badza
just joined
Topic Author
Posts: 4
Joined: Mon Jun 22, 2009 1:47 pm

Re: RouterOS HotSpot Status Page Variables

Tue Jun 23, 2009 10:19 am

I got it !!!!

<script language="JavaScript">

function readablizeBytes(bytes) {
var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
var e = Math.floor(Math.log(bytes)/Math.log(1024));
return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e];
}

</script>

(in your status page table)

<tr><td align="left">Quota Used:</td><td><script language="JavaScript">document.write(readablizeBytes($(bytes-out)));</script></td></tr>

notice hows the variable is encapsulated by the java script, now we have "nice" looking values


:D :D :D
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8716
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: RouterOS HotSpot Status Page Variables

Tue Jun 23, 2009 12:34 pm

also you may want to add <noscript>$(bytes-out) bytes</noscript> section for those rare users who do not have JavaScript enabled =)
 
MICPROF
Member Candidate
Member Candidate
Posts: 106
Joined: Thu Jan 27, 2011 7:22 pm
Contact:

Re: RouterOS HotSpot Status Page Variables

Tue Mar 01, 2011 5:47 am

Hi ,
I got it !!!!

<script language="JavaScript">

function readablizeBytes(bytes) {
var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
var e = Math.floor(Math.log(bytes)/Math.log(1024));
return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e];
}

</script>

(in your status page table)

<tr><td align="left">Quota Used:</td><td><script language="JavaScript">document.write(readablizeBytes($(bytes-out)));</script></td></tr>

notice hows the variable is encapsulated by the java script, now we have "nice" looking values
Thank you for that , but i need remin-bytes-total ,, i write this script and write the ( <tr><td align="left">Quota Used:</td><td><script language="JavaScript">document.write(readablizeBytes($(remain-bytes-total)));</script></td></tr> ) but noy work show me NaN undefine , please help me if possible ASAP ...
 
User avatar
bax
Member Candidate
Member Candidate
Posts: 268
Joined: Mon Dec 20, 2004 8:45 pm
Location: Croatia

Re: RouterOS HotSpot Status Page Variables

Sat Oct 13, 2012 5:46 pm

I got it !!!!

<script language="JavaScript">

function readablizeBytes(bytes) {
var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
var e = Math.floor(Math.log(bytes)/Math.log(1024));
return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e];
}

</script>

(in your status page table)

<tr><td align="left">Quota Used:</td><td><script language="JavaScript">document.write(readablizeBytes($(bytes-out)));</script></td></tr>

notice hows the variable is encapsulated by the java script, now we have "nice" looking values


:D :D :D
Does you have solutin for ROS v 5.xx ?
 
User avatar
bax
Member Candidate
Member Candidate
Posts: 268
Joined: Mon Dec 20, 2004 8:45 pm
Location: Croatia

Re: RouterOS HotSpot Status Page Variables

Tue Feb 11, 2014 6:13 pm

It work under ROS v 6.9 x86...
but im have some strange errors ... It was stop after 18 - 24 hours ...
My temp solution is shedule reboot every day ...
Does anybody have idea why is this hapening ?
I suspect on my hard disk ...
 
olobnet
just joined
Posts: 1
Joined: Thu Jun 14, 2018 7:23 am

Re: RouterOS HotSpot Status Page Variables

Thu Jun 14, 2018 7:27 am

work v5.26 and v6.42
thank you