Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 2009 01:03:06 +0200
From:      Kurt Jaeger <lists@c0mplx.org>
To:        "Marc G. Fournier" <scrappy@hub.org>
Cc:        freebsd-jail@freebsd.org
Subject:   Re: Calculating per jail memory usage ...
Message-ID:  <20090603230306.GF10978@home.opsec.eu>
In-Reply-To: <20090603180221.E56412@hub.org>
References:  <20090603180221.E56412@hub.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi!

> Are there any tools for this that are either in ports, or others would 
> like to share?

This perl snippet works pretty good:

# return memory/proc usage per jail and system
sub vmem {
    my(@res);
    my($i);
    my($ip);
    my(@t);

    @res = `/bin/ps ax -o 'pid,jid,rss,vsz,args' 2>&1`;
    shift(@res);
    foreach $i (@res) {
        $i = " ".$i;
        @t=split(/ +/,$i);
        # print "i: $i t1: $t[2]\n";
        $jproc{$t[2]}++;
        $jrealm{$t[2]} += $t[3];
        $jvirtm{$t[2]} += $t[4];
    }

    foreach $i (keys(%running)) {
        $ip=$vs2ip{$i};
        if ( defined($jproc{$ip2jid{$ip}}) ) {
            $runproc{$i} = $jproc{$ip2jid{$ip}} - 1
        }
        else {
            $runproc{$i} = 0;
        }
        $runrealm{$i} = $jrealm{$ip2jid{$ip}};
        $runvirtm{$i} = $jvirtm{$ip2jid{$ip}};
    }
}

-- 
pi@opsec.eu            +49 171 3101372                        11 years to go !



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090603230306.GF10978>