123456789101112131415161718 |
- #!/bin/bash
- exec 2> /dev/null
- TOTALRESERVE=0
- for SERVICENAME in $(docker service ls -q); do
- echo -n $( docker service inspect ${SERVICENAME} -f {{.Spec.Name}} )' '
- SERVICE_RESERVE=$(docker service inspect $SERVICENAME -f {{.Spec.TaskTemplate.Resources.Reservations.MemoryBytes}})
- if [ $? -eq 0 ]; then
- SERVICE_RESERVE=$(( SERVICE_RESERVE*$(docker service ps $SERVICENAME -q -f desired-state=running | wc -l)/1024/1024 ))
- else
- SERVICE_RESERVE='none'
- fi
- echo ' Total service reserved '$SERVICE_RESERVE' M'
- TOTALRESERVE=$(( TOTALRESERVE+SERVICE_RESERVE ))
- done
- echo 'Summary reserved '$TOTALRESERVE' M'
|