Parse /proc/xxx or are there direct kernel structures?

Parse /proc/xxx or are there direct kernel structures?

Post by Mike Perc » Mon, 22 Jan 2001 05:01:49



Not trying to reinvent the wheel, but I need to capture some of the system
status and export them periodically to a remote machine. Should this be done by
parsing the various /proc files or is there some direct access api? I've been
looking at top source code, and source code for libproc. These are not exactly
clear to the un-initiated.

Also, is there any way to get data on I/O per process? /proc/partitions shows
breakdown by spindle and by partition, but we're kinda interested in per
process. For that matter, I'm not certain I understand all the columns in
/proc/partitions?

Guess I'll head off to the Microcenter and pick up a book if necessary--any
recommendations?

--
"Each game of chess means there's one less variation left to be played.
Each day got through means one or two less mistakes remain to be made."
Seen on the net: "Microsoft is to computers as McDonalds is to food"

 
 
 

Parse /proc/xxx or are there direct kernel structures?

Post by Juha Laih » Tue, 23 Jan 2001 05:45:19



Quote:>Not trying to reinvent the wheel, but I need to capture some of the system
>status and export them periodically to a remote machine. Should this be done by
>parsing the various /proc files or is there some direct access api? I've been
>looking at top source code, and source code for libproc. These are not exactly
>clear to the un-initiated.

I'd recommend /proc; that's provided as the primary API to use.
Unfortunately I cannot answer the rest of your questions, except

Quote:>Guess I'll head off to the Microcenter and pick up a book if necessary--any
>recommendations?

Look out for outdated books. /proc appears still to be a moving target,
i.e. is developing at least in some parts at a rate too fast for any
paper media to keep up with.

As you're looking for per-process I/O statistics, though, I'd assume these
are collected to the per-process statistis (/proc/PID/?), if anywhere. My
guess would've been /proc/PID/stat, but I went digging through the kernel
code and found (function get_stat in fs/proc/array.c) that the guess was
wrong. Now I'm beginning to suspect that per-process I/O isn't summarized
anywhere.
--
Wolf  a.k.a.  Juha Laiho     Espoo, Finland

         !M V PS(+) PE Y+ PGP(+) t- 5? !X R tv--- b+ DI? D G e+ h--- r+++ y+
"...cancel my subscription to the resurrection!" (Jim Morrison)