CPUãã¡ã¢ãªãIOã¨ãã£ããªã½ã¼ã¹ã®å¶éä¸ã§ã¨ããã³ãã³ããå®è¡ããããå ´åã«ãcgroupä¸ã«ä½ãgroupãä½ã£ãããã¦ããcgexecãå®è¡ãã¦ãå®è¡å¾ã¯ãã®groupãæ¶ããã¨ãã£ããããªä¸æéãããæ¹æ³ãã»ã¨ãã©ã§ããã
å®è¡å¾ã®groupã綺éºã«ããããã¨ãã£ãæã¾ã§èããã¨ãªããªãæéãããã£ã¦ããã®ã§ãããããå ¨ã¦ã¯ã³ã©ã¤ã³ã§ã§ããrconã¨ããã¯ã³ãã¤ããªã§åããã¼ã«ãä½ãã¾ããã
ä¾ãã°ãè² è·ãµã¼ãã§ã®èª¿æ»ãã¼ã«ãæµãéã«ãCPUã¨ãIOã¨ããå¶éãã¤ã¤ããããå®è¡ãããå ´åçã«ä¾¿å©ã§ããLinuxã®cgroup対å¿ããç°å¢ã§ã®ã¿åãã¾ãã
使ãæ¹
ã»ã¼READMEéããªã®ã§ããããªãã·ã§ã³ã¯ä»£æ¿ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã
--memã¯å¤ãªã®ã§--memoryã«å¤æ´ãã¾ãã!!
./rcon --help Usage: rcon [options] --user username --command "yes >> /dev/null" --cpu VAL default: 30 (%) --memory VAL default: 512000000 (Byte) --read VAL defualt: 10485760 (Byte/sec) --write VAL defualt: 10485760 (Byte/sec) --group VAL defualt: rcon --dev VAL default: 202:0 --version
ä¾ãã°ãCPUãå¶éãã¤ã¤å®è¡ãããå ´åã«ãæ®éã«ä»¥ä¸ã®ãããªCPUãé£ãã³ãã³ããå®è¡ããã¨ã
yes >> /dev/null
CPUãã¬ãã¨100ï¼ é£ããã¾ãã
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 27577 matsumot 20 0 98.5m 608 520 R 100.0 0.0 0:01.95 yes
ããããrcon
ã使ã£ã¦10%ã®ä½¿ç¨çã«å¶éãã¤ã¤å®è¡ããã¨ã
sudo ./rcon --user matsumotory --command "yes >> /dev/null" --cpu 10
ãããªæãã§CPUã10ï¼ ä»¥ä¸ã«å¶éããã¤ã¤å®è¡ããã¾ãã
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 23941 matsumot 20 0 98.5m 604 520 R 9.6 0.0 0:00.63 yes
ãæ軽ã§ä¾¿å©ã§ããã
ã¾ããIOãå¶éãããå ´åããæ®éã«ddãå®è¡ããã¨ã
dd if=/dev/zero of=tempfile bs=1M count=1000 oflag=direct
ãããªæãã§ã¬ãããªIOã使ããã¾ãã
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 27569 be/4 matsumot 0.00 B/s 22.09 M/s 0.00 % 95.93 % dd if=/dev/zero of=tempfile bs=1M count=1000 oflag=direct
ããããä¾ãã°ãããã1Mbyte/sec以ä¸ã§writeãããå ´åã«ã¯ãrconã§ä»¥ä¸ã®ããã«å®è¡ããã¨ã
sudo ./rcon --user matsumotory --command "dd if=/dev/zero of=tempfile bs=1M count=1000 oflag=direct" --write 1024000
綺éºã«1Mbyte/sec以ä¸ã§writeãèµ°ã£ã¦ãã¾ãã
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 24676 be/4 matsumot 0.00 B/s 995.77 K/s 0.00 % 99.99 % dd if=/dev/zero of=tempfile bs=1M count=1000 oflag=direct
ã¡ãªã¿ã«ãIOã®ããã¤ã¹ã¯IDã§æå®ããªãã¨ãããªãã®ã§ã以ä¸ã®ããã«å¯¾è±¡IOããã¤ã¹ã®IDãåå¾ãã¦ã
$ ls -l /dev/xvda | awk '{print $5 $6}' | sed 's/,/:/' 202:0
--dev
ãªãã·ã§ã³ã«æ¸¡ãã¨ããã®ããã¤ã¹ã§ã®IOãå¶éãã¦ããã¾ãã
ã¾ãã--group
ã¨ããæ©è½ããã£ã¦ãããã©ã«ãã¯rcon
ã°ã«ã¼ããªã®ã§ããããããç¹å®ã®groupåã«è¨å®ãã¦å®è¡ããå ´åãä¾ãã°è¤æ°ã®rconã§åä¸ã°ã«ã¼ãå
ã§å®è¡ããã¨ãããã«å±ããã°ã«ã¼ãã¯ãæå®ãããªã½ã¼ã¹å
ã§å
±æããªããå®è¡ããã¾ãã
ä¾ãã°ãCPUã50ï¼ ã«å¶éãã¦ãåä¸ã°ã«ã¼ãã§rconçµç±ã§2ã¤ã³ãã³ããå®è¡ããã¨ããããã25ï¼ ã®CPUã使ãã¤ã¤å®è¡ããã¾ãã
loopã®ãããªå¦çãSIGTERMãããSIGINTãã¦ããcgroupãã¡ããã¨æé¤ãã¦ãããã®ã§ããã®è¾ºããå²ãã¨ä¾¿å©ã§ãã
ã¨ãããã¨ã§ãªããªã便å©ãªã®ã§ããã²ãæ´»ç¨ä¸ããã