Skip to content

Instantly share code, notes, and snippets.

@ayush
Last active August 29, 2015 13:57
Show Gist options
  • Save ayush/9463318 to your computer and use it in GitHub Desktop.
Save ayush/9463318 to your computer and use it in GitHub Desktop.
shows key memory stats and open files/sockets for a system + process
while true; do
date; echo;
ps aux | awk '{print $2, $4, $11}' | sort -k2r | head -n 5; echo;
free -m; echo;
cat /proc/meminfo | egrep '(Slab|SRec|SUnr)'; echo;
cat /proc/$(pidof $1)/status | grep Vm;
echo; echo '_____________________'; echo;
cat /proc/sys/fs/file-nr; echo;
sudo lsof -c $1 | wc -l; echo;
sudo lsof -i -c $1 | grep CLOSE_WAIT | wc -l; echo;
echo; echo '************************************'; echo;
sleep $2;
done
@ayush
Copy link
Author

ayush commented Mar 10, 2014

Shows the following once every minute for monmem java 60

Mon Mar 10 07:22:51 EDT 2014

PID %MEM COMMAND
4049 34.0 /usr/bin/java
657 0.0 [xfssyncd/xvdb]
643 0.0 [xfs_mru_cache]
647 0.0 [xfslogd/3]

             total       used       free     shared    buffers     cached
Mem:         34173      17301      16872          0         13       4249
-/+ buffers/cache:      13038      21135
Swap:            1          1          0

Slab:             681856 kB
SReclaimable:     558384 kB
SUnreclaim:       123472 kB

VmPeak: 34105280 kB
VmSize: 33843008 kB
VmLck:         0 kB
VmHWM:  11923828 kB
VmRSS:  11923828 kB
VmData: 33682352 kB
VmStk:        88 kB
VmExe:         4 kB
VmLib:     13912 kB
VmPTE:     25424 kB
VmSwap:        0 kB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment