From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 29 18:52:30 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64B0616A417 for ; Tue, 29 Jan 2008 18:52:30 +0000 (UTC) (envelope-from gahr@gahr.ch) Received: from cpanel03.rubas-s03.net (cpanel03.rubas-s03.net [195.182.222.73]) by mx1.freebsd.org (Postfix) with ESMTP id EC73013C4CE for ; Tue, 29 Jan 2008 18:52:29 +0000 (UTC) (envelope-from gahr@gahr.ch) Received: from 80-218-191-236.dclient.hispeed.ch ([80.218.191.236] helo=gahrtop.localhost) by cpanel03.rubas-s03.net with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1JJvZM-0007V0-Kk for freebsd-hackers@freebsd.org; Tue, 29 Jan 2008 19:52:28 +0100 Message-ID: <479F75D9.4070301@gahr.ch> Date: Tue, 29 Jan 2008 19:52:09 +0100 From: Pietro Cerutti User-Agent: Thunderbird 2.0.0.9 (X11/20071121) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org X-Enigmail-Version: 0.95.5 OpenPGP: id=9571F78E; url=http://www.gahr.ch/pgp Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig06CC06C773D5BA35D2A317E5" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel03.rubas-s03.net X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gahr.ch X-Source: X-Source-Args: X-Source-Dir: Subject: struct devstat's bytes[] meaning X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2008 18:52:30 -0000 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 #include #include #include #include #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--