<br>
<b>Warning</b>:  Undefined array key "HTTP_REFERER" in <b>/home/webhostingchenna/domains/webhostingchennai.co.in/public_html/blog/wp-content/plugins/wp-linkbuilder/plugin/plugin_class.inc.php</b> on line <b>637</b><br>
{"id":743,"date":"2018-02-26T16:22:39","date_gmt":"2018-02-26T10:52:39","guid":{"rendered":"http:\/\/www.webhostingchennai.co.in\/blog\/?p=743"},"modified":"2019-03-12T13:12:56","modified_gmt":"2019-03-12T07:42:56","slug":"how-find-resource-usages-of-users","status":"publish","type":"post","link":"https:\/\/www.webhostingchennai.co.in\/blog\/how-find-resource-usages-of-users\/","title":{"rendered":"How do I find resource usages of users in Centos"},"content":{"rendered":"<h4><span style="">How to find resource usages of users in Centos <\/span><\/h4>\n<p>In some high load situations, we need to find out the resource consumption of each user in the server to figure out the exact issue. There are a lot of options\/commands to find the same. Normally, we are using the \u201cps\u201d and \u201ctop\u201d command for performing this.<\/p>\n</p><p>Separating or sorting Unix user with their own resource usage is quit hard with a <a href="">Linux beginner<\/a>. \u00a0The command PS has a lot of switches for sorting processes in different manner.<\/p>\n<p>We can simply sort the current executing processes with its CPU and Memory conception ratio. Also, here is a simple link\u00a0for monitoring your server load \u201cLoad monitoring in Linux servers\u201c<\/p>\n</p><p><a href=""><img loading=""><\/a><\/p>\n<p>\u201cps command\u201d and \u201ctop command\u201d have a lot of options, here I am explaining some useful command combinations to find the resource(cpu, memory\u2026) usages of users in the server.<\/p>\n</p><p>It\u2019s simply a static output of current resource usage in the server. You can use the grep command to separate users.<\/p>\n</p><p><strong>To list top 10 CPU usage processes with user<\/strong><\/p>\n<pre># ps -e -o pcpu,pid,user,args|sort -k1 -nr|head -10\r\n\r\n\r\n<\/pre>\n<p><span style=""><strong>Output<\/strong><\/span><\/p>\n<pre>[root@webhostingchennai ~]# ps -e -o pcpu,pid,user,args|sort -k1 -nr|head -10\r\n%CPU   PID    USER     COMMAND\r\n 0.0     9    root     [rcu_sched]\r\n 0.0  9202    vnstat   \/usr\/sbin\/vnstatd -n\r\n 0.0     8    root     [rcu_bh]\r\n 0.0  8907    root     [kworker\/u4:2]\r\n 0.0     7    root     [migration\/0]\r\n 0.0   749    postfix  qmgr -l -t unix -u\r\n 0.0   746    root     \/usr\/libexec\/postfix\/master -w\r\n 0.0    68    root     [deferwq]\r\n 0.0     5    root     [kworker\/0:0H]\r\n[root@webhostingchennai ~]#\r\n<\/pre>\n<p><strong>Find out top 10 CPU consuming process<\/strong><\/p>\n<pre># ps -auxf|sort -nr -k3|head -10<\/pre>\n<p><span style=""><strong>Output<\/strong><\/span><\/p>\n<pre>[root@webhostingchennai ~]# ps -auxf|sort -nr -k3|head -10\r\nvnstat    9202  0.0  0.0   7444   848 ?        Ss   Feb19   0:48 \/usr\/sbin\/vnstatd -n\r\nUSER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND\r\nroot         9  0.0  0.0      0     0 ?        S    Feb19   3:56  \\_ [rcu_sched]\r\nroot      8907  0.0  0.0      0     0 ?        S    Feb19   0:00  \\_ [kworker\/u4:2]\r\nroot         8  0.0  0.0      0     0 ?        S    Feb19   0:00  \\_ [rcu_bh]\r\nroot       746  0.0  0.2  89036  2172 ?        Ss   Feb19   0:04 \/usr\/libexec\/postfix\/master -w\r\nroot         7  0.0  0.0      0     0 ?        S    Feb19   0:00  \\_ [migration\/0]\r\nroot        68  0.0  0.0      0     0 ?        S&lt;   Feb19   0:00  \\_ [deferwq]\r\nroot         5  0.0  0.0      0     0 ?        S&lt;   Feb19   0:00  \\_ [kworker\/0:0H]\r\nroot       494  0.0  0.0 110036   844 tty1     Ss+  Feb19   0:00 \/sbin\/agetty --noclear tty1 linux\r\n[root@webhostingchennai ~]#<\/pre>\n<p><strong>To list top 10 Memory consuming processes with user<\/strong><\/p>\n<pre># ps -e -o pmem,pid,user,args|sort -k1 -nr|head -10<\/pre>\n<p><span style=""><strong>Output<\/strong><\/span><\/p>\n<pre>[root@webhostingchennai ~]# ps -e -o pmem,pid,user,args|sort -k1 -nr|head -10\r\n 1.6   450 root     \/usr\/bin\/python -Es \/usr\/sbin\/tuned -l -P\r\n 1.3 19168 root     \/usr\/sbin\/httpd -DFOREGROUND\r\n 0.8   457 polkitd  \/usr\/lib\/polkit-1\/polkitd --no-debug\r\n 0.7 23926 apache   \/usr\/sbin\/httpd -DFOREGROUND\r\n 0.7 23925 apache   \/usr\/sbin\/httpd -DFOREGROUND\r\n 0.7 23924 apache   \/usr\/sbin\/httpd -DFOREGROUND\r\n 0.7 23424 apache   \/usr\/sbin\/httpd -DFOREGROUND\r\n 0.7 23388 apache   \/usr\/sbin\/httpd -DFOREGROUND\r\n 0.7 23387 apache   \/usr\/sbin\/httpd -DFOREGROUND\r\n 0.7 23386 apache   \/usr\/sbin\/httpd -DFOREGROUND\r\n[root@webhostingchennai ~]#\r\n<\/pre>\n<p><strong>Find out the top 10 memory consuming process<\/strong><\/p>\n<pre># ps -auxf|sort -nr -k4|head -10<\/pre>\n<p><span style=""><strong>Output<\/strong><\/span><\/p>\n<pre>[root@webhostingchennai ~]# ps -auxf|sort -nr -k4|head -10\r\nroot       450  0.0  1.6 553152 16436 ?        Ssl  Feb19   2:12 \/usr\/bin\/python -Es \/usr\/sbin\/tuned -l -P\r\nroot     19168  0.0  1.3 330364 13248 ?        Ss   Feb19   1:01 \/usr\/sbin\/httpd -DFOREGROUND\r\npolkitd    457  0.0  0.8 528308  8844 ?        Ssl  Feb19   0:00 \/usr\/lib\/polkit-1\/polkitd --no-debug\r\napache   23926  0.0  0.7 330364  7784 ?        S    Feb26   0:00  \\_ \/usr\/sbin\/httpd -DFOREGROUND\r\napache   23925  0.0  0.7 330364  7784 ?        S    Feb26   0:00  \\_ \/usr\/sbin\/httpd -DFOREGROUND\r\napache   23924  0.0  0.7 330364  7788 ?        S    Feb26   0:00  \\_ \/usr\/sbin\/httpd -DFOREGROUND\r\napache   23424  0.0  0.7 330364  7772 ?        S    Feb25   0:00  \\_ \/usr\/sbin\/httpd -DFOREGROUND\r\napache   23388  0.0  0.7 330364  7788 ?        S    Feb25   0:00  \\_ \/usr\/sbin\/httpd -DFOREGROUND\r\napache   23387  0.0  0.7 330364  7788 ?        S    Feb25   0:00  \\_ \/usr\/sbin\/httpd -DFOREGROUND\r\napache   23386  0.0  0.7 330364  7768 ?        S    Feb25   0:00  \\_ \/usr\/sbin\/httpd -DFOREGROUND\r\n[root@webhostingchennai ~]#\r\n<\/pre>\n<p><strong>Find out every process running under a user<\/strong><\/p>\n<pre># ps -U user-name -u user-name u<\/pre>\n<p>Or<\/p>\n</p><pre># ps -e -o pid,user,args|grep $username<\/pre>\n<p><span style=""><strong>Output<\/strong><\/span><\/p>\n<pre>[root@webhostingchennai ~]# ps -e -o pid,user,args|grep root\r\n    1 root     \/usr\/lib\/systemd\/systemd --switched-root --system --deserialize 21\r\n    2 root     [kthreadd]\r\n    3 root     [ksoftirqd\/0]\r\n    5 root     [kworker\/0:0H]\r\n    7 root     [migration\/0]\r\n    8 root     [rcu_bh]\r\n    9 root     [rcu_sched]\r\n   10 root     [watchdog\/0]\r\n   11 root     [watchdog\/1]\r\n   12 root     [migration\/1]\r\n   13 root     [ksoftirqd\/1]\r\n   15 root     [kworker\/1:0H]\r\n   17 root     [kdevtmpfs]\r\n   18 root     [netns]\r\n<\/pre>\n<p>To get a dynamic result you must use the \u2018top\u2018 command instead of \u2018ps\u2019 or use the \u2018watch\u2018 command along with the \u2018ps\u2019.<\/p>\n</p><p><strong>To show the process usage of a user with \u2018top\u2019<\/strong><\/p>\n<pre># top -u $username<\/pre>\n<p><span style=""><strong>Output<\/strong><\/span><\/p>\n<pre>top - 11:47:03 up 7 days, 23:53,  2 users,  load average: 0.00, 0.01, 0.05\r\nTasks:  76 total,   2 running,  74 sleeping,   0 stopped,   0 zombie\r\n%Cpu(s):  0.0 us,  0.2 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st\r\nKiB Mem :  1012436 total,   370668 free,    68052 used,   573716 buff\/cache\r\nKiB Swap:  2097148 total,  2097148 free,        0 used.   906684 avail Mem\r\n\r\n  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND\r\n23384 apache    20   0  330364   7768   1936 S   0.0  0.8   0:00.00 httpd\r\n23385 apache    20   0  330364   7788   1932 S   0.0  0.8   0:00.00 httpd\r\n23386 apache    20   0  330364   7768   1936 S   0.0  0.8   0:00.00 httpd\r\n23387 apache    20   0  330364   7788   1932 S   0.0  0.8   0:00.00 httpd\r\n23388 apache    20   0  330364   7788   1936 S   0.0  0.8   0:00.00 httpd\r\n23424 apache    20   0  330364   7772   1936 S   0.0  0.8   0:00.00 httpd\r\n23924 apache    20   0  330364   7788   1936 S   0.0  0.8   0:00.00 httpd\r\n23925 apache    20   0  330364   7784   1932 S   0.0  0.8   0:00.00 httpd\r\n23926 apache    20   0  330364   7784   1932 S   0.0  0.8   0:00.00 httpd\r\n<\/pre>\n<p>You can refer this \u201cHow to show process usage for single user with TOP command\u201d for more details<\/p>\n</p><p><strong>To list top 10 CPU usage processes with user<\/strong><\/p>\n<pre># watch \"ps -e -o pcpu,pid,user,args|sort -k1 -nr|head -10\"<\/pre>\n<p><span style=""><strong>Output<\/strong><\/span><\/p>\n<pre>0.4 24497 root     watch ps -e -o pcpu,pid,user,args|sort -k1 -nr|head -10\r\n%CPU   PID USER     COMMAND\r\n 0.0     9 root     [rcu_sched]\r\n 0.0  9202 vnstat   \/usr\/sbin\/vnstatd -n\r\n 0.0     8 root     [rcu_bh]\r\n 0.0  8907 root     [kworker\/u4:2]\r\n 0.0     7 root     [migration\/0]\r\n 0.0   749 postfix  qmgr -l -t unix -u\r\n 0.0   746 root     \/usr\/libexec\/postfix\/master -w\r\n 0.0    68 root     [deferwq]\r\n<\/pre>\n<p><strong>To list top 10 Memory consuming processes with user<\/strong><\/p>\n<pre># watch \"ps -e -o pmem,pid,user,args|sort -k1 -nr|head -10\"<\/pre>\n<p>instead you can use the grep command to separate users.<\/p>\n</p><p>To disable SELinux : <a href="">Click Here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":934,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,20],"tags":[91,92],"class_list":["post-743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-vps","tag-finding-high-resource-users","tag-finding-resource-usage"],"_links":{"self":[{"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/posts\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/comments?post=743"}],"version-history":[{"count":8,"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":1179,"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/posts\/743\/revisions\/1179"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/media\/934"}],"wp:attachment":[{"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/media?parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/categories?post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhostingchennai.co.in\/blog\/wp-json\/wp\/v2\/tags?post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}</p></a></p></pre></strong></p></pre></strong></span></p></pre></strong></p></pre></strong></span></p></pre></strong></p></pre></strong></span></p></pre></pre></strong></p></pre></strong></span></p></pre></strong></p></pre></strong></span></p></pre></strong></p></pre></strong></span></p></pre></strong></p></pre></strong></span></p></pre></strong></p></a></p></a></p></span></h4>