Created
June 11, 2020 04:30
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 | |
function tasksByNodeAPI | |
{ | |
echo "DC/OS Tasks By Node" | |
if [ "$#" -eq 0 ]; then | |
echo "Need node ip as input. Exiting." | |
exit 1 | |
fi | |
nodeIp=$1 | |
mesosId=`dcos node | grep $nodeIp | awk '{print $3}'` | |
if [ -z "mesosId" ]; then | |
echo "No node found with ip $nodeIp. Exiting." | |
exit 1 | |
fi | |
curl -s -H "Authorization: Bearer $(dcos config show core.dcos_acs_token)" "$(dcos config show core.dcos_url)/mesos/tasks?limit=10000" | jq --arg mesosId $mesosId '.tasks[] | select (.slave_id == $mesosId and .state == "TASK_RUNNING") | .name + "\t\t\t" + .id' -r | |
} | |
function tasksByNodeCLI | |
{ | |
echo "DC/OS Tasks By Node" | |
if [ "$#" -eq 0 ]; then | |
echo "Need node ip as input. Exiting." | |
exit 1 | |
fi | |
nodeIp=$1 | |
dcos task | egrep "HOST|$nodeIp" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment