Community discussions

MikroTik App
 
khalid engineer
just joined
Topic Author
Posts: 17
Joined: Fri Jul 13, 2007 3:37 pm
Location: Iraq

i need script

Fri Sep 28, 2007 5:34 am

hello all
I need help
i need script makes the user uses the Internet at speeds 40k/100k
but when the total download exceeds 50 megabyte
the speed decrease to 20k/50k
and the script is daily (the counters of total download is clear at 12 am )
best regards
khalid
Last edited by khalid engineer on Fri Sep 28, 2007 2:21 pm, edited 1 time in total.
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Fri Sep 28, 2007 1:30 pm

Assuming you're using User Manager:

:local user
:local bytesin
:local bytesout
:local megstotal
:local user

/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=YOURSUBSCRIBERNAME ] do={

:set user [get $i name]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set megstotal (($bytesin + $bytesout) / 1000000)

:if ([$megstotal] < 50) do={
/tool user-manager user set [/tool user-manager user find user=$i] rate-limit=40k/100k \
:log info "User $user Rate Limit set to 40k/100k" } else={
/tool user-manager user set [/tool user-manager user find user=$i] rate-limit=20k/50k \
:log info "User $user Rate Limit set to 20k/50k }

}

Just wrote that on the fly, haven't tested it out,
so it might have a couple of bugs.
Try that out and see if it works for you.
Take note that I think you have to reset the user's connection for settings like that to take effect. I speak under correction though.

You'll need to make an entry into Scheduler to let it run every 24 hours:
/system scheduler add name=DailyWhatever on-event=YourScriptName start-date=sep/28/2007 start-time=23:59:50 interval=24h

That entry will execute the script 10 seconds before midnight, tonight.

Cheers!
-Krige
 
khalid engineer
just joined
Topic Author
Posts: 17
Joined: Fri Jul 13, 2007 3:37 pm
Location: Iraq

Re: i need script

Fri Sep 28, 2007 9:11 pm

thank u again
there is a problem
i add the script

Image

and when i click on Run script the script is not work


Image
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Sat Sep 29, 2007 11:06 am

I will debug the script through the day and give you one that works by this afternoon.

Check this post again later for a working version.

Thanks!
-Krige
 
khalid engineer
just joined
Topic Author
Posts: 17
Joined: Fri Jul 13, 2007 3:37 pm
Location: Iraq

Re: i need script

Sun Sep 30, 2007 1:31 pm

dear Krige
Thank you for your interest
im waiting you and i tried with the script and it still not work
i need it very much and my mikrotik is 2.9.27
and i waiting u
best regards
khalid
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Sun Sep 30, 2007 8:25 pm

The script works on my machine, running ROS 3.0rc5.

You have not answered my question from the other thread:
Are you using User Manager or PPP/secrets?
The script is written for User Manager.

If you log into your router and run the script manually,
what error message do you get?

-K
 
khalid engineer
just joined
Topic Author
Posts: 17
Joined: Fri Jul 13, 2007 3:37 pm
Location: Iraq

Re: i need script

Sun Sep 30, 2007 9:00 pm


Can you clarify what is more User Manager and PPP / secrets?
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Sun Sep 30, 2007 9:12 pm

User Manager:
http://wiki.mikrotik.com/wiki/MikroTik_User_Manager

While PPP/Secrets are usernames and passwords entered directly into the Mikrotik console, that will work only for that mikrotik box. The PPP/Secrets are checked to do auths before it checks the user manager (or radius) for logins.
 
khalid engineer
just joined
Topic Author
Posts: 17
Joined: Fri Jul 13, 2007 3:37 pm
Location: Iraq

Re: i need script

Sun Sep 30, 2007 9:23 pm

i m using hotspot and winbox to manage the server
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Tue Oct 02, 2007 1:09 am

hello i have a pc running 2.9.46 with usermanger and it dont work for me and would really like to be able to use somthing like that.

thanks
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Tue Oct 02, 2007 9:28 am

I gave you a script illustrating the principles,
and told you that I have not tested it,
or tried debugging it.
Has anyone attempted debugging?

Here's a working version under ROS 3.0rc5:

:local user
:local bytesin
:local bytesout
:local megstotal

/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={

:set user [get $i name]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set megstotal (($bytesin + $bytesout) / 1000000)

:if ([$megstotal] < 50) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=40k/100k
:put $user
:put $megstotal
:put "User Rate Limit set to 40-100"} else={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=20k/50k
:put $user
:put $megstotal
:put "User Rate Limit set to 20-50"}
}

Please make sure you understand what each and every command does before implementing this into your network.

-K
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Tue Oct 02, 2007 9:53 am

hello
thanks for the help but i am still having trouble . i am not sure how to debug it.. i get the different colors when i execute but i am not sure where the problem is.. here is the error that i get and i have tried on v3.0rc5 and also latest stable version..

[admin@MikroTik] > :local user
[admin@MikroTik] > :local bytesin
[admin@MikroTik] > :local bytesout
[admin@MikroTik] > :local megstotal
[admin@MikroTik] >
[admin@MikroTik] > /tool user-manager user
[admin@MikroTik] /tool user-manager user> :foreach i in=[/tool user-manager user
find subscriber=admin] do={
{...
{... :set user [get $i name]
expected variable name (line 3 column 6)
[admin@MikroTik] /tool user-manager user> :set bytesin [get $i download-used]
expected variable name (line 1 column 6)
[admin@MikroTik] /tool user-manager user> :set bytesout [get $i upload-used]
expected variable name (line 1 column 6)
[admin@MikroTik] /tool user-manager user> :set megstotal (($bytesin + $bytesout)
/ 1000000)
expected variable name (line 1 column 6)
[admin@MikroTik] /tool user-manager user>
[admin@MikroTik] /tool user-manager user> :if ([$megstotal] < 50) do={
syntax error (line 1 column 8)
[admin@MikroTik] /tool user-manager user> /tool user-manager user set [/tool use
r-manager user find name=$user] rate-limit=40k/100k
syntax error (line 1 column 65)
[admin@MikroTik] /tool user-manager user> :put $user
syntax error (line 1 column 7)
[admin@MikroTik] /tool user-manager user> :put $megstotal
syntax error (line 1 column 7)
[admin@MikroTik] /tool user-manager user> :put "User Rate Limit set to 40-100"}
else={
User Rate Limit set to 40-100
[admin@MikroTik] /tool user-manager user> /tool user-manager user set [/tool use
r-manager user find name=$user] rate-limit=20k/50k
syntax error (line 1 column 65)
[admin@MikroTik] /tool user-manager user> :put $user
syntax error (line 1 column 7)
[admin@MikroTik] /tool user-manager user> :put $megstotal
syntax error (line 1 column 7)
[admin@MikroTik] /tool user-manager user> :put "User Rate Limit set to 20-50"}
User Rate Limit set to 20-50
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: i need script

Tue Oct 02, 2007 10:00 am

put all your script in { } this will be treated as one script

in your case each line is different scripts and as you can read in 3.0 changelog variables must be declared before use, but if you declare local variable in one script it is not passed to another.:
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Tue Oct 02, 2007 10:18 am

works correctly in 3.0rc5,, havnt figured it out yet in the stable version

thanks...

is there any way that i can make it take a look at the speed that the customer has right now and set the speed to half that and then reset itself at midnight.. as we have several different packages... or say find rate 40/100 and set it to 20/80 if over 20mb and find rate 70/200 and set it to 50/150 if over 40mb ect.


thanks

i am not all that good with scripting but am trying to learn .. i have been setting here for 8 solid hours trying to figure this out..
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: i need script

Tue Oct 02, 2007 10:28 am

to get curretn rate limit
/tool user-manager user get [/tool user-manager user find name=$user] rate-limit
Add scheduler to run every 24 hours starting at midnight that runs reset script.
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Tue Oct 02, 2007 10:32 am

this is how i have it now and it runs perfectly

{
:local user
:local bytesin
:local bytesout
:local megstotal

/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={

:set user [get $i name]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set megstotal (($bytesin + $bytesout) / 1000000)

:if ([$megstotal] < 100) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 128k/256k 256k/384k 64k/128k 30/30 6 16k/32k"
:put $user
:put $megstotal
:put "User Rate Limit set to 128/256"} else={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 64k/64k 128k/128 64k/64k 30/30 8 16k/32k"
:put $user
:put $megstotal
:put "User Rate Limit set to 64k/64k"}
}
}
}


it put the burst and everthing in there..

with the midnight script what exactly will happen??? this script will run and will set bandwith correct?? what i really need to do is check this say every hour and if they have used over the limit it takes them offline so that the new bandwith rule will go into effect and or is there a way to do that dynamiclly and then at midnight reset there bandwith back to what it should be..

thanks a ton

p.s i was thinking and it seems that the total bytes in + out runs as a total and we would really like to keep a record of how much bandwith has been used during the time that $cleint has been a cleint. so how do i figure this out to not count total bandwith just bandwith used on a day to day basis? somthing to do with adding the date ???
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Wed Oct 03, 2007 10:05 pm

Since the original script is mine, I'll be happy to consult on adapting it.

The download-used and upload-used attributes in the /tool/user-manager/user section is the Total downloads since Sign-Up, or since it was last reset. Resetting this does not affect the counters you will see in User Manager web interface's reports generator.

The long-term records are kept in /tool/user-manager/log.
In other words, you'll still have a record of your user's usage since he/she signed up, even after you've run the Reset-Counters command.

So tell me exactly what you need, and let's take it from there.

-Krige
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Thu Oct 04, 2007 2:28 am

thanks very much for your help.. what i do not understand is the reset part of the script or is that a totally differnt script? also i would like to figure out how to make the script to look for $user under ip hotspot active user and log them off if they have used more bandwith than the set limit .. as from what i uderstand just changing the settings in usermanager does not have any effect until the user logs off and back on.. once i figure out how to do this i plan to implement it on a 4 hour basis to set users bandwith... another cool idea would be for it to check the group id of user in usermanager and if it is say A it applies but if not it has no effect.. that way i can set varios differnt plans with group id and it would be very useful...


thanks in advance..
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Thu Oct 04, 2007 7:56 am

The resetting can be implemented in the same script.

As for changes in user manager having no effect until you reconnect - That's correct.
I'm sure it is possible to disconnect a user under ip-hotspot, much the same you can terminate a PPPoE connection by killing it in /interface/pppoe-server/

I will look into it after I get some sleep. Just got back from an all-nighter work session and the sun is already out. Oy.
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Fri Oct 05, 2007 3:24 am

but how do i make it reset the counters i cant seem to figure that one out..

thanks
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Fri Oct 05, 2007 9:32 am

Hey

Sorry I haven't gotten to the script yet, have some time today to look at it.
But to answer your question, here's a line out of a script that I wrote that automatically sends out a bill via E-mail to all my clients at the end of the month:

/tool user-manager user reset-counters X

Where X is the index number to reset.

You can put it in a loop:
Note that "subscriber name" is NOT your USER name, but the name of the 'customer' (or you) who administrates users, or to wom a user "belongs".

:foreach i in=[/tool user-manager user find subscriber=YOURSUBSCRIBERNAME ] do={
/tool user-manager user reset-counters $i }

That will run through all your user that is subscribed to that UM-customer's services.

In the script that I wrote, it pulls some user data, calculates total usage.
If they're on a Usage-Based package, it calculates how much the throughput-used costs, and adds the base charge, or if the user has a set cap, it determines which package he is using and how much that costs a month, puts all of that down in an E-mail, along with banking details etc, and sends it to the user. It also drops a copy that contains only the absolutely necessary information into an Accounts@MyWISP.com address.

Let me know if you want it.
Also welcome to chat to me on MSN if you need help. You can find my address in my forum user profile.

Cheers!
-Krige
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Sat Oct 06, 2007 1:46 am

ok we are making progress .. i figured out how to reset only the users data that is getting changed to a lower rate during the scipting proces and i will make another one that will reset everybodys usage once a day.. i tried to also make them log out but i was not able to do that ,, below is what i have wrote. the problem that i found is that on beta the /ip hotspot active print shows a number and the user name but to do remove you have to put in the number not the username so i need to figure out how to make the mikrotik associate that number with that user.

{
:local user
:local bytesin
:local bytesout
:local megstotal

/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={

:set user [get $i name]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set megstotal (($bytesin + $bytesout) / 1000000)

:if ([$megstotal] < 20) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 100k/100k 150k/180k 64k/64k 30/30 6 16k/32k"
/ip hotspot active remove [/tool user-manager user find name=$user]
:put $user
:put $megstotal
:put "User Rate Limit set to 128/256"} else={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 50k/50k 150k/180k 64k/64k 30/30 8 16k/32k"
/tool user-manager user reset-counters [/tool user-manager user find name=$user]
:put $user
:put $megstotal
:put "User Rate Limit set to 64k/64k"}
}
}


p.s. would love to look at that script that you say you have.. my email is mps01k at yahoo.com i am in honduras so i am not sure when you would be on IM my time.
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Sat Oct 06, 2007 5:04 am

i have tried and tried to get somthing to make the users log out but it just isnt hapening ,,

below are some of the things i have tried

ip hotspot active remove 0
/ip hotspot active remove 1
/ip hotspot active remove 2
/ip hotspot active remove 3
/ip hotspot active remove 4
/ip hotspot active remove 5
/ip hotspot active remove 6
/ip hotspot active remove 7
/ip hotspot active remove 8
/ip hotspot active remove 9
/ip hotspot active remove 10
/ip hotspot active remove 11
/ip hotspot active remove 12
/ip hotspot active remove 13
/ip hotspot active remove 14
/ip hotspot active remove 15
/ip hotspot active remove 16
/ip hotspot active remove 17
/

above works in terminal but in script says its invalid

{
:local user
:local address

/ip hotspot active
:foreach i in=[/ip hotspot active] do={

:set user [get $i name]
:set address [get $i address]

/ip hotspot active remove $user
:log info $user
:log info $address
:log info "user logged off"
}

cant find the i in active.

{
:local i 10; :do {:put $i; :set i ($i - 1);} \
\ while (($i < 11) && ($i > 0))
{
/ip hotspot active remove $i
}
:set i
}

this one logs off one user not all of them.


i have spent too much time setting in this chair ,, i better go buy groceries before my wife throws me out.. cheers

michael

p.s. i ended up disabling the hotspot interface and enabling with a script 30 seconds after bandwith change.. but i dont like that as we use nat 1:1 with bypass for certain clients on different ip than the router and as soon as it disables hotspot interface they drop connection for a second.
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Sat Oct 06, 2007 6:00 am

i found a bug in the below script and a way to fix it but maybe there is a different way
. if the total bandwith used is =0 then it sets them to the restricted bandwith.

:local bytesin
:local bytesout
:local megstotal

/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={

:set user [get $i name]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set megstotal (($bytesin + $bytesout) / 1000000)

:if ([$megstotal] < 20) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 128k/512k 140k/1024k 64k/64k 30/30 5 16k/32k"
:log info $user
:log info $megstotal
:log info "User Rate Limit set to 128k/512k"} else={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 64k/128k 140k/1024k 64k/64k 30/30 8 16k/32k"
/tool user-manager user reset-counters [/tool user-manager user find name=$user]
:log info $user
:log info $megstotal
:log info "User Rate Limit set to 64k/512k and bandwith total reset to 0 MB THEY USED MORE THAN 20MB IN THE LAST 4 HOURS"}
}
}




FIXED VERSION

:local bytesin
:local bytesout
:local megstotal

/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={

:set user [get $i name]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set megstotal (($bytesin + 1 + $bytesout) / 1000000)

:if ([$megstotal] < 21) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 128k/512k 140k/1024k 64k/64k 30/30 5 16k/32k"
:log info $user
:log info $megstotal
:log info "User Rate Limit set to 128k/512k"} else={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 64k/128k 140k/1024k 64k/64k 30/30 8 16k/32k"
/tool user-manager user reset-counters [/tool user-manager user find name=$user]
:log info $user
:log info $megstotal
:log info "User Rate Limit set to 64k/512k and bandwith total reset to 0 MB THEY USED MORE THAN 20MB IN THE LAST 4 HOURS"}
}
}
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Tue Oct 09, 2007 1:25 am

hello ,

thanks for all the help.

below is my latest config and works with ABC profiles and sets bandwith acordingly. might be somthing for the WIKI!!!!!!!!!

it is testing and working on a operational system with cleints running right now.. i have it run every 4 hours.. i really never understood script very well . but thanks to the help i have recieved i now understand it to some degree, just like when i first started learning spanish 6 years ago. LOL


{
:local user
:local bytesin
:local bytesout
:local megstotal
:local groupname

/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={

:set user [get $i name]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set megstotal (($bytesin + 1 + $bytesout) / 1000000)
:set groupname [get $i group-name]

:if (([$megstotal] < 21) && ([$groupname]=A)) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 64k/128k 128k/256k 32k/64k 30/30 6 16k/32k"
:log info $user
:log info $groupname
:log info "Total MB Used=$megstotal"
:log info "User Rate Limit set to 64k/128k with burst up to 128k/256k with average 32k/64k priority 6"}

:if (([$megstotal] > 21) && ([$groupname]=A)) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 32k/64k 128k/256k 32k/64k 30/30 6 16k/32k"
/tool user-manager user reset-counters [/tool user-manager user find name=$user]
:log info $user
:log info $groupname
:log info "Total MB Used=$megstotal"
:log info "User Rate Limit set to 32k/64k with burst up to 128k/256k with average 32k/64k priority 8 and bandwith total reset to 0 MB"}

:if (([$megstotal] < 41) && ([$groupname]=B)) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 128k/256k 256k/512k 64k/128k 30/30 5 16k/32k"
:log info $user
:log info $groupname
:log info "Total MB Used=$megstotal"
:log info "User Rate Limit set to 128/256 with burst up to 256k/512k with average 64/128k prority 5"}

:if (([$megstotal] > 41) && ([$groupname]=B)) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 64k/128k 150k/512k 64k/128k 30/30 7 16k/32k"
/tool user-manager user reset-counters [/tool user-manager user find name=$user]
:log info $user
:log info $groupname
:log info "Total MB Used=$megstotal"
:log info "User Rate Limit set to 64k/128k with burst up to 150k/512k with average 64k/128k priority 7 and bandwith total reset to 0 MB"}

:if (([$megstotal] < 81) && ([$groupname]=C)) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 256k/512k 280k/1024k 128k/256k 30/30 4 64k/128k"
:log info $user
:log info $groupname
:log info "Total MB Used=$megstotal"
:log info "User Rate Limit set to 256k/512k with burst up to 280k/1MB with average 128k/256k priority 4"}


:if (([$megstotal] > 81) && ([$groupname]=C)) do={
/tool user-manager user set [/tool user-manager user find name=$user] rate-limit=" 128k/256k 256k/1024k 100k/128k 30/30 6 16k/32k"
/tool user-manager user reset-counters [/tool user-manager user find name=$user]
:log info $user
:log info $groupname
:log info "Total MB Used=$megstotal"
:log info "User Rate Limit set to 128kk/256k with burst to 256k/1MB with average 100k/128k priority 6 and bandwith total reset to 0 MB"}


}
}
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Wed Oct 10, 2007 10:30 am

i have tried and tried to get somthing to make the users log out but it just isnt hapening ,,

below are some of the things i have tried

ip hotspot active remove 0
...
/ip hotspot active remove 17
I've had the exact same problem with Radius entgries.
Here's my solution:

You've got your Foreach loop, and you've got your variable
that pulls Username as $user, right - Just make sure that it pulls it correctly - Debug it with a ":put $user" command straight after the "get" command, so that you can see the users being assigned to the variable on screen when you run it. But anyway.

Instead of just Remove $i, go for this:

/ip hotspot active remove [/ip hotspot active find user=$user]

You have to "print" the list first before the entries get a numerical index value assigned to them, so to tell "Remove This Number" won't work unless you Print. But Printing from script doesn't seem to work. The part between brackets searches for the numerical index value specifically, so you force the router to return one, and then you can proceed to remove it.

Hope that helps!
Glad you found my script helpful.

-Krige
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Tue Oct 23, 2007 10:32 pm

hello again friend,

i am still trying to get it to log off active users. I made the mod that you sujest and i dont get any errors but it also does not log user off

{
:local user
:local address
:local uptime

/ip hotspot active
:foreach i in=[/ip hotspot active] do={

:set user [get $i name]
:set address [get $i address]
:set uptime [get $i uptime]

:if ([$user]=luis) do={

/ip hotspot active remove [/ip hotspot active find user=$user]
:log info $user
:log info $address
:log info $uptime
:log info "user logged off"
}
}
}
 
User avatar
skillful
Trainer
Trainer
Posts: 552
Joined: Wed Sep 06, 2006 1:42 pm
Location: Abuja, Nigeria
Contact:

Re: i need script

Tue Oct 23, 2007 10:50 pm

mps01k,

Replace this line in your script
/ip hotspot active remove [/ip hotspot active find user=$user]
with
/ip hotspot active remove [find user=[/ip hotspot user get $i name]]
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: i need script

Wed Oct 24, 2007 4:23 am

hello , runs without problem but still same issue , nothing happens, if it would just say what the error was it would be easier to figure out, but ir runs like a charm , just does nothing.

thanks
 
User avatar
krigevr
Member Candidate
Member Candidate
Posts: 155
Joined: Mon Aug 20, 2007 7:02 pm
Location: South Africa

Re: i need script

Wed Oct 24, 2007 10:51 am

Put in some :put commands everywhere -
Each time you assign a value to a variable - :put it.
That way you can see what gets assigned, and what does not.

And begin debugging from there.
 
leb23m
newbie
Posts: 29
Joined: Sat Jun 10, 2006 3:18 pm

Re: i need script

Sat Nov 10, 2007 10:13 pm

is there a script for the same AIM, making a limitation of speed at 50 Mb , and than give another speed for example 40k/100k at 1st 50 meg, and when it done, it give speed : 24k/46k...
Am using Static Ip ( ARP )

any replies plz?

Who is online

Users browsing this forum: No registered users and 6 guests