Have a Question?

If you have any question you can ask below or enter what you are looking for!

Find out disk usage of all VPSs in an OpenVZ node

This article describes how you can find out disk usage of active (or running) VPSs in your SubHosting.net OpenVZ hardware node running CentOS 5/6 operating system.

Running the commands given here requires root user privilege. Use vzlist command to get the disk usage of running VPSs and awk command to process and display the output in desired format. Both vzlist and awk should be installed by default in your OpenVZ hardware node. Otherwise, install them using YUM package manager. You need to install gawk (for awk) and vzctl (for vzlist) packages.

Displaying disk usage of active VPSs

Use vzlist command and pipe its output to awk command as given below:

vzlist -H -o veid,hostname,diskspace | awk '{ printf("%d\t%s\t%.2f GB\n", $1, $2, $3/(1024*1024))}'
2002	vps.domain1.com		171.75 GB
2006	vps.domain2.com		7.00 GB
2008	vps.domain3.com		120.19 GB
2009	vps.domain4.com		0.94 GB
2011	vps.domain5.com		67.67 GB
2013	vps.domain6.com		132.94 GB
2015	vps.domain7.com		37.74 GB
2016	vps.domain8.com		5.80 GB
2018	vps.domain9.com		109.59 GB
2019	vps.domain10.com	18.14 GB
2021	vps.domain11.com	55.15 GB
2022	vps.domain12.com	35.29 GB

Displaying disk usage of active VPSs with total disk usage

You can modify awk command as follows to find out sum of disk usage of all VPSs:

vzlist -H -o veid,hostname,diskspace | awk '{ printf("%d\t%s\t%.2f GB\n", $1, $2, $3/(1024*1024))} {sum += $3} END {printf("Total disk usage: %.2f GB\n", sum/(1024*1024))}'
2002	vps.domain1.com		171.75 GB
2006	vps.domain2.com		7.00 GB
2008	vps.domain3.com		120.19 GB
2009	vps.domain4.com		0.94 GB
2011	vps.domain5.com		67.67 GB
2013	vps.domain6.com		132.94 GB
2015	vps.domain7.com		37.74 GB
2016	vps.domain8.com		5.80 GB
2018	vps.domain9.com		109.59 GB
2019	vps.domain10.com	18.14 GB
2021	vps.domain11.com	55.15 GB
2022	vps.domain12.com	35.29 GB
Total disk usage: 762.12 GB 

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>