`
iunknown
  • 浏览: 404290 次
社区版块
存档分类
最新评论

[zz]Troubleshooting Memory Usage

阅读更多
http://rimuhosting.com/howto/memory.jsp

# create a memmon.sh script that tracks the current date, memory usage and running processes
cat << EOF > /root/memmon.sh
#!/bin/bash
date;
uptime
free -m
vmstat 1 5
ps auxf --width=200
if which iptables 2>&1 > /dev/null; then
iptables -L | diff iptables_default - | awk '{print "IPTABLES: " $0}'
iptables -L > iptables_default
else
echo "IPTABLES MISSING"
fi
dmesg | diff -u dmesg_default - | grep '^+' | awk '{print "DMESG:" $0}'
dmesg > dmesg_default
EOF

chmod +x /root/memmon.sh

# create a cronjob that runs every few minutes to log the memory usage
echo '0-59/10 * * * * root /root/memmon.sh >> /root/memmon.txt' > /etc/cron.d/memmon
/etc/init.d/cron* restart 

# create a logrotate entry so the log file does not get too large
echo '/root/memmon.txt {}' > /etc/logrotate.d/memmon

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics