Posted at

smapsの情報をいい感じに合計して出力する

More than 5 years have passed since last update.

httpdを調べたい場合。

for i in `pgrep httpd`; do echo "== $i =============="; for j in Rss Shared Private Swap; do printf "%-10s" $j;  grep $j /proc/$i/smaps | awk 'BEGIN{n=0}{n += $2}END{printf "%8s (kB)\n", n}'; done ; done

全部見たい場合。


smaps_add_each_processes.sh

for i in /proc/[0-9]*; do echo "==== $i ===="; for j in Rss Shared Private Swap; do printf "%-10s" $j;  grep $j $i/smaps | awk 'BEGIN{n=0}{n += $2}END{printf "%8s (kB)\n", n}'; done; done