Date: Tue, 29 Jan 2008 19:52:09 +0100 From: Pietro Cerutti <gahr@gahr.ch> To: freebsd-hackers@freebsd.org Subject: struct devstat's bytes[] meaning Message-ID: <479F75D9.4070301@gahr.ch>
next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig06CC06C773D5BA35D2A317E5
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
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 =3D 256;
long sel_gen;
struct statinfo si;
struct devinfo di;
struct device_selection *ds =3D NULL;
si.dinfo =3D malloc(sizeof(struct devinfo));
bzero(si.dinfo, sizeof(struct devinfo));
if(devstat_getdevs(NULL, &si) < 0)
return (-1);
nof_devs =3D 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 =3D 0; curr_dev < nof_devs; curr_dev++)
{
struct devstat *d_stat;
d_stat =3D &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!
--=20
Pietro Cerutti
PGP Public Key:
http://gahr.ch/pgp
--------------enig06CC06C773D5BA35D2A317E5
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (FreeBSD)
iD8DBQFHn3XewMJqmJVx944RCgtQAJ97DezjbjCoQkhEIwo9eQLX/g+GYgCgkvKx
abordeaXhLORN3ZbjVgktKY=
=zfdQ
-----END PGP SIGNATURE-----
--------------enig06CC06C773D5BA35D2A317E5--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?479F75D9.4070301>
