$ mbillable
bahamas10 => using 133 MB (1 GB billable)
Last active
December 25, 2015 07:19
-
-
Save bahamas10/6938284 to your computer and use it in GitHub Desktop.
Billable amount in Joyent Manta
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
# Total the billable amount in Manta | |
mbillable() { | |
mget -q ~~/reports/usage/storage/latest |\ | |
json storage.public.bytes storage.stor.bytes |\ | |
awk ' | |
{ | |
s += $1; | |
} | |
END { | |
billable = (s / 1024 / 1024 / 1024) + 1; | |
human = s; | |
units = "B"; | |
if (s > 1024 * 1024 * 1024 * 1024) { | |
human = s / 1024 / 1024 / 1024 / 1024; | |
units = "TB"; | |
} else if (s > 1024 * 1024 * 1024) { | |
human = s / 1024 / 1024 / 1024; | |
units = "GB"; | |
} else if (s > 1024 * 1024) { | |
human = s / 1024 / 1024; | |
units = "MB"; | |
} else if (s > 1024) { | |
human = s / 1024; | |
units = "KB"; | |
} | |
printf("%s => using %d %s (%d GB billable)\n", | |
ENVIRON["MANTA_USER"], human, units, billable); | |
} | |
' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment