最近有两台采集服务器磁盘老爆满,损失了不少数据。
shell脚本disk-ram-alert.sh
#!/bin/bash # script that will send an email to EMAIL when disk use in partition PART or RAM use is bigger than %MAX # adapt these 3 parameters to your case DISK_MAX=70 RAM_MAX=50 DISK_PART=/dev/xvdb5 EMAIL=$1 # Local IP IP=`/sbin/ifconfig eth1 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'` # Disk usage DISK_USE=`df -h |grep $DISK_PART | awk '{ print $5 }' | cut -d'%' -f1` echo "Disk usage:$DISK_USE%" # RAM usage RAM_USED=`free -m | grep cache: | awk '{print $3}'` RAM_TOTAL=`free -m | grep Mem: | awk '{print $2}'` RAM_USE=$[ $RAM_USED * 100 / $RAM_TOTAL ] echo "RAM usage:$RAM_USE%" if [ $DISK_USE -gt $DISK_MAX ]; then echo "Disk percent used: $DISK_USE" | mail -s "[Disk alert]Running out of disk space-$IP" $EMAIL fi if [ $RAM_USE -gt $RAM_MAX ]; then echo "Ram percent used: $RAM_USE" | mail -s "[RAM alert]Running out of RAM-$IP" $EMAIL fi ~ ~
添加计划任务,每小时检查一次:
0 */1 * * * /home/qi/disk-alert.sh redice@163.com
呵呵,谢谢
VaTG790i.最好的<a href=http://www.kyfei.com>网站推广软件</a>,
非常好
....................
;ui;普i;uighur;ui;ui;个
在unix网络编程中看到了关于TCP/IP的一些内容,我感觉还是写的不够。正在下载中,一定
下载地址呢