1 Reply Latest reply: Dec 7, 2009 7:59 AM by 807559 RSS

    How to watch CPU usage of a long running process?

    807559
      Hi Gurus,

      I have a daemon type process that handles transactions. The transactions typically completes in less than a second. I would like to find out the CPU usage of the transactions. I am looking for something that allow me to watch the CPU usage of a process so that I can look for a spike when the transaction happens.

      Regular monitoring tools do not go down to sub-second granularity and cannot track specific process. Is there any Dtrace script for the job?

      Thanks,
      Anthony
        • 1. Re: How to watch CPU usage of a long running process?
          807559
          I am a newbie with dtrace, but I think that this might work.

          Start the script with script.d -c "demon args"

          The script would be of the type
          #!/usr/sbin/dtrace -s
          #pragma D option quiet
          pid$target:demon::entry
          /probefunc == transproc/
          {
              self->ts[probefunc] = timestamp;
          }
          
          pid$target:demon::return
          /self->ts[probefunc]/
          {
              @func_time[probefunc] = sum(timestamp - self->ts[probefunc]);
          }