- Runs on lots of machines;
- machines may be heavily loaded;
- Sometimes the kick-off time is delayed beyond a 1-minute standard (typically due to load);
- I don't like having long-running subprocesses: they might stop/fail and I'd have to restart, they use memory, etc.;
- I'm doing this in Python;
- I can store state between runs in a pickle file;
- I want to replicate the existing fields coming out of vmstat -s and iostat -x -D n (where n is number of seconds of sample size);
- I want the values of these fields to match likewise.
Problem 1: Where is the source code for iostat.c ? In ubuntu at least (hoping RHEL / CENTOS is similar) it turns out it's in the sysstat package. I found systat source at: http://freecode.com/projects/sysstat.
Inside this package, there's source code for iostat as a file named iostat.c. I have yet to find it online, so here it is:
- Read current values from /proc/stats, /proc/diskstats, and vmstat -s
- read values from previous run from disk
- find diffs
- use diffs to compute values needed
- write current values to disk for next time.