Skip to content

Instantly share code, notes, and snippets.

@danifitz
Last active January 19, 2023 13:11
Show Gist options
  • Save danifitz/8ad09001a564e0cf8266151cb8418c62 to your computer and use it in GitHub Desktop.
Save danifitz/8ad09001a564e0cf8266151cb8418c62 to your computer and use it in GitHub Desktop.
an inventory script to measure vcpu consumption by gcp cloudrun
# A sample Bash script to count the number of vCPU's consumed by GCP CloudRun. @author [email protected]
REGIONS=(europe-north1 us-central1)
for region in ${REGIONS[@]}; do
SERVICES=$(gcloud run services list --region $region --format="json" | jq -r '.[] | .metadata.name')
echo "##############################\n GCP Region: $region"
for service in ${SERVICES[@]}; do
echo "##############################\n CloudRun service: $service \n##############################\n"
vcpu=$(gcloud run services describe $service --region $region --format="json" | jq -r '.spec.template.spec.containers | .[].resources.limits.cpu')
echo "$vcpu\n"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment