Skip to content

Instantly share code, notes, and snippets.

@jnm
Created March 11, 2014 13:57
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jnm/9486123 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 /var/lib/vz | grep '/var/lib/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