Created
April 23, 2013 08:54
-
-
Save anorm/5441916 to your computer and use it in GitHub Desktop.
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 | |
PID=$1 | |
function log() | |
{ | |
echo $(date) $@ | |
} | |
lastsize=0 | |
lastresident=0 | |
lastshare=0 | |
lasttext=0 | |
lastlib=0 | |
lastdata=0 | |
lastdt=0 | |
while [ 1 ]; do | |
# http://man7.org/linux/man-pages/man5/proc.5.html | |
read size resident share text lib data dt <<< $(cat /proc/$PID/statm) | |
if [[ $size -gt $lastsize ]]; then | |
log "Size $lastsize -> $size" | |
fi | |
lastsize=$size | |
if [[ $resident -gt $lastresident ]]; then | |
log "Resident $lastresident -> $resident" | |
fi | |
lastresident=$resident | |
if [[ $share -gt $lastshare ]]; then | |
log "Share $lastshare -> $share" | |
fi | |
lastshare=$share | |
if [[ $text -gt $lasttext ]]; then | |
log "Text $lasttext -> $text" | |
fi | |
lasttext=$text | |
if [[ $lib -gt $lastlib ]]; then | |
log "Lib $lastlib -> $lib" | |
fi | |
lastlib=$lib | |
if [[ $data -gt $lastdata ]]; then | |
log "Data $lastdata -> $data" | |
fi | |
lastdata=$data | |
if [[ $dt -gt $lastdt ]]; then | |
log "Dt $lastdt -> $dt" | |
fi | |
lastdt=$dt | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment