Created
June 11, 2020 04:30
-
-
Save velotiotech/07dbeafa0a74bd2f34b4cd48b07d5144 to your computer and use it in GitHub Desktop.
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