/ip hotspot active print count-only
:global counter;
:set counter ($counter+1);
:log warning "numbers of users so far is $counter";
global systemTime [/system clock get time];
global systemDate [/system clock get date];
:global hotusers "The time is - $systemDate $systemTime
Numbers of hot spot users so far-$counter";
/file set [/file find name=hotusers.txt] contents=$hotusers;
:global counter;
:set counter ($counter + 1);
:log info "number of logged users: $counter";
Yes, this script works from hotspot 'on-login' and counts every new-connected user.and you tried it in the hotspot- loggin script?
You are right, but David1234 asked for this.What your script does is it counts total logins .. not logged in users at the time.
:global counter;
:set counter ($counter+1);
:log warning "numbers of users so far is $counter";
global systemTime [/system clock get time];
global systemDate [/system clock get date];
:global hotusers "The time is - $systemDate $systemTime
Numbers of hot spot users so far-$counter";
/file set [/file find name=hotusers.txt] contents=$hotusers;
/ip hotspot profile
set [ find default=yes ] login-by=http-pap
add dns-name=Free-Wifi hotspot-address=172.20.164.254 login-by=http-pap \
name=hsprof1
/ip hotspot
add address-pool=hs-pool-1 disabled=no interface=wlan1 name=hotspot1 profile=\
hsprof1
/ip hotspot user profile
set [ find default=yes ] address-pool=hs-pool-1 idle-timeout=5m \
keepalive-timeout=2m on-login=":global counter;\r\
\n:set counter (\$counter + 1);\r\
\n:log warning \"number of logged users: \$counter\";" session-timeout=1d \
shared-users=60
/ip hotspot user
add name=admin password=1234
add name=david
<html><head><title>Free WIFI</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=320" /><script type="text/javascript">window.addEventListener('load', function() { setTimeout(scrollTo, 0, 0, 1); }, false);</script>
<body leftmargin="0" topmargin="0" marginwidth="0"><center><form name="login" action="http:login" method="post"><input type="hidden" name="dst" value="http://www.google.com" /><input type="hidden" name="popup" value="true" />
<INPUT CLASS="button" TYPE="image" src="img/top1.gif"/><center><a href="disclaimer.htm"><img src="img/but1.gif"></a></center><input type="hidden" style="width: 80px" name="username" type="text" value="david"/>
</form></center>
/ip hotspot user profile
add idle-timeout=5m keepalive-timeout=2m name=standard on-login=HSU_Count shared-users=200 status-autorefresh=1m transparent-proxy=no
/system script
add name=HSU_Count policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api source=":global counter;\r\
\n:set counter (\$counter + 1);\r\
\n:log info \"number of HS logins: \$counter\";"
number of HS logins: 1
what else may be wrong?number of HS logins: 1
:log info "New HotSpot user connected."
:global counter;
:set counter ($counter + 1);
:log info "number of logged users: $counter";
:set counter ($counter + 1);
:log info "number of logged users: $counter";
:set counter ($counter + 1);
:log info "number of logged users: $counter";
number of logged users: 4
:global counter;
:set counter ($counter + 1);
:log info "number of HS logins: $counter";
If variable is defined as 'global', shoud be visible in 'Enviroment' tab.
Maybe you missed something in your script (colons, semicolons, etc.), and your 'counter' is not global.
Check your script or copy-paste my working script and try again:HTH,Code: Select all:global counter; :set counter ($counter + 1); :log info "number of HS logins: $counter";
can any help to put this in html login page ?????No need for counter, etc.Code: Select all/ip hotspot active print count-only
:local numUsers 0;
:local time;
:set time [/system clock get time];
:foreach user in=[/ip hotspot active find] do={:set numUsers ($numUsers + 1)};
:log info "Number of users logged in at $time is $numUsers";
}
/system script
add name=hotspotcounter policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
source=":global counter\r\
\n:set counter (\$counter + 1)\r\
\n:log info \"number of HS logins: \$counter\""
/ip hotspot user profile
add address-pool=hs-pool idle-timeout=none keepalive-timeout=10m name=\
"1024k 4096k burst" on-login=hotspotcounter rate-limit=\
"256k/1024k 512k/4096k 230k/900k 128/128 8 30k/75k" shared-users=1000 \
status-autorefresh=1m transparent-proxy=no