流量超出后网站会被暂停,暂停后才会发邮件通知。此脚本可以加到计划任务,每天获取流量使用前十。及时查看流量是否会超出。


#!/bin/bash

ip=`ifconfig |grep "inet addr"|grep -v 127.0|cut -d: -f2|awk '{ print $1 }'`

file=/opt/useage.bandwidth

find /usr/local/directadmin/data/users/ -name user.usage|xargs cat|grep bandwidth|cut -d= -f2|sort -nr|head -n 10 > $file

mail -s $ip-usage.bandwidth xxxx@qq.com < $file