Notify 'Active' in hotspot

Hi guys,

I would like to configure my routers to request every 5 minutes one specific URL sending how many active users are in the hotspot as parameter in the URL, is it possible?
The URL will be something like this: http://www.domain.com/?routerID=123&active=XXX where ‘XXX’ should be replaced by the amount of users active in that moment.
I’m not sure how to get that value in the script and also how to set the automatic request every 5 minutes…
Can you help me??
Thanks!!! :slight_smile:

You can get the count into a variable with

:local activeCount [/ip hotspot active print count-only as-value];

and use it from then onwards as part of the “/tool fetch” URL.

To make this occur every 5 minutes, you’d need to create a scheduler script in “/system scheduler”.

e.g.

/system scheduler add name=HOTSPOT_ACTIVE_NOTIFIER interval=5m on-event={
/tool fetch url=("http://www.domain.com/\?routerID=123&active=" . [/ip hotspot active print count-only as-value]);
}

However…

Wouldn’t it be better if you let the other end keep track of the count itself at all times? Just make an on-login script that will send a request to notify about the login, and an on-logout script that will send another request that notifies about the logout.

Hi boen_robot,

Thanks for the help, I will use it right away!!
I prefer to count the active users on the router side because I don’t want to create hundreds of thousands of requests to track this…

I have a problem using the command ‘fetch’ because is downloading the response, is it possible to make a request from the router to some URL without downloading the content of the response as a local file?
Thanks!!

Sorry, I missed the property ‘keep-result’ from the documentation… problem solved! :slight_smile: