Linux: How to monitor the memory in use
One web service occurred not normal few times.
Microsoft Azure Metrics (on Web Based. Mobile apps not yet available) showed that had memory overload.
Set up cron to monitor memory for more detail to identify what process brought it.
More important, logging it.
So could follow this question.
# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head | sed "s#^#$(date +%Y/%m/%d/%H:%M) #" >> /var/log/memory.log
# crontab -e
*/1 * * * * /bin/ps -eo "pid,ppid,cmd,\%mem,\%cpu" --sort=-"\%mem" | head | sed "s#^#$(date +\%Y/\%m/\%d/\%H:\%M) #" >> /var/log/memory.log
Edit /etc/logrotate.d/memory
/var/log/memory.log {
rotate 7
size 50M
daily
compress
delaycompress
notifempty
missingok
}
Update