Date: Wed, 03 Jun 2009 12:40:09 +0200 From: Miroslav Lachman <000.fbsd@quip.cz> To: "Marc G. Fournier" <scrappy@hub.org> Cc: freebsd-isp@freebsd.org Subject: Re: Tools to calculate memory usage per jail Message-ID: <4A265309.4020700@quip.cz> In-Reply-To: <20090603063520.I56412@hub.org> References: <20090603063520.I56412@hub.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <olli@fromme.com> <olli@secnetix.de> # 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 <JID> list only processes in jail <JID>. # # 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 <JID> list only processes in jail <JID> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A265309.4020700>