From owner-freebsd-isp@FreeBSD.ORG Wed Jun 3 10:40:15 2009 Return-Path: Delivered-To: freebsd-isp@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 059651065678 for ; Wed, 3 Jun 2009 10:40:15 +0000 (UTC) (envelope-from 000.fbsd@quip.cz) Received: from elsa.codelab.cz (elsa.codelab.cz [94.124.105.4]) by mx1.freebsd.org (Postfix) with ESMTP id B58F08FC0C for ; Wed, 3 Jun 2009 10:40:14 +0000 (UTC) (envelope-from 000.fbsd@quip.cz) Received: from localhost (localhost.codelab.cz [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id 7AE9919E045; Wed, 3 Jun 2009 12:40:11 +0200 (CEST) Received: from [192.168.1.2] (r5bb235.net.upc.cz [86.49.61.235]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTPSA id 21DD219E043; Wed, 3 Jun 2009 12:40:09 +0200 (CEST) Message-ID: <4A265309.4020700@quip.cz> Date: Wed, 03 Jun 2009 12:40:09 +0200 From: Miroslav Lachman <000.fbsd@quip.cz> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: cz, cs, en, en-us MIME-Version: 1.0 To: "Marc G. Fournier" References: <20090603063520.I56412@hub.org> In-Reply-To: <20090603063520.I56412@hub.org> Content-Type: multipart/mixed; boundary="------------030702080702080301050209" Cc: freebsd-isp@freebsd.org Subject: Re: Tools to calculate memory usage per jail X-BeenThere: freebsd-isp@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Internet Services Providers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2009 10:40:15 -0000 This is a multi-part message in MIME format. --------------030702080702080301050209 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Marc G. Fournier wrote: > > Subject says it all ... does anyone know of / have such a tool? I am using some modified shell script - jps. It is based on Oliver Fromme http://www.secnetix.de/~olli/scripts/jps My version is attached. If jps is called with JID param, you get list of processes of given jail and summary like this: ============================== summary for JID 6 / tester1.example.com %MEM RSS VSZ %CPU 5 221064 1034648 0 It is far from perfect tool, but it is enough to my needs. Or you can ask on freebsd-jail@freebsd.org list, where are more skilled peoples around jails :) [Stef Walter is working on bsnmp-jails, maybe he is able to extend it for memory usage too] Miroslav Lachman --------------030702080702080301050209 Content-Type: text/plain; name="jps" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="jps" #!/bin/sh - # # Copyright (C) 2007 Oliver Fromme # All rights reserverd. Standard 2-clause BSD license and disclaimer apply. # # List processes that are running inside a jail. # This is intended to complement the standard jls(8) command. # # Usage: # jps list all jailed processes # jps list only processes in jail . # # Run the jls(8) command to get a list of jails and JIDs. # # Note: This script works for FreeBSD >= 6 only! # For FreeBSD 4.x, please use jailstat instead: # http://www.secnetix.de/~olli/scripts/jailstat # ME="${0##*/}" Usage() { cat <<-tac $ME -- List processes that are running inside a jail. This is intended to complement the standard jls(8) command. Usage: $ME list all jailed processes $ME list only processes in jail Run the jls(8) command to get a list of jails and JIDs. tac exit 1 } if [ $# -gt 2 ]; then Usage fi if [ $# -eq 1 ]; then case "$1" in ""|*[!0-9]*) Usage ;; esac FILTER='$1=="'$1'"' sum_jid="$1" jname=`jls | awk "$FILTER"'{ print $3 }'` else FILTER='$1!="0"' sum_jid="all" jname="-" fi ps -axww -o jid,pid,%mem,rss,user,command | awk '$1!~/[0-9]/||'"$FILTER" | sort -n echo echo "==============================" echo " summary for JID $sum_jid / $jname" echo " %MEM RSS VSZ %CPU " ## NOTE: jail processes can be swapped (%mem & rss are zero, but vsz not) ps -axww -o jid,%mem,rss,vsz,%cpu | awk '$1!~/[0-9]/||'"$FILTER" | awk '{ sm += $2; sp += $3; sv += $4; sc += $5 } END { printf(" %3d %9i %9i %3d \n", sm, sp, sv, sc) }' #-- --------------030702080702080301050209--