Skip to content

Commit

Permalink
Merge pull request kata-containers#842 from grahamwhaley/20181023_inc…
Browse files Browse the repository at this point in the history
…ontainer_memsize

metrics: density: in-container: set and store memsize
  • Loading branch information
GabyCT authored Oct 23, 2018
2 parents 0341cc1 + 55f8bf0 commit 8201389
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions metrics/density/memory_usage_inside_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ VERSIONS_FILE="${SCRIPT_PATH}/../../versions.yaml"
ALPINE_VERSION=$("${GOPATH}/bin/yq" read "$VERSIONS_FILE" "docker_images.alpine.version")
IMAGE="alpine:$ALPINE_VERSION"
CMD="cat /proc/meminfo"
TMP_FILE=$(mktemp meminfo.XXXXXXXXXX || true)
# We specify here in 'k', as that then matches the results we get from the meminfo,
# which makes later direct comparison easier.
MEMSIZE=${MEMSIZE:-$((2048*1024))}

function main() {
# Check tools/commands dependencies
Expand All @@ -30,8 +32,7 @@ function main() {

metrics_json_init

docker run --rm --runtime=$RUNTIME $IMAGE $CMD > $TMP_FILE
local output=$(cat $TMP_FILE)
local output=$(docker run -m ${MEMSIZE}k --rm --runtime=$RUNTIME $IMAGE $CMD)

# Save configuration
metrics_json_start_array
Expand All @@ -45,6 +46,10 @@ function main() {

local json="$(cat << EOF
{
"memrequest": {
"Result" : $MEMSIZE,
"Units" : "Kb"
},
"memtotal": {
"Result" : $memtotal,
"Units" : "$units_memtotal"
Expand All @@ -65,7 +70,6 @@ EOF
metrics_json_end_array "Results"
metrics_json_save
clean_env
rm -f $TMP_FILE
}

main "$@"

0 comments on commit 8201389

Please sign in to comment.