欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[zz]Troubleshooting Memory Usage

程序员文章站 2022-07-14 14:12:07
...
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

相关标签: Bash JSP