ã¿ã¤ãã«ã®ã¾ã¾ãªã®ã§ãããpidãã対象ããã»ã¹ãopenãã¦ããã¡ã¤ã«ã¨ãã®ownerã解æããCPU使ç¨çãMemory使ç¨çã¨åããã¦ã¬ãã¼ãããã¯ã³ãã¤ããªãªãã¼ã«ãä½ãã¾ããã
ã¨ããã®ãããã¹ãã£ã³ã°ã«ããã¦ã¯è² è·ãããã¦ããããã»ã¹ã«ã¤ãã¦ããªã½ã¼ã¹ä½¿ç¨éãå ã«openãã¦ãããã¡ã¤ã«ãã¹ããã¡ã¤ã«ã®ownerãè¿ éã«ç¥ãããå ´åãå¤ãããã§ãã
æ¢ã«ããã³ãã³ããlsof
ã/proc
ãtop
ã¨ããã®è¾ºãçµã¿åãããã¨ãã¡ããã§ãããã§ãããmruby-cliã使ã£ã¦one-binaryã§ä½ã£ã¦ã¿ããã£ãã®ã¨ãopenãã¦ãããã¡ã¤ã«ã¨CPU使ç¨çãMemory使ç¨éåæã«ãµã¯ã£ã¨ç´ æ©ã表示ãã¦ããããã¼ã«ãããã¨èª¿ã¹ãæãªãã£ãã®ã§å®è£
ãã¦ã¿ã¾ããã
- pfds - report a snapshot of the current processes fd
使ãæ¹
使ãæ¹ã¯ã»ã¼READMEã®ã¾ã¾ãªã®ã§ãããCPU使ç¨éã¨ãããããªãå ´åã¯ãshortãªãã·ã§ã³ã§å®è¡ããã¨ä»¥ä¸ã®ããã«è¡¨ç¤ºããã¾ãã
shortãã¼ã¸ã§ã³
$ sudo pfds short `pgrep nginx` | head 19939 daemon /usr/local/nginx-1.9.5/logs/error.log 19939 daemon /usr/local/nginx-1.9.5/logs/access.log 19939 daemon /usr/local/nginx-1.9.5/logs/deflate.log 19940 daemon /usr/local/nginx-1.9.5/logs/error.log 19940 daemon /usr/local/apache-2.4.16/htdocs/blog/wp-content/plugins/wp-social-bookmarking-light/images/hatena.gif 19940 daemon /usr/local/nginx-1.9.5/logs/access.log
å·¦ãããpidãopenãã¦ãããã¡ã¤ã«ã®ownerãopenãã¦ãããã¡ã¤ã«ãã®é ã§ããã¾ããé«éã«åä½ããããã«ãããã©ã«ã§ã¯4並åã§è§£æãã¦ããã並åæ°ã¯MRUBY_MULTI
ç°å¢å¤æ°ããå¤æ´ã§ãã¾ãã
sudo MRUBY_MULTI=24 pfds short `pgrep httpd`
ã¨ãã§ããã
ãªã½ã¼ã¹ä½¿ç¨éã表示ãããã¼ã¸ã§ã³
CPUãMemoryã®ä½¿ç¨éã§sortãªã©ããããå ´åã¯ã
$ sudo pfds `pgrep nginx` | head 19939 0.0 0.1 daemon /usr/local/nginx-1.9.5/logs/error.log 19939 0.0 0.1 daemon /usr/local/nginx-1.9.5/logs/access.log 19939 0.0 0.1 daemon /usr/local/nginx-1.9.5/logs/deflate.log 19940 0.0 0.3 daemon /usr/local/nginx-1.9.5/logs/error.log 19940 0.0 0.3 daemon /usr/local/apache-2.4.16/htdocs/blog/wp-content/plugins/wp-social-bookmarking-light/images/hatena.gif 14057 37.3 2.1 matsumoto_r /usr/local/apache-2.4.16/htdocs/blog/index.php
ã¨ããã¨ãpidãcpu使ç¨çãmemory使ç¨çãã¨ããããã«è¡¨ç¤ºããã¾ãã
ä¾ãã°ã
sudo ./pfds `pgrep httpd` | sort -nk2
ã§CPUé ã«sortãããããã¨è¯ãã§ãããã
ç¡è¦ãªã¹ããä½ã£ã¦ãã
æ®éã«å ¨é¨ã®openãã¡ã¤ã«ãè¦ãã¨ãããããã§ãããã®ã§ãä¾ãã°openãã¦ããã®ãããã£ã¦ãããããªãã¡ã¤ã«ãæåããç¡è¦ãªã¹ãã«ããã¦ããã¨ããã§ãããã
ãã®ããã«ã¯ããã«ãåã«ä»¥ä¸ã® mrblib/pfds/config.rb
ãå¤æ´ãã¦ãããã«ãããã¨è¯ãã§ãã
module Pfds module Config MULTI_PROCESS = (ENV["MRUBY_MULTI"] || 4).to_i IGNORE_FILES = %w( /dev/null /var/log/httpd/access_log /var/log/httpd/ssl_access_log /var/log/httpd/error_log /var/log/httpd/ssl_error_log ) IGNORE_PATTERN = %w( ^pipe: ^anon_inode: ^socket: ^/dev/pts/ ) end end
ããã©ã«ãã®ä¸¦åæ°ãå¤æ´ã§ãã¾ããã
ã¾ã¨ã
ã¨ãããã¨ã§ãã¯ã³ãã¤ããªãªã®ã§ãã¤ããªä¸ã¤ãµã¼ãã«éãè¾¼ãã°ä½¿ãã¦ãããã¨è²ã 便å©ãªã®ã§ãã²ä½¿ã£ã¦ã¿ã¦ãã ããã