Fair Bandwidth Sharing for simple queues: Porovnání verzí

Z Wiki UnArt Slavičín
Skočit na navigaciSkočit na vyhledávání
(Nová stránka: #Script name: "Fair Bandwidth Sharing" for simple queues #Author: Tomas Dulik #Date: Feb 2008 #Description: This script distributes the value of limit-at of a parent queue equally am...)
 
Bez shrnutí editace
Řádek 1: Řádek 1:
#Script name: "Fair Bandwidth Sharing" for simple queues
#Script name: "Fair Bandwidth Sharing" for simple queues
#Author: Tomas Dulik
#Author: Tomas Dulik
#Date: Feb 2008
#Date: Feb 2008
#Description: This script distributes the value of limit-at of a parent queue equally among all its children  
#Description: This script distributes the value of limit-at of a parent queue equally among all its children  
########## Tuto promennou nastav - misto "Ostatni" napis jmeno primo nadrazene (parent) fronty vsech uzivatelu!
########## Tuto promennou nastav - misto "Ostatni" napis jmeno primo nadrazene (parent) fronty vsech uzivatelu!
:local usersParent "Ostatni"
:local usersParent "Ostatni"
### nasledujici 2 promenne definuji hodnotu "max-limit", ktera se nastavi vsem uzivatelum
### nasledujici 2 promenne definuji hodnotu "max-limit", ktera se nastavi vsem uzivatelum
## Pokud je promenna $userDownloadMaxLimit nebo $userUploadLimit = 0, pouzijeme hodnotu max-limit rodicovske fronty  
## Pokud je promenna $userDownloadMaxLimit nebo $userUploadLimit = 0, pouzijeme hodnotu max-limit rodicovske fronty  
## (hodnoty muzes ale zadat (v bits/sekundu) tak jak na nasledujicich radcich:  
## (hodnoty muzes ale zadat (v bits/sekundu) tak jak na nasledujicich radcich:  
:local userDownloadMaxLimit 0
:local userDownloadMaxLimit 0
:local userUploadMaxLimit 512000
:local userUploadMaxLimit 512000


########## Tady zacina skript - pokud tomu nerozumis, radsi do ne nerypej
########## Tady zacina skript - pokud tomu nerozumis, radsi do ne nerypej
:set usersParentMaxLimit [/queue simple get $usersParent max-limit]
:set usersParentMaxLimit [/queue simple get $usersParent max-limit]
:set slashPosition [:find $usersParentMaxLimit /]
:set slashPosition [:find $usersParentMaxLimit /]
## Pokud neni nastavena promenna $userDownloadMaxLimit, nastavime ji na max-limit rodicovske fronty
## Pokud neni nastavena promenna $userDownloadMaxLimit, nastavime ji na max-limit rodicovske fronty
:if ($userDownloadMaxLimit=0) do={
:if ($userDownloadMaxLimit=0) do={
   :log info "max-limit for users' download was not set, using the max-limit of their parent queue..."
   :log info "max-limit for users' download was not set, using the max-limit of their parent queue..."
##z usersParentMaxLimit musime pomoci ":pick" vysekat max-limit pro download
##z usersParentMaxLimit musime pomoci ":pick" vysekat max-limit pro download
   :set userDownloadMaxLimit [:pick $usersParentMaxLimit ($slashPosition+1) [:len $usersParentMaxLimit]]
   :set userDownloadMaxLimit [:pick $usersParentMaxLimit ($slashPosition+1) [:len $usersParentMaxLimit]]
}
}
## Pokud neni nastavena promenna $userUploadMaxLimit, nastavime ji na max-limit rodicovske fronty
## Pokud neni nastavena promenna $userUploadMaxLimit, nastavime ji na max-limit rodicovske fronty
:if ($userUploadMaxLimit=0) do={
:if ($userUploadMaxLimit=0) do={
   :log info "max-limit for users' upload was not set, using the max-limit of their parent queue..."
   :log info "max-limit for users' upload was not set, using the max-limit of their parent queue..."
   :set userUploadMaxLimit [:pick $usersParentMaxLimit 0 $slashPosition]
   :set userUploadMaxLimit [:pick $usersParentMaxLimit 0 $slashPosition]
}
}


##usersParentLimitAt bude retezec napr. 1000000/4000000 (tj. upload/download)
##usersParentLimitAt bude retezec napr. 1000000/4000000 (tj. upload/download)
:set usersParentLimitAt [/queue simple get $usersParent limit-at]
:set usersParentLimitAt [/queue simple get $usersParent limit-at]
##z usersParentLimitAt musime vysekat limit-at pro upload:
##z usersParentLimitAt musime vysekat limit-at pro upload:
:set slashPosition [:find $usersParentLimitAt /]
:set slashPosition [:find $usersParentLimitAt /]
:set usersParentUploadLimitAt [:pick $usersParentLimitAt 0 $slashPosition]
:set usersParentUploadLimitAt [:pick $usersParentLimitAt 0 $slashPosition]
##a take limit-at pro download:
##a take limit-at pro download:
:set usersParentDownloadLimitAt [:pick $usersParentLimitAt ($slashPosition+1) [:len $usersParentLimitAt]]
:set usersParentDownloadLimitAt [:pick $usersParentLimitAt ($slashPosition+1) [:len $usersParentLimitAt]]


#### A ted uz zbyva nastavit spravne limit-at a max-limit pro vsechny uzivatele:
#### A ted uz zbyva nastavit spravne limit-at a max-limit pro vsechny uzivatele:
### Sestavime si seznam front vsech uzivatelu  (maji parent-a zadaneho prvnim radkem tohoto skriptu]
### Sestavime si seznam front vsech uzivatelu  (maji parent-a zadaneho prvnim radkem tohoto skriptu]
:set usersQueues [/queue simple find parent=$usersParent]
:set usersQueues [/queue simple find parent=$usersParent]
## spocitame, kolik tech uzivatelu mame:
## spocitame, kolik tech uzivatelu mame:
:set usersCount [:len $usersQueues]
:set usersCount [:len $usersQueues]
##a vypocitame, jak velky ma byt limit-at pro jednotlive uzivatele:
##a vypocitame, jak velky ma byt limit-at pro jednotlive uzivatele:
:set userDownloadLimitAt ($usersParentDownloadLimitAt/$usersCount)
:set userDownloadLimitAt ($usersParentDownloadLimitAt/$usersCount)
:set userUploadLimitAt ($usersParentUploadLimitAt/$usersCount)
:set userUploadLimitAt ($usersParentUploadLimitAt/$usersCount)


#a tady uz to vsem uzivatelum nastavime:
#a tady uz to vsem uzivatelum nastavime:
:foreach queue in=$usersQueues do={
:foreach queue in=$usersQueues do={
   /queue simple set $queue limit-at ($userUploadLimitAt . "/" . $userDownloadLimitAt) max-limit ($userUploadMaxLimit . "/" . $userDownloadMaxLimit) direction both
   /queue simple set $queue limit-at ($userUploadLimitAt . "/" . $userDownloadLimitAt) max-limit ($userUploadMaxLimit . "/" . $userDownloadMaxLimit) direction both
}
}

Verze z 7. 2. 2008, 17:40

#Script name: "Fair Bandwidth Sharing" for simple queues
#Author: Tomas Dulik
#Date: Feb 2008
#Description: This script distributes the value of limit-at of a parent queue equally among all its children 
########## Tuto promennou nastav - misto "Ostatni" napis jmeno primo nadrazene (parent) fronty vsech uzivatelu!
:local usersParent "Ostatni"
### nasledujici 2 promenne definuji hodnotu "max-limit", ktera se nastavi vsem uzivatelum
## Pokud je promenna $userDownloadMaxLimit nebo $userUploadLimit = 0, pouzijeme hodnotu max-limit rodicovske fronty 
## (hodnoty muzes ale zadat (v bits/sekundu) tak jak na nasledujicich radcich: 
:local userDownloadMaxLimit 0
:local userUploadMaxLimit 512000
########## Tady zacina skript - pokud tomu nerozumis, radsi do ne nerypej
:set usersParentMaxLimit [/queue simple get $usersParent max-limit]
:set slashPosition [:find $usersParentMaxLimit /]
## Pokud neni nastavena promenna $userDownloadMaxLimit, nastavime ji na max-limit  rodicovske fronty
:if ($userDownloadMaxLimit=0) do={
 :log info "max-limit for users' download was not set, using the max-limit of their parent queue..."
##z usersParentMaxLimit musime pomoci ":pick" vysekat max-limit pro download
 :set userDownloadMaxLimit [:pick $usersParentMaxLimit ($slashPosition+1) [:len  $usersParentMaxLimit]]
}
## Pokud neni nastavena promenna $userUploadMaxLimit, nastavime ji na max-limit rodicovske fronty
:if ($userUploadMaxLimit=0) do={
 :log info "max-limit for users' upload was not set, using the max-limit of their parent queue..."
 :set userUploadMaxLimit [:pick $usersParentMaxLimit 0 $slashPosition]
}
##usersParentLimitAt bude retezec napr. 1000000/4000000 (tj. upload/download)
:set usersParentLimitAt [/queue simple get $usersParent limit-at]
##z usersParentLimitAt musime vysekat limit-at pro upload:
:set slashPosition [:find $usersParentLimitAt /]
:set usersParentUploadLimitAt [:pick $usersParentLimitAt 0 $slashPosition]
##a take limit-at pro download:
:set usersParentDownloadLimitAt [:pick $usersParentLimitAt ($slashPosition+1) [:len  $usersParentLimitAt]]
#### A ted uz zbyva nastavit spravne limit-at a max-limit pro vsechny uzivatele:
### Sestavime si seznam front vsech uzivatelu  (maji parent-a zadaneho prvnim radkem tohoto skriptu]
:set usersQueues [/queue simple find parent=$usersParent]
## spocitame, kolik tech uzivatelu mame:
:set usersCount [:len $usersQueues]
##a vypocitame, jak velky ma byt limit-at pro jednotlive uzivatele:
:set userDownloadLimitAt ($usersParentDownloadLimitAt/$usersCount)
:set userUploadLimitAt ($usersParentUploadLimitAt/$usersCount)
#a tady uz to vsem uzivatelum nastavime:
:foreach queue in=$usersQueues do={
 /queue simple set $queue limit-at ($userUploadLimitAt . "/" . $userDownloadLimitAt) max-limit ($userUploadMaxLimit . "/" . $userDownloadMaxLimit) direction both
}