Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Find user Bandwidth from SSH (CPanel)  (Read 2907 times)

0 Members and 1 Guest are viewing this topic.

Aby

  • Guest
Find user Bandwidth from SSH (CPanel)
« on: November 08, 2013, 05:29:01 am »

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.