From owner-freebsd-jail@FreeBSD.ORG Wed Jun 3 23:03:08 2009 Return-Path: Delivered-To: freebsd-jail@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D0031065715 for ; Wed, 3 Jun 2009 23:03:08 +0000 (UTC) (envelope-from lists@c0mplx.org) Received: from home.opsec.eu (home.opsec.eu [IPv6:2001:14f8:200::1]) by mx1.freebsd.org (Postfix) with ESMTP id 4EAEC8FC19 for ; Wed, 3 Jun 2009 23:03:08 +0000 (UTC) (envelope-from lists@c0mplx.org) Received: from pi by home.opsec.eu with local (Exim 4.69 (FreeBSD)) (envelope-from ) id 1MBzUA-000Dmm-Rj; Thu, 04 Jun 2009 01:03:06 +0200 Date: Thu, 4 Jun 2009 01:03:06 +0200 From: Kurt Jaeger To: "Marc G. Fournier" Message-ID: <20090603230306.GF10978@home.opsec.eu> References: <20090603180221.E56412@hub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090603180221.E56412@hub.org> Cc: freebsd-jail@freebsd.org Subject: Re: Calculating per jail memory usage ... X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2009 23:03:09 -0000 Hi! > Are there any tools for this that are either in ports, or others would > like to share? This perl snippet works pretty good: # return memory/proc usage per jail and system sub vmem { my(@res); my($i); my($ip); my(@t); @res = `/bin/ps ax -o 'pid,jid,rss,vsz,args' 2>&1`; shift(@res); foreach $i (@res) { $i = " ".$i; @t=split(/ +/,$i); # print "i: $i t1: $t[2]\n"; $jproc{$t[2]}++; $jrealm{$t[2]} += $t[3]; $jvirtm{$t[2]} += $t[4]; } foreach $i (keys(%running)) { $ip=$vs2ip{$i}; if ( defined($jproc{$ip2jid{$ip}}) ) { $runproc{$i} = $jproc{$ip2jid{$ip}} - 1 } else { $runproc{$i} = 0; } $runrealm{$i} = $jrealm{$ip2jid{$ip}}; $runvirtm{$i} = $jvirtm{$ip2jid{$ip}}; } } -- pi@opsec.eu +49 171 3101372 11 years to go !