Fair Bandwidth Sharing for simple queues

Z Wiki UnArt Slavičín
Verze z 7. 2. 2008, 17:39, kterou vytvořil 10.143.19.19 (diskuse) (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...)
(rozdíl) ← Starší verze | zobrazit aktuální verzi (rozdíl) | Novější verze → (rozdíl)
Skočit na navigaciSkočit na vyhledávání
  1. Script name: "Fair Bandwidth Sharing" for simple queues
  2. Author: Tomas Dulik
  3. Date: Feb 2008
  4. Description: This script distributes the value of limit-at of a parent queue equally among all its children
                    1. Tuto promennou nastav - misto "Ostatni" napis jmeno primo nadrazene (parent) fronty vsech uzivatelu!
local usersParent "Ostatni"
      1. nasledujici 2 promenne definuji hodnotu "max-limit", ktera se nastavi vsem uzivatelum
    1. Pokud je promenna $userDownloadMaxLimit nebo $userUploadLimit = 0, pouzijeme hodnotu max-limit rodicovske fronty
    2. (hodnoty muzes ale zadat (v bits/sekundu) tak jak na nasledujicich radcich:
local userDownloadMaxLimit 0
local userUploadMaxLimit 512000
                    1. Tady zacina skript - pokud tomu nerozumis, radsi do ne nerypej
set usersParentMaxLimit [/queue simple get $usersParent max-limit]
set slashPosition [:find $usersParentMaxLimit /]
    1. 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..."
    1. z usersParentMaxLimit musime pomoci ":pick" vysekat max-limit pro download
 :set userDownloadMaxLimit [:pick $usersParentMaxLimit ($slashPosition+1) [:len $usersParentMaxLimit]]

}

    1. 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]

}

    1. usersParentLimitAt bude retezec napr. 1000000/4000000 (tj. upload/download)
set usersParentLimitAt [/queue simple get $usersParent limit-at]
    1. z usersParentLimitAt musime vysekat limit-at pro upload:
set slashPosition [:find $usersParentLimitAt /]
set usersParentUploadLimitAt [:pick $usersParentLimitAt 0 $slashPosition]
    1. a take limit-at pro download:
set usersParentDownloadLimitAt [:pick $usersParentLimitAt ($slashPosition+1) [:len $usersParentLimitAt]]
        1. A ted uz zbyva nastavit spravne limit-at a max-limit pro vsechny uzivatele:
      1. Sestavime si seznam front vsech uzivatelu (maji parent-a zadaneho prvnim radkem tohoto skriptu]
set usersQueues [/queue simple find parent=$usersParent]
    1. spocitame, kolik tech uzivatelu mame:
set usersCount [:len $usersQueues]
    1. a vypocitame, jak velky ma byt limit-at pro jednotlive uzivatele:
set userDownloadLimitAt ($usersParentDownloadLimitAt/$usersCount)
set userUploadLimitAt ($usersParentUploadLimitAt/$usersCount)
  1. 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

}