jails Memory accounting on jail

I have enabled accounting and have set a memory limit to a jail via,
Code:
/usr/bin/rctl -a jail:pj:memoryuse:deny=13958643712
This to prevent too much swapping and just kill the deadly jail processes.

But how do i query the accounting database to know the total current memory usage of that specifc jail(processes) ?
Otherwise if i can list all processes of that jail and use awk to sum is that possible from the host ?
 
I created something for total virtual memory of jail pj but it feels ugly,
Code:
#!/usr/local/bin/zsh
export pj1=` /bin/pgrep -j pj | xargs -I {} /bin/ps xao pid,vsz,rss,command {}`
export pj2=`echo $pj1 | grep -v COMMAND`
export pjvir=`echo $pj2 | /usr/bin/awk '{sum+=$2;} END{print sum;}'`
export pjrss=`echo $pj2 | /usr/bin/awk '{sum+=$3;} END{print sum;}'`
echo $pjvir
echo $pjrss
 
Back
Top