Find the answer to your Linux question:
Results 1 to 7 of 7
Hi All, I am trying to figure out, is there an api or a command that gives me load taken by each core on a multi core machine ? Basically ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    who
    who is offline
    Just Joined!
    Join Date
    Apr 2012
    Location
    Seattle, WA
    Posts
    12

    Calculating load on each core??


    Hi All,

    I am trying to figure out, is there an api or a command that gives me load taken by each core on a multi core machine ? Basically I want to check the load exerted by a particular thread.

    I am writing this application which does dynamic load balancing on a multi core machine, among threads.

    I tried using the OperatingSystemMXBean.getSystemLoadAverage() method but this api returns cumulative load of all cores and processors on the machine

    Any other ideas to check load for a given thread is highly appreciated...

    Thanks in advance.

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,318
    you could do this in a simplistic fashion, but quickly, with top or ps. However, the mpstat is probably right up your ally, read the man page for info/details.

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,175
    You can also use the sar command, which if configured properly, will regularly get CPU and other performance stats from /proc and put them in an easy-to-access form.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. #4
    who
    who is offline
    Just Joined!
    Join Date
    Apr 2012
    Location
    Seattle, WA
    Posts
    12
    Quote Originally Posted by atreyu View Post
    you could do this in a simplistic fashion, but quickly, with top or ps. However, the mpstat is probably right up your ally, read the man page for info/details.
    So I tried to use the top -u <username> -H and this does show me the threads in a particular process but it does not show me the thread id I guess so I still don't have a way to check which particular thread is exerting how much load ?

    Quote Originally Posted by Rubberman View Post
    You can also use the sar command, which if configured properly, will regularly get CPU and other performance stats from /proc and put them in an easy-to-access form.
    I have fedora os and I am not able to find the sar command ? it says comand not found...

  5. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,175
    The sar command is part of the sysstat package. Install that and you should get sar as well.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #6
    who
    who is offline
    Just Joined!
    Join Date
    Apr 2012
    Location
    Seattle, WA
    Posts
    12
    Quote Originally Posted by Rubberman View Post
    The sar command is part of the sysstat package. Install that and you should get sar as well.
    I tried sar command .. but that still gives me a load of all processors..

    is there a way to find a thread id at the OS level ? using a command on linux prompt ?

  7. #7
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,175
    You need to use the -A option for sar to see for each processor, otherwise you get get the aggregate stats. Read the sar man page. It is quite thorough of the options and what they do.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •