3 Replies Latest reply on Sep 2, 2015 8:50 AM by PeteB

    Log CPU usage of a process


      I need to log the CPU usage of a process (PID known). I tried using 'top' and 'ps' commands with '-p $pid' option. I get an error  'invalid option p'. Is there a way to install complete package of top or ps programs? Or Is there other program in Edison with which we can log resource usage by a process? 

        • 1. Re: Log CPU usage of a process
          Steven Moy

          To install a more detail ps, there is a thread that may interest you: Standard "ps" not BusyBox?

          • 2. Re: Log CPU usage of a process

            Hi krag,


            Right now I’m using the ps command that comes by default with the image. I’ll try to install a newer version to see if I’m able to use the additional features of the ps command. I’m not sure if this would help you, but you use the ps command along with grep to filter your results. It might not be the most practical way to do it, but it can be helpful.


            You can also check stevenmoy's suggestion. Maybe you'll find the answer you're looking for in that thread.




            • 3. Re: Log CPU usage of a process

              If you know the PID, you could just write a bash script to read /proc/$pid/stat, and get some of the values out of there. This could then be easily parsed either on the edison or elsewhere at a later date. Sorry, I don't have mine booted, but I think you are looking for the following items in the space separated list.


              #14 - utime

              #15 - stime

              #22 - startime


              These can be divided by the TICK interval to get the actual clock time the process consumed.


              Google proc pid stat, and hit up the first stackoverflow result which has a good description as well.