From owner-freebsd-questions@FreeBSD.ORG Tue Aug 15 17:47:43 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 88E7C16A4DE for ; Tue, 15 Aug 2006 17:47:43 +0000 (UTC) (envelope-from philippe.lang@attiksystem.ch) Received: from mail.attiksystem.ch (f29.attiksystem.ch [212.147.59.29]) by mx1.FreeBSD.org (Postfix) with ESMTP id C3B4643D7C for ; Tue, 15 Aug 2006 17:47:42 +0000 (GMT) (envelope-from philippe.lang@attiksystem.ch) Received: from poweredge.attiksystem.ch (poweredge.attiksystem.ch [10.0.0.29]) by mail.attiksystem.ch (8.12.11/8.12.11) with ESMTP id k7FHleOw002734; Tue, 15 Aug 2006 19:47:40 +0200 (CEST) (envelope-from philippe.lang@attiksystem.ch) MIME-Version: 1.0 Date: Tue, 15 Aug 2006 19:47:40 +0200 Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=SHA1; boundary="----=_NextPart_000_0000_01C6C0A3.A89EA7D0" Content-class: urn:content-classes:message Message-ID: <6C0CF58A187DA5479245E0830AF84F421D108F@poweredge.attiksystem.ch> X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: Cacti & FreeBSD Jail CPU & RAM monitoring Thread-Index: AcbAj8/GMT1mxUB8SMKsInfme9gsfgAAmJ6Q From: "Philippe Lang" To: "Chad Leigh -- Shire.Net LLC" X-Spam-Score: -1.44 () ALL_TRUSTED X-Scanned-By: MIMEDefang 2.49 on 10.0.0.111 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:47:43 -0000 This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C6C0A3.A89EA7D0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit owner-freebsd-questions@freebsd.org wrote: > 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? Hi, Just like for a "ps -u", but it's here the sum of the percentages of all the processes owned by the jail. The same for %CPU. This might not be very accurate, but it gives a very good idea of which jails are using a lot of memory or cpu. --------------- Philippe Lang Attik System ------=_NextPart_000_0000_01C6C0A3.A89EA7D0 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIII/zCCAocw ggHwoAMCAQICEEdYYafa1wkm0CP4DOffAiswDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd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