I use usermanager for billing PPTP VPN clients.
In Usermanager i have 2 profiles one with Total data Usage of 2GB limitation and the other profile named exhausted which has no limitation but address list.
The address list in th exhausted profile has a redirection rules to an external page to alert users that they are out of data.
In usermanager I assign both profiles to a user but activates the first profile with the 2GB limitation.
After the PPTP user logs in and finishes his 2GB the exhausted profile is automatically activated with no address list entry added, untill they log off and logs back in.
To work around this, I created a script to;
- Check all users in usermanager with the profile exhausted
- Check if they are online, Grab their IP and add it to the address list for redirection.
For some reason this is failing, can anyone help me out, with a script or watch through my script. Thanks
List name
:local LISTNAME “exhaustedd”
:global uname
:foreach uname in=[/tool user-manager user find ] do={
:local uname2 [/tool user-manager user get $uname name]
Check USERMANAGER entries and collect matching names
:foreach u in=[/tool user-manager find where (name~“$uname2”) && (actual-profile~“exhausted”)] do={
Get IP Address from the Users in the exhausted and hold it in temporary buffer
:foreach pppuser in=[/ppp active find ] do={
:local Buffer [/ppp active get $pppuser address ]
:local name [/ppp active get $pppuser name]
:local uname3 [/ppp active get $u name]
:if ([$uname2=$uname3]) do={
Check if entry is already not exists, then OK, otherwise ignore duplication
:if ( [/ip firewall address-list find where address=$Buffer] = “”) do={
Print name in LOG window
:log info (“added entry: $uname3 $Buffer”);
Add IP addresses and there names to the address list
/ip firewall address-list add address=$Buffer list=$LISTNAME
}
}
}
}
}