Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 11, 2020 04:24
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 velotiotech/4b660121b5e50ad6f48c5cf1e7265c9f to your computer and use it in GitHub Desktop.
Save velotiotech/4b660121b5e50ad6f48c5cf1e7265c9f to your computer and use it in GitHub Desktop.
#!/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