Date: Tue, 15 Aug 2006 11:24:13 -0600 From: "Chad Leigh -- Shire.Net LLC" <chad@shire.net> To: Philippe Lang <philippe.lang@attiksystem.ch> Cc: freebsd-questions Questions <freebsd-questions@freebsd.org> Subject: Re: Cacti & FreeBSD Jail CPU & RAM monitoring Message-ID: <B1E75841-F1E1-4B07-8FCE-9308DD2A9710@shire.net> In-Reply-To: <6C0CF58A187DA5479245E0830AF84F421D108E@poweredge.attiksystem.ch> References: <6C0CF58A187DA5479245E0830AF84F421D108E@poweredge.attiksystem.ch>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B1E75841-F1E1-4B07-8FCE-9308DD2A9710>