Community discussions

MUM Europe 2020
 
User avatar
airstream
Member Candidate
Member Candidate
Topic Author
Posts: 188
Joined: Fri Feb 03, 2006 6:33 am
Location: New Zealand

Usermanager Fields Script values

Mon Mar 31, 2008 2:21 am

Hi all,

I have been working with the billing scripts as found on the wiki with huge success. I am now writing a script to handle on the fly alteration of the "rate-limit" field in UM.

Is there any way to pull UM data regarding throttles in its individual form? like "rate-limit-TX" "rate-limit-RX" etc?

As I currently see it the field in the UM database that holds this data is rate-limit=" 128k/270k 0/0 0/0 0/0 7". The first "128k/270k" are the current values for the RX TX in the given user seems easy enough to break this information from that field into variables like
 :foreach i in=[/tool user-manager user find subscriber=admin] do={ 
 
 :set foo [get $i rate-limit]
:set bar [:pick $foo 1 8]......}
and manipulate the foo and bar variable in script then write them to the same field. But... if the customer has "512k/1024k" then the above script will fail because the end of the requested value is outside the last character integer (in bar 1 - 8 ).

Any help would be greatly appreciated.
Keep tryin' its bound to work!!
-----
-----
ROOT@COSMOS> Reality.sys corrupted -- Reboot Universe (Y/N)?
>_
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: Usermanager Fields Script values

Mon Mar 31, 2008 6:44 am

here is a script that i wrote to use with usermanager and it runs on V 3.6 and below to set bandwith speeds , apart from this script you need a couple more to make it work, but you will get the idea. you need to set the comment to bandwith used total to began with. you also need to do that every time interval that you want to reset the amount of MB given. you also need a script to take the fappped users back to normal speeds. say if FGHIJ set to ABCCC. if you want them i can email them to you or something

{
:local userX
:local bytesin
:local bytesout
:local megstotal
:local groupnameA
:local usera
:local userb
:local userc
:local commentMB
:local fapstatus
:local fapstatus1
:local nameA
:local bytesinA
:local bytesoutA
:local megstotalA
:local ID
:local macaddres
:local ipaddres
:local uptimeA
/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={
:set userX [get $i name]
:set bytesin [get $i download-used]
:set fapstatus1 [get $i comment]
:set bytesout [get $i upload-used]
:if ([$bytesin]!= "") do={
:set megstotal ($bytesout/1048576+$bytesin/1048576)
:set groupnameA [get $i group-name]
:set commentMB [get $i comment]
:set fapstatus ($megstotal-$commentMB)
:if ([$groupnameA]="A") do={
:set userb $userX
:if ([$fapstatus]<100) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 32k/32k 256k/256k 64k/64k 60/60 5 32k/32k"
:log info "total Mb Used=$fapstatus $userX $groupnameA OK"
:log info " "
}
:if ([$fapstatus]>100) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 16k/16k 256k/256k 32k/32k 60/60 6 16k/16k" group-name="F"
:log info "Total MB Used=$fapstatus $userX $groupnameA FAPPED"
:log info " "
:set fapstatus1 $userX
/ip hotspot active
:foreach i in=[/ip hotspot active find] do={
:set nameA $userX
:set macaddres [get $i mac-address]
:put $macaddres
:set ipaddres [get $i address]
:if ([$nameA]=[$fapstatus1]) do={
/ip hotspot active remove [find user=$nameA]
}
}
}
}
:if ([$groupnameA]="B") do={
:set userb $userX
:if ([$fapstatus]<200) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 64k/64k 384k/384k 96k/96k 60/60 4 56k/56k"
:log info "total Mb Used=$fapstatus $userX $groupnameA OK"
:log info " "
}
:if ([$fapstatus]>200) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 56k/56k 384k/384k 64k/64k 60/60 5 32k/32k" group-name="G"
:log info "total Mb Used=$fapstatus $userX $groupnameA FAPPED"
:set fapstatus1 $userX
:log info " "
/ip hotspot active
:foreach i in=[/ip hotspot active find] do={
:set nameA $userX
:set macaddres [get $i mac-address]
:set ipaddres [get $i address]
:if ([$nameA]=[$fapstatus1]) do={
/ip hotspot active remove [find user=$nameA]
}
}
}
}
:if ([$groupnameA]="C") do={
:set userb $userX
:if ([$fapstatus]<550) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 256k/256k 1024k/1024k 128k/128k 400/400 4 128k/128k"
:log info "total Mb Used=$fapstatus $userX $groupnameA OK"
:log info " "
}
:if ([$fapstatus]>550) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 128k/128k 512k/512k 128k/128k 400/400 5 128k/128k" group-name="H"
:log info "total Mb Used=$fapstatus $userX $groupnameA User FAPPED"
:set fapstatus1 $userX
:log info " "
/ip hotspot active
:foreach i in=[/ip hotspot active find] do={
:set nameA $userX
:set macaddres [get $i mac-address]
:set ipaddres [get $i address]
:if ([$nameA]=[$fapstatus1]) do={
/ip hotspot active remove [find user=$nameA]
}
}
}
}
:if ([$groupnameA]="F") do={
:log info "total Mb Used=$fapstatus $userX $groupnameA FAPPED"
:log info " "
}
:if ([$groupnameA]="G") do={
:log info "total Mb Used=$fapstatus $userX $groupnameA FAPPED"
:log info " "
}
:if ([$groupnameA]="H") do={
:set userb $userX
:if ([$fapstatus]<750) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 128k/128k 512k/512k 128k/128k 400/400 5 128k/128k"
:log info "total Mb Used=$fapstatus $userX $groupnameA FAPPED"
:log info " "
}
:if ([$fapstatus]>750) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 56k/56k 384k/384k 64k/64k 60/60 5 32k/32k" group-name="I"
:log info "total Mb Used=$fapstatus $userX $groupnameA User FAPPED 2nd Time"
:set fapstatus1 $userX
:log info " "
/ip hotspot active
:foreach i in=[/ip hotspot active find] do={
:set nameA $userX
:set macaddres [get $i mac-address]
:set ipaddres [get $i address]
:if ([$nameA]=[$fapstatus1]) do={
/ip hotspot active remove [find user=$nameA]
}
}
}
}
:if ([$groupnameA]="I") do={
:set userb $userX
:if ([$fapstatus]<950) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 56k/56k 384k/384k 64k/64k 60/60 5 32k/32k"
:log info "total Mb Used=$fapstatus $userX $groupnameA FAPPED 2ND TIME"
:log info " "
}
:if ([$fapstatus]>950) do={
/tool user-manager user set [/tool user-manager user find name=$userX] rate-limit=" 1k/1k 2k/2k 1k/1k 60/60 8 1k/1k" group-name="J"
:log info "total Mb Used=$fapstatus $userX $groupnameA User FAPPED 3RD TIME"
:set fapstatus1 $userX
:log info " "
/ip hotspot active
:foreach i in=[/ip hotspot active find] do={
:set nameA $userX
:set macaddres [get $i mac-address]
:set ipaddres [get $i address]
:if ([$nameA]=[$fapstatus1]) do={
/ip hotspot active remove [find user=$nameA]
}
}
}
}
:if ([$groupnameA]="J") do={
:log info "total Mb Used=$fapstatus $userX $groupnameA FAPPED 3RD TIME"
:log info " "
}
}
}
}
}
}
}
}
}
setting up small WISP in Honduras over Satelite connections
 
User avatar
airstream
Member Candidate
Member Candidate
Topic Author
Posts: 188
Joined: Fri Feb 03, 2006 6:33 am
Location: New Zealand

Re: Usermanager Fields Script values

Mon Mar 31, 2008 11:08 pm

Many thanks mps01k :wink: , Ill have a go with this script over the next day or so. and get back.

Cheers
Keep tryin' its bound to work!!
-----
-----
ROOT@COSMOS> Reality.sys corrupted -- Reboot Universe (Y/N)?
>_
 
User avatar
airstream
Member Candidate
Member Candidate
Topic Author
Posts: 188
Joined: Fri Feb 03, 2006 6:33 am
Location: New Zealand

Re: Usermanager Fields Script values

Tue Apr 01, 2008 10:16 am

Thanks for your script mps01k, I have used the flow of your script to come up with
:local cap
 :local comment
 :local lastwarning
 :local throttle
 :local currentlimit
 
 /tool user-manager user
 :foreach i in=[/tool user-manager user find subscriber=admin] do={ 
 
 :set comment [get $i group-name]
 :set lastwarning [:pick $comment 4 6]
 :set currentlimit [get $i rate-limit]
 :set throttle [:pick $currentlimit 1 10]
 
 
 
 :if ([$throttle] = "128k/256k") do={ :if ([$lastwarning] = 99) do={ /tool user-manager user set (i) rate-limit=" 32k/32k 0/0 0/0 0/0 7" } }
 
 :if ([$throttle] = "32k/32k 0") do={ :if ([$lastwarning] < 99) do={ /tool user-manager user set (i) rate-limit=" 128k/256k 0/0 0/0 0/0 7" } }
 
 }
 
:wink: works a treat. We use the billing script by Kridge to implement the values called from the usermanagers group field.
Keep tryin' its bound to work!!
-----
-----
ROOT@COSMOS> Reality.sys corrupted -- Reboot Universe (Y/N)?
>_
 
mps01k
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Fri Mar 23, 2007 9:09 pm
Location: HONDURAS
Contact:

Re: Usermanager Fields Script values

Wed Apr 02, 2008 6:17 am

glad you were able to make it of some use

michael
setting up small WISP in Honduras over Satelite connections

Who is online

Users browsing this forum: bbs2web and 19 guests