Skip to content

Instantly share code, notes, and snippets.

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