Thursday, January 1, 2015

Colorized Show Swappers -- Scraping /proc/*/status

alias showswappers=$' CP="\\033[1;3" && Y="${CP}3m" && P="${CP}5m" && C="${CP}6m" && G="${CP}2m" && RST="${CP}0m" && for file in /proc/*/status; do SWPPID=$(cut -d \'/\' -f3 <<< "${file}"); echo -en "${Y}[[[[${RST} ${P}Pid:${RST} ${C}${SWPPID}${RST} "; awk \"/Name/{printf \\"${P}Cmd_Shortname:${RST} ${C}%s${RST} \\",\$2}/VmSwap/{printf \\"${P}Swap_Used:${RST}${C} %s %s ${RST}\\",\$2,\$3}END{printf \\"${RST}${Y}]]]] ==> ${RST}${G}\\"}\" "${file}"; cat /proc/${SWPPID}/cmdline; echo; done 2>/dev/null | sort -n -k 7'

[[[[ Pid: 25400 Cmd_Shortname: chrome Swap_Used: 9784 kB ]]]] ==> /opt/google/chrome/chrome --type=gpu-broker

No comments:

Post a Comment