29 lines
539 B
Bash
29 lines
539 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -eu
|
||
|
|
||
|
|
||
|
SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||
|
OUTPUT="stats.json"
|
||
|
|
||
|
# Move in repo folder
|
||
|
pushd ${SCRIPT_PATH} > /dev/null
|
||
|
|
||
|
|
||
|
# If file does not exist, create it with JSON bracket
|
||
|
if [ ! -f $OUTPUT ]; then
|
||
|
echo "[" >> ${OUTPUT}
|
||
|
fi
|
||
|
|
||
|
# Append stat data
|
||
|
now=$(date -Iseconds)
|
||
|
echo "{" >> ${OUTPUT}
|
||
|
echo " \"data\": \"${now}\"" >> ${OUTPUT}
|
||
|
/snap/bin/docker stats --no-stream --format " ,\"{{.Name}}\": \"{{.MemUsage}}\"" >> ${OUTPUT}
|
||
|
|
||
|
echo "}," >> ${OUTPUT}
|
||
|
|
||
|
|
||
|
# Back to original path
|
||
|
popd
|