CPU details programmaticaly


Results 1 to 5 of 5

Thread: CPU details programmaticaly

  1. #1
    Join Date
    Aug 2009
    Location
    Krakow, Poland
    Posts
    1

    Angry CPU details programmaticaly

    Hello everyone,
    i'm trying to figure out how to obtain:

    - mhz
    - cpu usage
    - /proc/cpuinfo details

    programatically without parsing /proc/* at all.

    Some details might be taken via asm, sysinfo...

    i am willing to write a small code for my agent that would print those details by using system calls - rather than parsing the files on the fs.

    Any idea ?

  2. #2
    Join Date
    Sep 1999
    Posts
    3,202
    Take a look at the kernel code that generates the info in the /proc directory ...

  3. #3
    Join Date
    Jan 2004
    Location
    boston, mass USA
    Posts
    1,878
    dmidecode?

  4. #4
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    Why?

    Seriously -- it's trivial to parse these files (especially with something like grep + sed, or perl, or whatever). It's really really hard to figure out this information from userspace. Since the kernel already exports it, just use what you already have!

    Unless, of course, it's a homework assignment to do it the other way. (It doesn't sound quite like one, but given the specificity, it might be.) In that case, ask whoever assigned it to you for some help.

  5. #5
    Join Date
    Aug 2001
    Location
    Somewhere, Texas
    Posts
    9,627
    I agree with bwkaz, something smells like textbook. Expecially when that's what /proc is for.
    asm for finding CPU values? Talk about going to the long way!

Tags for this Thread

Posting Permissions

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