X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ntsimulator%2Fscripts%2Fdocker_stats.sh;fp=ntsimulator%2Fscripts%2Fdocker_stats.sh;h=0000000000000000000000000000000000000000;hb=f1d5c9198acde7a7ce296490087cad37e008f688;hp=fbf15abc019afe0775e837811ab2cd66d6055dba;hpb=f2d8f1002fa93848c80a88e5658db4816cba3020;p=sim%2Fo1-interface.git diff --git a/ntsimulator/scripts/docker_stats.sh b/ntsimulator/scripts/docker_stats.sh deleted file mode 100755 index fbf15ab..0000000 --- a/ntsimulator/scripts/docker_stats.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -################################################################################ -# -# Copyright 2019 highstreet technologies GmbH and others -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ - -# This script is used to complete the output of the docker stats command. -# The docker stats command does not compute the total amount of resources (RAM or CPU) - -# Get the output of the docker stat command. Will be displayed at the end -# Without modifying the special variable IFS the ouput of the docker stats command won't have -CPU_CORES=`nproc` -# the new lines thus resulting in a failure when using awk to process each line -IFS=; -mapfile -t DOCKER_PS_RESULT < <(/usr/bin/docker ps --all --format "{{.ID}}" --filter "label=NTS") - -CONTAINERS="" - -if [ ${#DOCKER_PS_RESULT[@]} -gt 0 ] -then - - for container in "${DOCKER_PS_RESULT[@]}" - do - CONTAINERS="$CONTAINERS $container" - done -fi - -if [ -z "$CONTAINERS" ] -then - CPU_SCALED=0 - SUM_RAM=0 -else - DOCKER_STATS_COMMAND="/usr/bin/docker stats --no-stream --format \"table {{.CPUPerc}}\t{{.MemUsage}}\" ${CONTAINERS}" - DOCKER_STATS_COMMAND_RESULT=$(eval "$DOCKER_STATS_COMMAND") - - SUM_CPU=`echo $DOCKER_STATS_COMMAND_RESULT | tail -n +2 | sed "s/%//g" | awk '{s+=$1} END {print s}'` - SUM_RAM=`echo $DOCKER_STATS_COMMAND_RESULT | tail -n +2 | sed "s/%//g" | awk '{s+=$2} END {print s}'` - - CPU_SCALED=$(echo "scale=2; $SUM_CPU/$CPU_CORES" | bc) -fi - -# Output the result -echo -e "CPU=${CPU_SCALED}%;RAM=${SUM_RAM}MiB" \ No newline at end of file