Skip to content

Commit

Permalink
Update and rename memcpu.sh to mem-cpu.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudh-devanand authored May 12, 2021
1 parent ad03fe1 commit 82fd8f8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/memcpu.sh → scripts/mem-cpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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

0 comments on commit 82fd8f8

Please sign in to comment.