Last active
June 23, 2018 17:27
-
-
Save pkazi/049dd14e3b23da6b45c1da84a10b74e8 to your computer and use it in GitHub Desktop.
Get DCOS nodes with node attributes, number of tasks running, memory and cpu available
This file contains 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
#!/bin/bash | |
printf "\n %-15s %-18s%-18s%-10s%-15s%-10s\n" "Node Type" "Node IP" "Attribute" "Tasks" "Mem Free (MB)" "CPU Free" | |
printf '%.0s=' {1..90} | |
printf "\n" | |
TAB=`echo -e "\t"` | |
dcos node --json | jq '.[] | if (.type | contains("leader")) then "Master (leader)" elif ((.type | contains("agent")) and .attributes.public_ip != null) then "Public Agent" elif ((.type | contains("agent")) and .attributes.public_ip == null) then "Private Agent" else empty end + "\t"+ if(.type |contains("master")) then .ip else .hostname end + "\t" + (if (.attributes | length !=0) then (.attributes | to_entries[] | join(" = ")) else "NA" end) + "\t" + if(.type |contains("agent")) then (.TASK_RUNNING|tostring) + "\t" + ((.resources.mem - .used_resources.mem)| tostring) + "\t\t" + ((.resources.cpus - .used_resources.cpus)| tostring) else "\t\tNA\tNA\t\tNA" end' -r | sort -t"$TAB" -k1,1d -k3,3d -k2,2d | |
printf '%.0s=' {1..90} | |
printf "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment