Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
Created September 25, 2015 16:13
Show Gist options
  • Save rushipkar90/4d6c5e25d2696f042353 to your computer and use it in GitHub Desktop.
Save rushipkar90/4d6c5e25d2696f042353 to your computer and use it in GitHub Desktop.
capped_bwlimit.sh
#/bin/bash
hname=`hostname`;
echo > /usr/local/src/bw_limit.txt;
echo > /usr/local/src/bw_limit1.txt;
echo > /usr/local/src/cappedresults.txt;
find /usr/local/apache/conf/userdata/*/*/*/*/ -name "cp_bw_all_limit.conf" > /usr/local/src/bw_limit.txt
find /usr/local/apache/conf/userdata/*/*/*/ -maxdepth 1 -name "cp_bw_all_limit.conf" > /usr/local/src/bw_limit1.txt
echo "Hostname" ";" "Username" ";" "Domain Name" ";" "Bandwidth Limit" >> capped.csv
for i in `cat /usr/local/src/bw_limit.txt`; do
{
bwlimit=`cat $i | grep -w "BandWidth all" | uniq | awk '{print $3}'`
capped_username=`echo $i | cut -d"/" -f9`
if [ -z != `ls /var/cpanel/users/$capped_username` ]
then
{
capped_domain=`echo $i | cut -d"/" -f10`
#echo "-----------------------------" >> cappedresults.txt
echo $hname ";" $capped_username ";" $capped_domain ";" $bwlimit >> capped.csv
#echo "---------" >> cappedresults.txt
#echo " " " " "Domain " " " "Bandwidth Limit" >> cappedresults.txt
#echo " " " " "$capped_domain" " " "$bwlimit" >> cappedresults.txt
#echo "-----------------------------" >> cappedresults.txt
}
else
echo "User doesnot exists : $capped_username"
fi
}
done
for j in `cat /usr/local/src/bw_limit1.txt`; do
{
bwlimit=`cat $j | grep -w "BandWidth all" | uniq | awk '{print $3}'`
capped_username=`echo $j | cut -d"/" -f9`
if [ -z != `ls /var/cpanel/users/$capped_username` ]
then
{
#echo "-----------------------------" >> cappedresults.txt
echo $hname ";" $capped_username ";" "All" ";" $bwlimit >> capped.csv
#echo "Username : $capped_username" "" >> cappedresults.txt
#echo "---------" >> cappedresults.txt
#echo " " " " "Domain " " " "Bandwidth Limit" >> cappedresults.txt
#if [ -z != `ls /var/cpanel/users/$capped_username` ]
#then
#{
#for k in `cat /var/cpanel/users/$capped_username | grep -i dns | cut -d"=" -f2`; do
#echo " " " " "$k" " " "$bwlimit" >> cappedresults.txt
#done
}
else
echo "User doesnot exists : $capped_username"
fi
}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment