Skip to content

Instantly share code, notes, and snippets.

@Syerram Syerram/cf-dot-get-mem.sh
Last active Jun 26, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.