Skip to content

Instantly share code, notes, and snippets.

@azilber
Forked from jnm/container-disk-use.sh
Last active February 4, 2017 02:49
Show Gist options
  • Save azilber/66508ebe9fb24791161897aadbd83731 to your computer and use it in GitHub Desktop.
Save azilber/66508ebe9fb24791161897aadbd83731 to your computer and use it in GitHub Desktop.
Show OpenVZ containers' disk use in GB and as percentage of the host's total disk space. Tested with Proxmox VE.
#!/bin/bash
# jnm 20140311
TOTAL_AVAILABLE=$(df /vz | grep '/vz$' | awk '{ print $2 }')
vzlist -o ctid,numproc,status,ip,hostname,diskspace -s diskspace | awk '
{
printf $0 "\t"
if(NR==1)
{
print "in G\tas % of host"
}
else
{
printf "%2.f\t%0.f\n", $NF / 1024 / 1024, $NF * 100 / $TOTAL_AVAILABLE
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment