diff --git a/scripts/memcpu.sh b/scripts/mem-cpu.sh similarity index 86% rename from scripts/memcpu.sh rename to scripts/mem-cpu.sh index 11fcfdf..c1ce76b 100755 --- a/scripts/memcpu.sh +++ b/scripts/mem-cpu.sh @@ -5,7 +5,7 @@ meml=$(cat /proc/meminfo | grep MemTotal | tr -s ' ' | cut -d ' ' -f 2 | bc) memr=$(pmap $1 | tail -1 | tr -s ' ' | cut -d ' ' -f 2 | tr -d 'K' | bc) -#converting Kb to Mb +#converting K to M meml="$(( meml / 1000 )).$(( meml % 1000 )) M" memr="$(( memr / 1000 )).$(( memr % 1000 )) M" @@ -14,5 +14,5 @@ cpul=$(( $(cat /proc/cpuinfo | grep cores | cut -d ':' -f 2 | tr -d ' ' |tail -1 cpur=$(echo "$(ps -p $1 -o %cpu | tail -1 | bc )*$(( cpul / 100 ))" | bc) #printing in .json format -echo -e "\"resources\":{\n\t\"limits\":{\n\t\t\"memory\":\"$meml\",\n\t\t\"cpu\":\"$cpul m\"\n\t}," -echo -e "\t\"requests\":{\n\t\t\"memory\":\"$memr\",\n\t\t\"cpu\":\"$cpur m\"\n\t}\n}" +echo -e "\"resources\":{\n\t\"limits\":{\n\t\t\"memory\":\"$meml\",\n\t\t\"cpu\":\"$cpul m\"\n\t}," > mem-cpu.json +echo -e "\t\"requests\":{\n\t\t\"memory\":\"$memr\",\n\t\t\"cpu\":\"$cpur m\"\n\t}\n}" >> mem-cpu.json