Create a new file with following code and chmod +x the file and then execute with 2 parameters viz. month and year.
cd /root
vi bandwidth
#!/bin/bash
cd /var/cpanel/bandwidth/
ls | grep -v "\." | xargs -n 1 -izzz sh -c "echo -n zzz \" = \"; egrep \"^$1\..*\.$2-all\" zzz | awk -F'=' 'START {bytes=0} { bytes+=\$2 } END {print bytes/1024/1024 \" MB\"}'"
cd -
Usage:
./bandwidth month year
Eg To see top 20 BW taking users in April 2009
./bandwidth 3 2009 | sort -nrk 3 | head -20
The above will show the result in the descending order, the highest BW usage account first.
User names can be related with domain names from /etc/trueuserdomains
No comments:
Post a Comment