First things first, let's give credit where credit is due. I wanted this to have more visible coverage and originally stumbled upon this information in which references this site.
Because part of the discussion references how to determine the number of containers on the host node when logged into the node directly (IE: as the provider) I am skipping that as that's not the access your normal end user would have. Instead I'll be focusing on how to determine the container count on a OpenVZ node when logged into your own container as a customer. Please note that this may not work on every OpenVZ container, as @mitgib pointed out however I've tested it on a couple containers myself and have posted the results below.
I am certain someone else can chime in with more technical information as my understanding of this is limited.
The command
cat /proc/cgroups
Yep, that's it.
Your results should appear similar to this:
root@dev:~# cat /proc/cgroups
#subsys_name hierarchy num_cgroups enabled
cpuset 3 295 1
cpu 3 295 1
cpuacct 3 295 1
devices 4 294 1
freezer 4 294 1
net_cls 0 1 1
blkio 1 299 1
perf_event 0 1 1
net_prio 0 1 1
memory 2 294 1
OR
root@other-dev:~# cat /proc/cgroups
#subsys_name hierarchy num_cgroups enabled
cpuset 2 75 1
cpu 2 75 1
cpuacct 2 75 1
devices 3 74 1
freezer 3 74 1
net_cls 0 1 1
blkio 1 75 1
perf_event 0 1 1
In the case of the first example, the number of containers on the hostnode should be 294 containers. Seems like a lot, but the provider is a budget provider and does not advertise 'non oversold' and performance is fine for what it is. It's just a cheap VPS so overselling is of course expected. In the second example, you guessed it, 74 total containers appear to be on the host node.
If your VPS provider is operating an older kernel then your results will likely appear like this and will not output the values above:
root@old-kernel:~# cat /proc/cgroups
#subsys_name hierarchy num_cgroups enabled
Feel free to run this on your OpenVZ containers and post your results, though just keep in mind some providers operate some large and beefy VPS nodes so a high container count should not automatically make you assume they are overselling or overloading their nodes to a large degree.
EDIT: @Mun made an awesome script here to do this for you:
Because part of the discussion references how to determine the number of containers on the host node when logged into the node directly (IE: as the provider) I am skipping that as that's not the access your normal end user would have. Instead I'll be focusing on how to determine the container count on a OpenVZ node when logged into your own container as a customer. Please note that this may not work on every OpenVZ container, as @mitgib pointed out however I've tested it on a couple containers myself and have posted the results below.
I am certain someone else can chime in with more technical information as my understanding of this is limited.
The command
cat /proc/cgroups
Yep, that's it.
Your results should appear similar to this:
root@dev:~# cat /proc/cgroups
#subsys_name hierarchy num_cgroups enabled
cpuset 3 295 1
cpu 3 295 1
cpuacct 3 295 1
devices 4 294 1
freezer 4 294 1
net_cls 0 1 1
blkio 1 299 1
perf_event 0 1 1
net_prio 0 1 1
memory 2 294 1
OR
root@other-dev:~# cat /proc/cgroups
#subsys_name hierarchy num_cgroups enabled
cpuset 2 75 1
cpu 2 75 1
cpuacct 2 75 1
devices 3 74 1
freezer 3 74 1
net_cls 0 1 1
blkio 1 75 1
perf_event 0 1 1
In the case of the first example, the number of containers on the hostnode should be 294 containers. Seems like a lot, but the provider is a budget provider and does not advertise 'non oversold' and performance is fine for what it is. It's just a cheap VPS so overselling is of course expected. In the second example, you guessed it, 74 total containers appear to be on the host node.
If your VPS provider is operating an older kernel then your results will likely appear like this and will not output the values above:
root@old-kernel:~# cat /proc/cgroups
#subsys_name hierarchy num_cgroups enabled
Feel free to run this on your OpenVZ containers and post your results, though just keep in mind some providers operate some large and beefy VPS nodes so a high container count should not automatically make you assume they are overselling or overloading their nodes to a large degree.
EDIT: @Mun made an awesome script here to do this for you:
Last edited by a moderator: