Created
July 25, 2016 14:15
-
-
Save stevenwilliamson/459f5382883a688d7534762404e4495b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Space stats | |
| ZONES_ZVOLS=$(zfs list -r -H -p -o volsize zones | grep -v - | awk '{ SUM += $1 } END { print int ( SUM / 1024 / 1024 / 1024 ) }') | |
| ZONES_QUOTAS=$(zfs list -r -Hp -o quota zones | grep -v - | awk '{ SUM += $1 } END { print int ( SUM / 1024 / 1024 / 1024 ) }') | |
| VM_QUOTAS=$(vmadm list -H -p -o quota | awk '{ SUM += $1 } END { print SUM }') | |
| ZONES_POOL_SIZE=$(zpool list -p -H zones | awk '{ print int ( $2 / 1024 / 1024 / 1024 ) }') | |
| VM_TOTAL=$(expr ${VM_QUOTAS} + ${ZONES_ZVOLS} ) | |
| OVER_PROV_GB=$(expr ${ZONES_POOL_SIZE} - ${VM_TOTAL}) | |
| FREE_TO_PROV=$(expr ${ZONES_POOL_SIZE} - ${VM_TOTAL}) | |
| if [ ${OVER_PROV_GB} -gt "0" ]; then | |
| OVER_PROV_GB=0 | |
| fi | |
| if [ ${FREE_TO_PROV} -le 1 ]; then | |
| FREE_TO_PROV=0 | |
| fi | |
| ZONES_POOL_AVAIL=$(zfs list -Hp -o space zones | awk '{ print int ( $2 / 1024 / 1024 / 1024 ) }') | |
| echo $(hostname) | |
| echo "Space used by ZVOLS: ${ZONES_ZVOLS}" | |
| echo "Space allocated via VM quotas: ${VM_QUOTAS}" | |
| echo "Zones pool size: ${ZONES_POOL_SIZE}" | |
| echo "Over Provisioned by: ${OVER_PROV_GB}" | |
| echo "Free to Provision: ${FREE_TO_PROV}" | |
| echo "Currenty Free: ${ZONES_POOL_AVAIL}" | |
| # Output a CSV record that can be grepped out | |
| echo -n "CSV," | |
| echo -n "$(hostname)," | |
| echo -n "${ZONES_ZVOLS}," | |
| echo -n "${VM_QUOTAS}," | |
| echo -n "${ZONES_POOL_SIZE}," | |
| echo -n "${OVER_PROV_GB}," | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment