Bash Collection – Script to get the real amount of used memory of an application

, par  Alexander Löhner , popularité : 2%

The following script was written by me to be able to get the really used amount of memory for one single application.

Since it isn’t that easy to get the used memory through “top” or “ps” or similar tools, this may be helpful for somebody.

The output is in megabytes and looks like this :

 $ memused.sh mono 5438.39

Just save the following script as “/usr/local/bin/memused.sh” and make it executable (chmod 755 /usr/local/bin/memused.sh) :

# !/bin/bash # Written by Alexander Löhner # The Linux Counter Project # Updated on Sep. 8th 2015 by Mike Hay to remove dependency on ’bc’ if [1] ; then echo "please add the name of the process as a parameter" exit 1 fi for i in $(pidof $1) ; do echo $(awk ’/Private/ sum+=$2 END print sum’ /proc/$i/smaps) ; done | awk ’sum+=$1 END printf("%.2f\n", sum/1000)

If you also have some useful scripts, please don’t hesitate to share them with us !

Just contact info@linuxcounter.net and attach your script with a small description what it does.

Thanks !

.

Voir en ligne : http://blog.linuxcounter.net/2015/0...

[1"$1" = ""

Publications Derniers articles publiés

Sites favoris Tous les sites

84 sites référencés dans ce secteur