Skip to content

Instantly share code, notes, and snippets.

@benhardy
Last active August 29, 2015 14:13
Show Gist options
  • Save benhardy/63a5c23615f8a562a68f to your computer and use it in GitHub Desktop.
Save benhardy/63a5c23615f8a562a68f to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Show resource usage as reported by Singularity
#
# author: github.com/benhardy
set -o errexit -o nounset
if [ $# -ne 1 ]; then
echo "Usage: $0 singularity-resource-usage.sh SINGULARITY_SERVER"
exit 1
fi
SINGULARITY_SERVER=$1
REQS=$(curl -s http://$SINGULARITY_SERVER/api/requests | jq '.[].request.id'|tr -d '"')
(for REQ in $REQS; do
echo $REQ $( curl -s http://$SINGULARITY_SERVER/api/requests/request/$REQ | jq '.activeDeploy.resources'|jq '.cpus, .memoryMb, .numPorts')
done) | sort | perl -ne 'chop; ($name,$cpu,$ram,$ports)=split; printf("%-40s %5.2f cpu %5dmb ram %2d ports\n",$name,$cpu,$ram,$ports);'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment