LoginSignup
2
0

More than 5 years have passed since last update.

GCPプロジェクトの全ディスク使用量を確認する

Posted at

GCPプロジェクトの全ディスク使用量を確認する

きっかけ

このプロジェクトのディスクって何GB使ってる?と聞かれて、
あれ?どうやればいいんだっけ?という状態になった。
課金で見るか、Quotaで見るか・・・うーん。っていう感じだったが、gcloudでやったほうがかっこよくない?とちょっと思ったからやってみた。

どうやったか

gcloudコマンドでは以下のように出力される

gcloud compute disks list

NAME   ZONE   SIZE_GB   TYPE   STATUS

んで、トータルを出す。

gcloud compute disks list | grep -v SIZE_GB | awk '{sum += $3} END {print sum}'
200

種類ごとに集計する

$ gcloud compute disks list | grep -v SIZE_GB | awk '{type[$4]+=$3} END {for(name in type){print name " "type[name]}}'
pd-standard 150
pd-ssd 50
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0