# iocage memory usage



## fred974 (Jan 14, 2017)

Hi,

I have been looking at the iocage() but I cannot figure out if there is a way to show the current memory usage of a jail..

Could anyone please tell me if such feature exist in sysutils/iocage?

Thank you


----------



## aribi (Jan 17, 2017)

fred974 said:


> show the curent memory usage of a jail..


Simple question, but a jail doesn't have its own memory like a VM. Jail is actually a set of processes with a specific jail id.
You can do `ps -eo pid,rss,args -J jailid` which will show you a list of the processes in your jail and their memory usage. Or put it in a oneliner to get the percentage of of system memory in use for jailid:

```
ps -eo %mem -J jailid | tail +2 | awk 'BEGIN{i=0}\
 {i=i+$1}\
 END{printf"%f%%\n",i}'
```


----------



## fred974 (Jan 17, 2017)

That's a very cool command you just gave me 
I'll try to make a script out of it to calculate what I want and display for all jail..

Thank you


----------



## sko (Jan 19, 2017)

iocage is only a wrapper for managing jails, not for observing them.
Some of the common system tools have become jail-aware, so e.g. top can show processes from a specific jail by using the -J <jailid | jailname> option. 

If more specific stats are needed or you have to drill (really) deep into a specific problem, DTrace is a great tool and even with only some basic knowledge of it you can get pretty far when chasing down a problem.


----------



## kalleboy (Aug 17, 2022)

fred974 said:


> Hi,
> 
> I have been looking at the man iocage() but I cannot figure out if there is a way to show the curent memory usage of a jail..
> 
> ...



that's a very later answer but i just found this tool from this week's vermaden blog newsletter, works fine on my system:









						GitHub - ozgurkazancci/jstats: A small tool for FreeBSD systems - lists RAM, CPU and disk space usage of the jails running in the host system.
					

A small tool for FreeBSD systems - lists RAM, CPU and disk space usage of the jails running in the host system. - GitHub - ozgurkazancci/jstats: A small tool for FreeBSD systems - lists RAM, CPU an...




					github.com


----------

