Created
July 15, 2018 19:32
-
-
Save hpsaturn/360801ea6c53ed38f4dd0e2d0d84896f to your computer and use it in GitHub Desktop.
Get the total of memory from a procces and her threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cmd=$1 | |
mem=`ps -eo %mem,cmd --sort=-%mem | grep -i $cmd | awk -F ' ' '{sum += $1} END {print sum}'` | |
memtotal=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'` | |
memcmd=`awk 'BEGIN{printf "%.2f\n", (("'$mem'"*"'$memtotal'")/100000)}'` | |
echo "${memcmd} Mb (${mem}%)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment