dstatãã¡ãã£ã¨ã ãæ¹é ãã話
以åããdstatãkibanaã§å¯è¦åãã®è©±ãæ¸ããã®ã§ããã ãã®æã®ç°å¢ã§è²ã ä¸è¶³ããã£ã¦æãå ãããããããã¯ãã®æã«æ°ã«ãªã£ãé¨åãå¾ã§æ¹è¯ããããã¨ããäºããã£ã¦ã ååã®è¨äºãfluentd-plugin-dstat_stdinã½ãã®ãæ¸ãã話ãã ãã®æã®1ã¤ã§ãã
ä»åããã®1ã¤ã§ãdstatã§ã®åºåå
容ã«ä¸è¶³ããã£ãã®ã§è¿½å ãã¦ã¿ã話ã§ãã
å
·ä½çã«ã¯dstat(0.7.2)ã®CPUé¢é£ã®åºåã«stealã追å ãã¾ãã
dstatã¯pythonã§æ¸ããã¦ãã¾ãã
apt-getã§å
¥ããå ´åãæ¬ä½ã¯ /usr/bin/dstat ã«ããã¾ãã
ã¾ããpluginã®å ´åã¯/usr/share/dstaté
ä¸ã«åå¥ãã¡ã¤ã«ã§ç½®ãããå½¢ã§ãã
/usr/bin/dstat ãè¦ã¦ã¿ãã¨ããªãã·ã§ã³é
ç®æ¯ã«classãåã£ã¦ãã£ã¦ã
CPUé¢ä¿ã®å ´åãclass dstat_cpu
ã«ãªãã¾ãã
class dstat_cpu(dstat): def __init__(self): self.nick = ( 'usr', 'sys', 'idl', 'wai', 'hiq', 'siq' ) self.type = 'p' self.width = 3 self.scale = 34 self.open('/proc/stat') self.cols = 6 ...ç¥
classå®ç¾©ã®é¨åããã/proc/statããæ å ±ãåå¾ãã¦ãã¦ã usr, sys, idl, wai, hiq, siq ã®6é ç®ã§ãããã¨ãæ³åã§ãã¾ãã
/proc/statãè¦ã¦ã¿ã¾ãã
cpu 370 0 441 313249 132 0 31 0 0 0 cpu0 370 0 441 313249 132 0 31 0 0 0 ...ç¥
ãã®è¡ã®åæ°å¤ãåå¾ãã¦å å·¥ãã¦è¡¨ç¤ºãã¦ãã¾ãã
ãcpuããTotalã§[cpu0ããcpu1åç®ããã«ãã³ã¢ãªãæ´ã«è¡ãå¢ãã¾ãã
procã®man page ã§/proc/statãè¦ã¦ã¿ãã¨ã
â user â¡nice â¢system â£idle â¤lowait â¥irq â¦softirq â§steal â¨guest â©guest_nice
ã§ã/usr/bin/dstatã®å®éã«åå¾ãã¦ããé¨åãè¦ãã¨
self.set2[name] = ( long(l[1]) + long(l[2]), long(l[3]), long(l[4]), long(l[5]), long(l[6]), long(l[7]) )
7çªç®ã¾ã§ä½¿ããã¦ããã®ã§ãä¼¼ããããªå½¢ã§8çªç®ãåå¾ããããã«ããã°stealã表示ã§ããããªãã¨ããããã¾ãã
æçµçã«ä¿®æ£ããå·®åã¯ä»¥ä¸
vagrant@server:/usr/bin$ diff dstat updated__dstat 564c564 < self.nick = ( 'usr', 'sys', 'idl', 'wai', 'hiq', 'siq' ) --- > self.nick = ( 'usr', 'sys', 'idl', 'wai', 'hiq', 'siq', 'stl' ) 569c569 < self.cols = 6 --- > self.cols = 7 574c574 < if len(l) < 8 or l[0][0:3] != 'cpu': continue --- > if len(l) < 9 or l[0][0:3] != 'cpu': continue 609c609 < if len(l) < 8: continue --- > if len(l) < 9: continue 612c612 < self.set2[name] = ( long(l[1]) + long(l[2]), long(l[3]), long(l[4]), long(l[5]), long(l[6]), long(l[7]) ) --- > self.set2[name] = ( long(l[1]) + long(l[2]), long(l[3]), long(l[4]), long(l[5]), long(l[6]), long(l[7]), long(l[8]) ) 614c614 < for i in range(6): --- > for i in range(7):
ãããªæãã§æ¯è¼çç°¡åã«ä¿®æ£ãããã¨ãå¯è½ã§ãã
dstatããã£ã¦ãããã¨ã¯å¤§ä½ã/procé
ä¸ã®ãã¡ã¤ã«ãå®æçã«è¦ã¦æ°å¤ã¨ã£ã¦ãã ããªã®ã§ã
æ
£ããã¨è²ã
好ããªæ°å¤ãã¨ã£ããã§ãããã§ãã
ä¾ãã°èªåã¯/proc/net/snmpã®UDPãã±ããã®åå¤ãåå¾ããpluginãæ¸ããããã¾ããã
ãã«ãªã¯ããã°ãããããªããã¨è¨ããããã§ãããgithubã®dstatã¬ãã¸ããªã§ã¯çµæ§ã½ã¼ã¹ãå¤æ´ããã¦ãã¦ã stealã®è¡¨ç¤ºãæ¢ã«å ¥ã£ã¦ãã¾ããéã«hiq, siqã¯å¥optionã«è¿½ãåºããã¦ãããã ããã0.7.2ãåºã¦ãã2å¹´ããã£ã¦ãã¦ãã¤æ´æ°ããããã¯ä¸æãªç¶æ³ã ã£ããã æ©ã¾ããã§ãã
ãã¨ã¯fluentd-plugin-mapã®configurationã®è©±ãåºæ¥ãããã«ãªãã¨ä¸éãã»ã»ã»