From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 8 17:04:51 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0288FD91 for ; Fri, 8 Aug 2014 17:04:51 +0000 (UTC) Received: from mx1.scaleengine.net (beauharnois2.bhs1.scaleengine.net [142.4.218.15]) by mx1.freebsd.org (Postfix) with ESMTP id CFDFA2DC9 for ; Fri, 8 Aug 2014 17:04:50 +0000 (UTC) Received: from [192.168.1.2] (senat1-01.HML3.ScaleEngine.net [209.51.186.5]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id 63D0937802 for ; Fri, 8 Aug 2014 17:04:49 +0000 (UTC) Message-ID: <53E50347.9050206@freebsd.org> Date: Fri, 08 Aug 2014 13:05:11 -0400 From: Allan Jude User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Subject: Re: disk and NIC io statistics via sysctl References: <20140808184021.537feca9b15e3a261ea27fa7@systemdatarecorder.org> <1407515358.56408.374.camel@revolution.hippie.lan> In-Reply-To: <1407515358.56408.374.camel@revolution.hippie.lan> X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="an0ffcWd34E6W8B0AJeTWj207CHANw89X" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Aug 2014 17:04:51 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --an0ffcWd34E6W8B0AJeTWj207CHANw89X Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2014-08-08 12:29, Ian Lepore wrote: > On Fri, 2014-08-08 at 18:40 +0300, Stefan Parvu wrote: >> Hi,=20 >> >> Fetching CPU and Memory statistics, using sysctl interface and perl se= ems nice and easy. >> I made great progress with sysrec a generic recorder reporting: cpu me= m disk and nic=20 >> stats on FreeBSD. Now Im getting into disk and nic sections: >> >> 1. Disk=20 >> Im able to get a list of all disks on a system using kern.disks sysctl= variable. >> I want to be able to report per disk something like: >> >> readreq rate read requests per second, rate >> writereq rate write requests per second, rate >> totreq rate total read + write requests per second, rate >> readbyt rate read bytes per second, in KB, rate >> writebyt rate write bytes per second, in KB, rate >> totbyt rate total read + write bytes per second, in KB, rate=20 >> >> iostat seems the simplest way to fetch these, but how about sysctl int= erface ? >> I could not figure out any sysctl parameters for disk throughput. How = one will=20 >> fetch throughput per disk via sysctl ?=20 >> >> >> 2. NIC >> Same will go for network card interfaces. I want to fetch per NIC thro= ughput and >> errors via sysctl, something like these: >> >> 1 timestamp time seconds since Epoch >> 2 interface number NIC name, string >> 3 rxKB rate the number of KBytes received per sec >> 4 rxpcks rate the no. of packets received per sec >> 5 rxerrs rate the number of errors while received packets per sec >> 6 rxdrop rate the number of packets that were dropped per sec >> 7 rxfifo rate the number of FIFO overruns on received packets per s= ec >> 8 rxframe rate the number of carrier errors on received packet per = sec >> 9 rxcompr rate the number of compressed packets received per sec >> 10 rxmulti rate the number of multicast packets received per sec >> 11 txKB rate the number of KBytes transmitted per sec >> 12 txpcks rate the number of packets transmitted per sec >> 13 txerrs rate the number of errors transmitting packets per sec >> 14 txdrop rate the number of packets that were dropped per sec >> 15 txfifo rate the number of FIFO overruns on transmitted packets p= er sec >> 16 txcolls rate the number of collisions that were detecte per sec >> 17 txcarr rate the number of carrier errors on transmitted packets = per sec >> 18 txcompr rate the number of compressed packets transmitted per se= c >> 19 ttpcks rate the total number of packets (received + transmitted)= per sec >> 20 ttKB rate the total number of KBytes (received + transmitted) pe= r sec=20 >> >> >> Any ideas ? >> >> Many thanks, >> >=20 > All of this series of questions you've been asking really have the same= > answer: look at the source code for the very apps you cite as examples= > of outputting the info you want, and do what they do. There are no > magic secret kernel backdoor interfaces, all these userland tools are > using documented interfaces such as sysctl to get their info. (There > may be a few miscreants that open /dev/kmem and rudely poke around in > kernel memory, but I'm not sure we have any of them in base. The lsof > tool in ports is one that comes to mind for that.) >=20 > In addition to the tools you've already mentioned that have the info yo= u > want, have a look at gstat for IO stats, netstat for net throughput, an= d > systat for lots of stuff. >=20 > -- Ian >=20 >=20 > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.o= rg" >=20 I often use net/nload from ports to monitor interfaces, it may be helpful as well. --=20 Allan Jude --an0ffcWd34E6W8B0AJeTWj207CHANw89X Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJT5QNJAAoJEJrBFpNRJZKfoo4P/09cqFl8U5tU6Ua1ccjvA8Gp ADD7NiLbRR8gq5xhHWTPNYY5LGsaT34PWXqlArxq4Hx/DCDsor15kY1UnVGyFh1+ IR4sCHHoZOYmdx9SS7zqJKBTp/6nYYS5a8DpPXIm2JS3IFnIcPrmZWviRWUCglNj XrrKlApqrBNOq8oZTBt1Oyum8WTdblfsLVS84ucJy31jk/gPIPX0xJS7VecuNWkz c484Kk/cLWyzz9Cb1Mq2ikWAs1nFCC8DSWdEu0OiowRlKLreDVZJC9j8qlpUMcsl zeUvBw7TRsHqi9gLOLhv0YHnLeeFe1wvVwbTFhKgdssvu/YpZDOlBDvJBz75MVJR 2wdXRhF3Uqf/cd3nXCXrIKedwj4nIDBOxNo60UK/M3fW6QooYo14vDwzQgjryZIP NyQFHIjixuHSZOY/1eOhqkVMBhnaLZFDCfxDp6ES9MVSHg34Mkh7j9CB3yzF148K Bjuzon3N/XfMH3It4kaqKiJL6k7P+XksDrcDcfHT6yIVEq1u3+HnG5tNB+ktmK7g SUtDcXTIb4aAevDYuVVXsRgt4tWclrvmTWuDM7buBb7oAhOmmEgo8g52b8R3Dt9w UCbqDjQRe4r3K4iY7dMz68LtLjBkykq0Ad7SMa2BuPgjGUWJlcV3C5IaEr4DmEKr lzfi23p1WsIZduBHs04P =xuDu -----END PGP SIGNATURE----- --an0ffcWd34E6W8B0AJeTWj207CHANw89X--