Skip to content

Instantly share code, notes, and snippets.

@Syerram
Last active June 26, 2019 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Syerram/024181ff3c46e08cf59235802143d290 to your computer and use it in GitHub Desktop.
Save Syerram/024181ff3c46e08cf59235802143d290 to your computer and use it in GitHub Desktop.
cf dot - Get free memory after the CF upgrade
# For help on this command, please contact the Diego team on CF slack channel #diego
cfdot cell-states \
| jq '(.RootFSProviders.preloaded.set | keys) as $rootfses | select($rootfses | contains(["linux"])) | .segment = "Segment: \(.PlacementTags | .[0] // "(shared)") | Stacks: \($rootfses | join(", "))"' \
| jq '{segment, containers: (.TotalResources.Containers - .AvailableResources.Containers), total_memory: .TotalResources.MemoryMB, free_memory: .AvailableResources.MemoryMB, cells: 1}' \
| jq -s 'reduce (.[] | .segment as $s | del(.segment) | to_entries[] | .segment = $s) as $i ({}; .[$i.segment][$i.key] += $i.value) | to_entries | map(.value.segment = .key | .value) | sort_by(.segment) | .[]' \
| jq -r '(.free_memory - (.containers * 32)) as $free_memory_after | "\(.segment)\n Cells: \(.cells)\n Containers: \(.containers)\n Current Free Memory: \(.free_memory) MB / \(.free_memory / .total_memory * 1000 | floor /10)%\n Additional Memory Required: \(.containers * 32) MB\n Free Memory Afterward: \($free_memory_after) MB / \($free_memory_after / .total_memory * 1000 | floor / 10)%\n"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment