Click to See Complete Forum and Search --> : CPU details programmaticaly


codemasterpl
08-10-2009, 08:08 AM
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 ?

ph34r
08-11-2009, 12:34 PM
Take a look at the kernel code that generates the info in the /proc directory ...

happybunny
08-11-2009, 10:01 PM
dmidecode?

bwkaz
08-19-2009, 01:50 AM
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. :)

Icarus
08-19-2009, 10:25 AM
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!