From owner-freebsd-questions@FreeBSD.ORG Tue Aug 15 17:24:20 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 7D14616A4DA for ; Tue, 15 Aug 2006 17:24:20 +0000 (UTC) (envelope-from chad@shire.net) Received: from hobbiton.shire.net (mail.shire.net [166.70.252.250]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4B6AA43D6D for ; Tue, 15 Aug 2006 17:24:19 +0000 (GMT) (envelope-from chad@shire.net) Received: from [67.171.127.191] (helo=[192.168.99.68]) by hobbiton.shire.net with esmtpa (Exim 4.51) id 1GD2eI-0005yY-DU; Tue, 15 Aug 2006 11:24:18 -0600 In-Reply-To: <6C0CF58A187DA5479245E0830AF84F421D108E@poweredge.attiksystem.ch> References: <6C0CF58A187DA5479245E0830AF84F421D108E@poweredge.attiksystem.ch> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: "Chad Leigh -- Shire.Net LLC" Date: Tue, 15 Aug 2006 11:24:13 -0600 To: Philippe Lang X-Mailer: Apple Mail (2.752.2) X-SA-Exim-Connect-IP: 67.171.127.191 X-SA-Exim-Mail-From: chad@shire.net X-SA-Exim-Scanned: No (on hobbiton.shire.net); SAEximRunCond expanded to false Cc: freebsd-questions Questions Subject: Re: Cacti & FreeBSD Jail CPU & RAM monitoring 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: Tue, 15 Aug 2006 17:24:20 -0000 On Aug 15, 2006, at 9:16 AM, Philippe Lang wrote: > Hi, > > Based on answers of my first post, I wrote a small perl script in > order to find out the CPU and MEMORY used by each jail. > Here it is: > > ------------------------------------------------------ > - jls.ps > ------------------------------------------------------ > #!/usr/bin/perl > @jails = `jls`; > $title = shift @jails; > chomp $title; > print $title . "\t\t%CPU\t%MEM\n"; > foreach (@jails) > { > my ($jid) = /\s+(\S+)\s/; > @jexec = `jexec $jid ps -afxu`; > > @mem = map {/\S+\s+\S+\s+\S+\s+(\S+)\s/} @jexec; > shift @mem; > $tot_mem = 0; > foreach (@mem) { $tot_mem = $tot_mem + $_; } > > @cpu = map {/\S+\s+\S+\s+(\S+)\s/} @jexec; > shift @cpu; > $tot_cpu = 0; > foreach (@cpu) { $tot_cpu = $tot_cpu + $_; } > > chomp $_; > print $_ . "\t$tot_cpu\t$tot_mem\n"; > } > ------------------------------------------------------ What are the units on the MEM? Chad --- Chad Leigh -- Shire.Net LLC Your Web App and Email hosting provider chad at shire.net