Hi list, I'm trying to get device IO status (i.e. read and written bytes) by using the devstat interface, and I wrote this small program (mostly inspired by the gkrellm2 port freebsd.c system-dependent module).
#include <stdio.h> #include <stdlib.h> #include <strings.h> #include <sys/resource.h> #include <devstat.h> #define MB ((double)(1024.0 * 1024.0)) int main(void) { int curr_dev, nof_devs, nof_selected, nof_selections; int max_devs = 256; long sel_gen; struct statinfo si; struct devinfo di; struct device_selection *ds = NULL; si.dinfo = malloc(sizeof(struct devinfo)); bzero(si.dinfo, sizeof(struct devinfo)); if(devstat_getdevs(NULL, &si) < 0) return (-1); nof_devs = si.dinfo->numdevs; if(devstat_selectdevs(&ds, &nof_selected, &nof_selections, &sel_gen, si.dinfo->generation, si.dinfo->devices, nof_devs, NULL, 0, NULL, 0, DS_SELECT_ONLY, max_devs, 1) < 0) return (-1); printf("NAME\tIN\tOUT\n"); for(curr_dev = 0; curr_dev < nof_devs; curr_dev++) { struct devstat *d_stat; d_stat = &si.dinfo->devices[ds[curr_dev].position]; printf("%s%d\t%.2lf MB\t%.2lf MB\n", d_stat->device_name, d_stat->unit_number, d_stat->bytes[1] / d_stat->block_size / MB, d_stat->bytes[2] / d_stat->block_size / MB); } free(si.dinfo); return (0); } I compile it by gcc -ggdb -ldevstat -o iostat iostat.c and run it: >./iostat NAME IN OUT ad0 9.02 MB 9.65 MB Now, I suppose that those two numbers represent the amount of IO generated within some time slice, but I can't find any documentation on it... Could anyone explain it to me? Thank you in advance! -- Pietro Cerutti PGP Public Key: http://gahr.ch/pgp
signature.asc
Description: OpenPGP digital signature