From owner-freebsd-questions@FreeBSD.ORG Mon Sep 18 14:42:15 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CEF516A416 for ; Mon, 18 Sep 2006 14:42:15 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 43F4B43D6D for ; Mon, 18 Sep 2006 14:42:07 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.6/8.13.6) id k8IEg642024143; Mon, 18 Sep 2006 09:42:06 -0500 (CDT) (envelope-from dan) Date: Mon, 18 Sep 2006 09:42:06 -0500 From: Dan Nelson To: Paul Hoffman Message-ID: <20060918144206.GG55663@dan.emsphone.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 6.1-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.13 (2006-08-11) Cc: freebsd-questions@freebsd.org Subject: Re: Getting a specific value from netstat X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Sep 2006 14:42:15 -0000 In the last episode (Sep 17), Paul Hoffman said: > Greetings again. If I do a 'netstat -I em0 -b', I get: > > Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll > em0 1500 00:0e:0c:67:c8:04 93555198 0 2179562966 114493253 0 723565977 0 > em0 1500 fe80:1::20e:c fe80:1::20e:cff:f 0 - 0 4 - 288 - > em0 1500 192.245.12 Balder-227 35399016 - 1770283188 114484197 - 3415268168 - > em0 1500 192.245.12.22 Balder-228 27063120 - 1655024896 0 - 0 - > em0 1500 192.245.12.22 Balder-229 47427840 - 3954775975 18975500 - 2445620452 - > > What I care about is the number of input and output bytes (in this > case, 2179562966 and 723565977). I can write a short Perl script to > parse the netstat output, but I would rather just get the numbers > directly from the OS. Are these values available without going > through netstat? If you use the same code netstat does, yes :) It looks like per-interface stats are still obtained by grovelling through /dev/kmem, though, so it may be easier to just parse netstat's output. Another alternative would be to install net-snmp and ask it for the stats. -- Dan Nelson dnelson@allantgroup.com