Get separate user, system, etc CPU usage per process












3















On a Unix or Unix-like system, how do I view the percent CPU usage per process, split into user and system and other time categories? top shows me overall "sy", "us", "wa", etc for the entire computer or per core, but I don't see anything in the manual showing how to show those stats per process.



To illustrate...
top shows something like this:



top - 18:11:58 up 9 days,  6:41, 17 users,  load average: 2.42, 2.38, 2.47
Tasks: 2642 total, 4 running, 2638 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.9 us, 0.8 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 26413387+total, 26355763+used, 576240 free, 233544 buffers
KiB Swap: 8921084 total, 8920140 used, 944 free. 14931166+cached Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
63209 postgres 20 0 0.101t 0.012t 0.012t R 100.0 5.0 389:44.92 postgres
62356 postgres 20 0 0.101t 922336 886508 R 100.0 0.3 10:25.82 postgres
2139 rabbitmq 20 0 9817.9m 5.334g 2968 S 10.4 2.1 1848:43 beam.


For example, I'd like to see something like this (see %CPU(sy) and %CPU(us)):



top - 18:11:58 up 9 days,  6:41, 17 users,  load average: 2.42, 2.38, 2.47
Tasks: 2642 total, 4 running, 2638 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.9 us, 0.8 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 26413387+total, 26355763+used, 576240 free, 233544 buffers
KiB Swap: 8921084 total, 8920140 used, 944 free. 14931166+cached Mem

PID USER PR NI VIRT RES SHR S %CPU(us) %CPU(sy) %MEM TIME+ COMMAND
63209 postgres 20 0 0.101t 0.012t 0.012t R 100.0 1.0 5.0 389:44.92 postgres
62356 postgres 20 0 0.101t 922336 886508 R 100.0 0.4 0.3 10:25.82 postgres
2139 rabbitmq 20 0 9817.9m 5.334g 2968 S 10.4 0.2 2.1 1848:43 beam.









share|improve this question



























    3















    On a Unix or Unix-like system, how do I view the percent CPU usage per process, split into user and system and other time categories? top shows me overall "sy", "us", "wa", etc for the entire computer or per core, but I don't see anything in the manual showing how to show those stats per process.



    To illustrate...
    top shows something like this:



    top - 18:11:58 up 9 days,  6:41, 17 users,  load average: 2.42, 2.38, 2.47
    Tasks: 2642 total, 4 running, 2638 sleeping, 0 stopped, 0 zombie
    %Cpu(s): 2.9 us, 0.8 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    KiB Mem: 26413387+total, 26355763+used, 576240 free, 233544 buffers
    KiB Swap: 8921084 total, 8920140 used, 944 free. 14931166+cached Mem

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    63209 postgres 20 0 0.101t 0.012t 0.012t R 100.0 5.0 389:44.92 postgres
    62356 postgres 20 0 0.101t 922336 886508 R 100.0 0.3 10:25.82 postgres
    2139 rabbitmq 20 0 9817.9m 5.334g 2968 S 10.4 2.1 1848:43 beam.


    For example, I'd like to see something like this (see %CPU(sy) and %CPU(us)):



    top - 18:11:58 up 9 days,  6:41, 17 users,  load average: 2.42, 2.38, 2.47
    Tasks: 2642 total, 4 running, 2638 sleeping, 0 stopped, 0 zombie
    %Cpu(s): 2.9 us, 0.8 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    KiB Mem: 26413387+total, 26355763+used, 576240 free, 233544 buffers
    KiB Swap: 8921084 total, 8920140 used, 944 free. 14931166+cached Mem

    PID USER PR NI VIRT RES SHR S %CPU(us) %CPU(sy) %MEM TIME+ COMMAND
    63209 postgres 20 0 0.101t 0.012t 0.012t R 100.0 1.0 5.0 389:44.92 postgres
    62356 postgres 20 0 0.101t 922336 886508 R 100.0 0.4 0.3 10:25.82 postgres
    2139 rabbitmq 20 0 9817.9m 5.334g 2968 S 10.4 0.2 2.1 1848:43 beam.









    share|improve this question

























      3












      3








      3








      On a Unix or Unix-like system, how do I view the percent CPU usage per process, split into user and system and other time categories? top shows me overall "sy", "us", "wa", etc for the entire computer or per core, but I don't see anything in the manual showing how to show those stats per process.



      To illustrate...
      top shows something like this:



      top - 18:11:58 up 9 days,  6:41, 17 users,  load average: 2.42, 2.38, 2.47
      Tasks: 2642 total, 4 running, 2638 sleeping, 0 stopped, 0 zombie
      %Cpu(s): 2.9 us, 0.8 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
      KiB Mem: 26413387+total, 26355763+used, 576240 free, 233544 buffers
      KiB Swap: 8921084 total, 8920140 used, 944 free. 14931166+cached Mem

      PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
      63209 postgres 20 0 0.101t 0.012t 0.012t R 100.0 5.0 389:44.92 postgres
      62356 postgres 20 0 0.101t 922336 886508 R 100.0 0.3 10:25.82 postgres
      2139 rabbitmq 20 0 9817.9m 5.334g 2968 S 10.4 2.1 1848:43 beam.


      For example, I'd like to see something like this (see %CPU(sy) and %CPU(us)):



      top - 18:11:58 up 9 days,  6:41, 17 users,  load average: 2.42, 2.38, 2.47
      Tasks: 2642 total, 4 running, 2638 sleeping, 0 stopped, 0 zombie
      %Cpu(s): 2.9 us, 0.8 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
      KiB Mem: 26413387+total, 26355763+used, 576240 free, 233544 buffers
      KiB Swap: 8921084 total, 8920140 used, 944 free. 14931166+cached Mem

      PID USER PR NI VIRT RES SHR S %CPU(us) %CPU(sy) %MEM TIME+ COMMAND
      63209 postgres 20 0 0.101t 0.012t 0.012t R 100.0 1.0 5.0 389:44.92 postgres
      62356 postgres 20 0 0.101t 922336 886508 R 100.0 0.4 0.3 10:25.82 postgres
      2139 rabbitmq 20 0 9817.9m 5.334g 2968 S 10.4 0.2 2.1 1848:43 beam.









      share|improve this question














      On a Unix or Unix-like system, how do I view the percent CPU usage per process, split into user and system and other time categories? top shows me overall "sy", "us", "wa", etc for the entire computer or per core, but I don't see anything in the manual showing how to show those stats per process.



      To illustrate...
      top shows something like this:



      top - 18:11:58 up 9 days,  6:41, 17 users,  load average: 2.42, 2.38, 2.47
      Tasks: 2642 total, 4 running, 2638 sleeping, 0 stopped, 0 zombie
      %Cpu(s): 2.9 us, 0.8 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
      KiB Mem: 26413387+total, 26355763+used, 576240 free, 233544 buffers
      KiB Swap: 8921084 total, 8920140 used, 944 free. 14931166+cached Mem

      PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
      63209 postgres 20 0 0.101t 0.012t 0.012t R 100.0 5.0 389:44.92 postgres
      62356 postgres 20 0 0.101t 922336 886508 R 100.0 0.3 10:25.82 postgres
      2139 rabbitmq 20 0 9817.9m 5.334g 2968 S 10.4 2.1 1848:43 beam.


      For example, I'd like to see something like this (see %CPU(sy) and %CPU(us)):



      top - 18:11:58 up 9 days,  6:41, 17 users,  load average: 2.42, 2.38, 2.47
      Tasks: 2642 total, 4 running, 2638 sleeping, 0 stopped, 0 zombie
      %Cpu(s): 2.9 us, 0.8 sy, 0.0 ni, 96.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
      KiB Mem: 26413387+total, 26355763+used, 576240 free, 233544 buffers
      KiB Swap: 8921084 total, 8920140 used, 944 free. 14931166+cached Mem

      PID USER PR NI VIRT RES SHR S %CPU(us) %CPU(sy) %MEM TIME+ COMMAND
      63209 postgres 20 0 0.101t 0.012t 0.012t R 100.0 1.0 5.0 389:44.92 postgres
      62356 postgres 20 0 0.101t 922336 886508 R 100.0 0.4 0.3 10:25.82 postgres
      2139 rabbitmq 20 0 9817.9m 5.334g 2968 S 10.4 0.2 2.1 1848:43 beam.






      top cpu-usage






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 4 '17 at 2:15









      sudosudo

      202313




      202313






















          1 Answer
          1






          active

          oldest

          votes


















          4














          you can have the statistics you want about a process by using this Command:



          pidstat -u -p <PID> 


          for example



          pidstat -u -p 2345





          share|improve this answer


























          • Yep, that works. I had to do pidstat -u -p <PID> on my system, but it probably depends on what version of the utility you have.

            – sudo
            Mar 5 '17 at 0:50











          • it's a great utility you can have an average value in the time for example :

            – Hamza Jabbour
            Mar 5 '17 at 7:55






          • 3





            pidstat -u -p <PID> 25 this will give you the avarage of CPU consemption by the process in 25 seconds

            – Hamza Jabbour
            Mar 5 '17 at 7:57











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f349042%2fget-separate-user-system-etc-cpu-usage-per-process%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          you can have the statistics you want about a process by using this Command:



          pidstat -u -p <PID> 


          for example



          pidstat -u -p 2345





          share|improve this answer


























          • Yep, that works. I had to do pidstat -u -p <PID> on my system, but it probably depends on what version of the utility you have.

            – sudo
            Mar 5 '17 at 0:50











          • it's a great utility you can have an average value in the time for example :

            – Hamza Jabbour
            Mar 5 '17 at 7:55






          • 3





            pidstat -u -p <PID> 25 this will give you the avarage of CPU consemption by the process in 25 seconds

            – Hamza Jabbour
            Mar 5 '17 at 7:57
















          4














          you can have the statistics you want about a process by using this Command:



          pidstat -u -p <PID> 


          for example



          pidstat -u -p 2345





          share|improve this answer


























          • Yep, that works. I had to do pidstat -u -p <PID> on my system, but it probably depends on what version of the utility you have.

            – sudo
            Mar 5 '17 at 0:50











          • it's a great utility you can have an average value in the time for example :

            – Hamza Jabbour
            Mar 5 '17 at 7:55






          • 3





            pidstat -u -p <PID> 25 this will give you the avarage of CPU consemption by the process in 25 seconds

            – Hamza Jabbour
            Mar 5 '17 at 7:57














          4












          4








          4







          you can have the statistics you want about a process by using this Command:



          pidstat -u -p <PID> 


          for example



          pidstat -u -p 2345





          share|improve this answer















          you can have the statistics you want about a process by using this Command:



          pidstat -u -p <PID> 


          for example



          pidstat -u -p 2345






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 1 hour ago









          arielf

          528510




          528510










          answered Mar 4 '17 at 12:33









          Hamza JabbourHamza Jabbour

          42127




          42127













          • Yep, that works. I had to do pidstat -u -p <PID> on my system, but it probably depends on what version of the utility you have.

            – sudo
            Mar 5 '17 at 0:50











          • it's a great utility you can have an average value in the time for example :

            – Hamza Jabbour
            Mar 5 '17 at 7:55






          • 3





            pidstat -u -p <PID> 25 this will give you the avarage of CPU consemption by the process in 25 seconds

            – Hamza Jabbour
            Mar 5 '17 at 7:57



















          • Yep, that works. I had to do pidstat -u -p <PID> on my system, but it probably depends on what version of the utility you have.

            – sudo
            Mar 5 '17 at 0:50











          • it's a great utility you can have an average value in the time for example :

            – Hamza Jabbour
            Mar 5 '17 at 7:55






          • 3





            pidstat -u -p <PID> 25 this will give you the avarage of CPU consemption by the process in 25 seconds

            – Hamza Jabbour
            Mar 5 '17 at 7:57

















          Yep, that works. I had to do pidstat -u -p <PID> on my system, but it probably depends on what version of the utility you have.

          – sudo
          Mar 5 '17 at 0:50





          Yep, that works. I had to do pidstat -u -p <PID> on my system, but it probably depends on what version of the utility you have.

          – sudo
          Mar 5 '17 at 0:50













          it's a great utility you can have an average value in the time for example :

          – Hamza Jabbour
          Mar 5 '17 at 7:55





          it's a great utility you can have an average value in the time for example :

          – Hamza Jabbour
          Mar 5 '17 at 7:55




          3




          3





          pidstat -u -p <PID> 25 this will give you the avarage of CPU consemption by the process in 25 seconds

          – Hamza Jabbour
          Mar 5 '17 at 7:57





          pidstat -u -p <PID> 25 this will give you the avarage of CPU consemption by the process in 25 seconds

          – Hamza Jabbour
          Mar 5 '17 at 7:57


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f349042%2fget-separate-user-system-etc-cpu-usage-per-process%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          CARDNET

          Boot-repair Failure: Unable to locate package grub-common:i386

          濃尾地震