2014-08-12
bandwidthd可以用來追蹤,並以圖型化、網頁化的方式來顯示TCP/IP網路中的使用
和MRTG 不同的是,'bandwidthd' 追蹤的是各別的IP 用量,而不像MRTG 是顯示某一網路介面的總量
CentOS 7.0 並沒有提供 Bandwidthd 套件, 要自己去下載安裝
http://bandwidthd.sourceforge.net/
小弟寫了一個快速安裝程式如下
(和 Fedora 主要差別是 OS 版本判斷; 判斷是否安裝時候, rpm 顯示訊息不同)
echo -e "\033[31m"
echo -e " BandWidthD 2.0.1 Install Shell Script (CentOS 7.0 x64_86) "
echo -e " by Lu 2014-08-12 "
echo -e "\033[0m"
DEBUG=n
if [ "`cat /proc/version | grep centos | grep el7`" != "" ]; then
OS="CentOS 6.x"
echo "Detection your OS is CentOS 7.x"
else
echo "[ERROR] Only Support CentOS 7.x"
exit
fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " ntpdate tick.stdtime.gov.tw "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mKill nptd on running...\033[0m"
ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
for i in $ProcessID
do
echo $i
kill -9 $i
done
ntpdate tick.stdtime.gov.tw
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " yum -y install something"
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mKill yum on running...\033[0m"
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
echo $i
kill -9 $i
done
echo -e "\033[32mCheck : yum -y install libpcap-devel libpng-devel gd-devel gcc httpd \033[0m"
YUMARGS=""
if [ "`rpm -q libpcap-devel | grep not`" != "" ]; then
YUMARGS="$YUMARGS libpcap-devel"
echo "libpcap-devel not installed"
else
echo "libpcap-devel installed"
fi
if [ "`rpm -q libpng-devel | grep not`" != "" ]; then
YUMARGS="$YUMARGS libpng-devel"
echo "libpng-devel not installed"
else
echo "libpng-devel installed"
fi
if [ "`rpm -q gd-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS gd-devel"
echo "gd-devel not installed"
else
echo "gd-devel installed"
fi
if [ "`rpm -q gcc | grep not `" != "" ]; then
YUMARGS="$YUMARGS gcc"
echo "gcc not installed"
else
echo "gcc installed"
fi
if [ "`rpm -q httpd | grep not`" != "" ]; then
YUMARGS="$YUMARGS httpd"
echo "httpd not installed"
else
echo "httpd installed"
fi
#echo $YUMARGS
if [ ! "$YUMARGS" == "" ]; then
rm -fr /var/cache/yum
echo -e "\033[32myum -y install $YUMARGS \033[0m"
yum -y install $YUMARGS
fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Install and Set BandWidthD"
echo -e "####################################"
echo -e "\033[0m"
cd /usr/local/src
if [ ! -s bandwidthd-2.0.1.gz ]; then
echo "bandwidth-2.0.1.gz not found ! Please download from http://bandwidthd.sourceforge.net/ "
wget "http://nchc.dl.sourceforge.net/project/bandwidthd/bandwidthd/bandwidthd%202.0.1/bandwidthd-2.0.1.tgz"
else
echo "bandwidth-2.0.1.gz found !"
echo " "
fi
echo -e "\033[32mtar zxvf bandwidthd-2.0.1.tgz \033[0m"
tar zxvf bandwidthd-2.0.1.tgz
echo -e "\033[32mcd bandwidthd-2.0.1 \033[0m"
cd bandwidthd-2.0.1
pwd
echo -e "\033[32m./configure \033[0m"
./configure
echo -e "\033[32mmake \033[0m"
make
echo -e "\033[32mmake install \033[0m"
make install
echo -e "\033[32mvi /etc/httpd/conf.d/bandwidthd.conf \033[0m"
echo "Alias /bandwidthd /usr/local/bandwidthd/htdocs" > /etc/httpd/conf.d/bandwidthd.conf
echo "<Location /bandwidthd>" >> /etc/httpd/conf.d/bandwidthd.conf
echo " Order deny,allow" >> /etc/httpd/conf.d/bandwidthd.conf
echo "# Deny from all" >> /etc/httpd/conf.d/bandwidthd.conf
echo " Allow from 127.0.0.1" >> /etc/httpd/conf.d/bandwidthd.conf
echo " Allow from ::1" >> /etc/httpd/conf.d/bandwidthd.conf
echo " # Allow from .example.com" >> /etc/httpd/conf.d/bandwidthd.conf
echo "</Location>" >> /etc/httpd/conf.d/bandwidthd.conf
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Run bandwidthd "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mchkconfig httpd on \033[0m"
#chkconfig httpd on
systemctl enable httpd
echo -e "\033[32mservice httpd start \033[0m"
#service httpd start
systemctl restart httpd
echo
# 要永久開放 http port,可執行
firewall-cmd --permanent --add-service=http
systemctl restart firewalld
#停掉防火牆
#systemctl stop firewalld
echo -e "\033[32mBandWidthD Config : /usr/local/bandwidthd/etc/bandwidthd.conf \033[0m"
echo -e "\033[32m modify subnet \033[0m"
echo -e "\033[32mhttpd Config : /etc/httpd/conf.d/bandwidthd.conf \033[0m"
echo
echo -e "\033[32mkillall bandwidthd \033[0m"
killall bandwidthd
echo -e "\033[32mcd /usr/local/bandwidthd \033[0m"
# You must run bandwidthd on special directory, else index.html will be generated on other directory
cd /usr/local/bandwidthd
pwd
echo -e "\033[32m/usr/local/bandwidthd/bandwidthd \033[0m"
/usr/local/bandwidthd/bandwidthd
# 如果要偵測所有來源, 可以修改 /usr/local/bandwidthd/etc/bandwidthd.conf
# 的 subnet (其他 subnet 註解掉)
# subnet 0.0.0.0/0
echo -e "\033[32mfirefox http://localhost/bandwidthd & \033[0m"
firefox http://localhost/bandwidthd &
|
最後執行的時候失敗
[root@localhost bandwidthd-2.0.1]# /usr/local/bandwidthd/bandwidthd
[root@localhost bandwidthd-2.0.1]# Error: NFLOG link-layer type filtering not implemented
Malformed libpcap filter string in bandwidthd.conf
Error: NFLOG link-layer type filtering not implemented
Malformed libpcap filter string in bandwidthd.conf
Error: NFLOG link-layer type filtering not implemented
Malformed libpcap filter string in bandwidthd.conf
Error: NFLOG link-layer type filtering not implemented
Malformed libpcap filter string in bandwidthd.conf
[root@localhost bandwidthd-2.0.1]#
(待研究...)
相關文章
[研究] Bandwidthd 2.0.1 快速安裝程式(tar.gz)(CentOS 7.0 x64_86)(失敗)
http://shaurong.blogspot.com/2014/08/bandwidthd-201-targzcentos-70-x6486.html
[研究] Bandwidthd 2.0.1 快速安裝程式 (CentOS 6.5 x64_86)
http://shaurong.blogspot.com/2014/08/bandwidthd-201-targzcentos-65-x6486.html
[研究] Bandwidthd 2.0.1 快速安裝程式 (CentOS 6.3 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=79310
[研究] Bandwidthd 2.0.1 快速安裝程式 (CentOS 6.0 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20227
[研究] Bandwidthd 2.0.1 快速安裝程式(tar.gz)(CentOS 5.1)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14852
[研究] Bandwidthd 2.0.1 快速安裝程式 (Fedora 16 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=21202
[研究] Bandwidthd 2.0.1快速安裝程式(yum) (Fedora 14,15 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19139
[研究] Bandwidthd 2.0.1快速安裝程式精簡版(tar.gz)(Fedora 8 )
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14887
[研究] Bandwidthd 2.0.1快速安裝程式精簡版(tar.gz)(Fedora 7)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14978
[研究] Bandwidthd 2.0.1快速安裝程式(tar.gz)(Fedora 7)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14848
[研究] Bandwidthd 2.0.1 快速安裝程式精簡版(tar.gz)(Ubuntu 8.04)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14951
[研究] Bandwidthd 2.0.1快速安裝程式精簡版(tar.gz)(Ubuntu 7.10)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14904
[研究] Bandwidthd 2.0.1快速安裝程式精簡版(ports)(FreeBSD 7.0)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14907
[研究] Bandwidthd 2.0.1快速安裝程式精簡版(tar.gz)(Debian 4.0r3)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14902
沒有留言:
張貼留言