From owner-freebsd-hackers@freebsd.org Fri Jan 22 18:36:38 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0F31A8D478 for ; Fri, 22 Jan 2016 18:36:38 +0000 (UTC) (envelope-from Mark.Martinec+freebsd@ijs.si) Received: from mail.ijs.si (mail.ijs.si [IPv6:2001:1470:ff80::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5CC781142 for ; Fri, 22 Jan 2016 18:36:38 +0000 (UTC) (envelope-from Mark.Martinec+freebsd@ijs.si) Received: from amavis-ori.ijs.si (localhost [IPv6:::1]) by mail.ijs.si (Postfix) with ESMTP id 3pn8SM248dz1Y9 for ; Fri, 22 Jan 2016 19:36:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ijs.si; h= user-agent:message-id:references:in-reply-to:organization :subject:subject:from:from:date:date:content-transfer-encoding :content-type:content-type:mime-version:received:received :received:received; s=jakla4; t=1453487792; x=1456079793; bh=Tia BspwjhWS5C3sbbxIfZQ5p9I8K4Ko0iUnJfBCPkm4=; b=NPr9ThcThoOrrvUXAZ4 jdCFX0L3oGn0/k4+uVFlDtvdbD2TZ6AkIdwhww7gUNUX2iIIp2yc0px46e6ICneL zFVoqyq0+mY0MLSGW5Aki/9jB524GG1l7Ej41X1/CHNeBFtSnRhgdHGOyjASe23j wjUMyl6vrJsHsZ7WF1Fp3/Uw= X-Virus-Scanned: amavisd-new at ijs.si Received: from mail.ijs.si ([IPv6:::1]) by amavis-ori.ijs.si (mail.ijs.si [IPv6:::1]) (amavisd-new, port 10026) with LMTP id CRHqWUuSFxey for ; Fri, 22 Jan 2016 19:36:32 +0100 (CET) Received: from mildred.ijs.si (mailbox.ijs.si [IPv6:2001:1470:ff80::143:1]) by mail.ijs.si (Postfix) with ESMTP id 3pn8SJ2Wpgz1Y8 for ; Fri, 22 Jan 2016 19:36:30 +0100 (CET) Received: from nabiralnik.ijs.si (nabiralnik.ijs.si [IPv6:2001:1470:ff80::80:16]) by mildred.ijs.si (Postfix) with ESMTP id 3pn8SG3hZpz1Xn for ; Fri, 22 Jan 2016 19:36:30 +0100 (CET) Received: from neli.ijs.si (2001:1470:ff80:88:21c:c0ff:feb1:8c91) by webmail.ijs.si with HTTP (HTTP/1.1 POST); Fri, 22 Jan 2016 19:36:30 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 22 Jan 2016 19:36:30 +0100 From: Mark Martinec To: freebsd-hackers@freebsd.org Subject: RE: get number of open files in a process? Organization: Jozef Stefan Institute In-Reply-To: <8ca419f8820c4280a81f03102c7c0372@hioexcmbx08-prd.hq.netapp.com> References: <20160121153636.GA10961@britannica.bec.de> <20160121161637.GA83843@night.db.net> <20160121162527.GA11600@britannica.bec.de> <20160121191308.GA21869@dft-labs.eu> <31126442b7d347c5976a57aabc2e5792@hioexcmbx08-prd.hq.netapp.com> <20160121224511.GA74045@stack.nl> <20160121225111.GB21869@dft-labs.eu> <8ca419f8820c4280a81f03102c7c0372@hioexcmbx08-prd.hq.netapp.com> Message-ID: <8a32fa24128e9def077522b1ea0414e6@mailbox.ijs.si> X-Sender: Mark.Martinec+freebsd@ijs.si User-Agent: Roundcube Webmail/1.1.4 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jan 2016 18:36:38 -0000 On 2016-01-22 00:14, Batutis, Ed wrote: >> I'm still not convinced the approach here (of checking fds) is the >> right one >> to take - you have to have a very big reserve to not suddenly run out >> of fds, >> one would just limit amount of clients and, well, handle errors as >> they can >> pop up for reasons other than running out of fd slots. > > I have a large reserve - usually more than 1000 fd slots. But > occasionally something happens and the process runs out. There are a > lot of different things going on in the process in terms of fd usage. > So, finding the issue could be easier if I know when the number > started rising to an unusual level. And I can possibly find the root > cause more easily if I stop doing some things when this happens. I can > monitor memory usage and CPU usage easily enough, but I could not > figure out how to monitor fd usage. There are other approaches, yes. > But I was looking for something simple but useful until additional > effort could be expended on other approaches. I imagine that instrumenting opens, closes, dups and the like with dtrace would be able to do the job: increment a count when a new fd pops up, decrement on close, and you may end up with a diagram of fd usage over time. Or track each operation dealing with file descriptors individually. Msrk