bandwidthd 安装记(转帖是为了不重复造轮子哈哈)

来源:互联网 发布:mac xlplayer 卸载 编辑:程序博客网 时间:2024/05/05 11:07
  • 實作系統:CentOS 4.5 Server, 核心版本:2.6.9-55.EL
  • 實作配備:PⅡ Celeron 450 + 256 RAM ( 剛好可以證明:「這是真的。」跟隨者:「真的~~~」 )

  • 官方網站:http://bandwidthd.sourceforge.net/
  • 官方Demo網址:http://bandwidthd.sourceforge.net/demo/
  • 下載點:http://nchc.dl.sourceforge.net/sourceforge/bandwidthd/bandwidthd-2.0.1.tgz
  目前最新版本為 2.0.1 (2007/5/23),而且他還有提供Windows版本,真的是太棒了。
  先以 root 登入:
  • wget http://nchc.dl.sourceforge.net/sourceforge/bandwidthd/bandwidthd-2.0.1.tgz
  • tar -xzvf bandwidthd-2.0.1.tgz
  • cd bandwidthd-2.0.1
  在安裝之前,我們先看看 README / INSTALL.Unix ,發現有些東西必須先確認一下,你必須確認有安裝以下函式庫:
  • libpcap ( http://www.tcpdump.org/ )
  • libpng (http://www.libpng.org/ )
  • libgd ( http://www.boutell.com/gd/ )
  檢查一下:
  • rpm -qa | grep libpcap
    找出:libpcap-0.8.3-10.RHEL4
  • rpm -qa | grep libpng
    找出:libpng-1.2.7-3.el4
  • rpm -qa | grep libgd
  你會發現,最後一個 libgd 會是空白的,沒關係,這跟等一下的錯誤有關哦!如果沒有安裝的話,建議使用 yum 來安裝。
  • yum -y install libpcap*
  • yum -y install libpng*
  • yum -y install libgd* (不會安裝任何套件,裝孝為嗎?請往下看,大人。)
  建議把第二個 libpng 執行一下,因為我發現有另一個 libpng10 的套件,而且我未安裝 libpng10 套件時,會出現以下錯誤訊息:
  • configure: error: Bandwidthd requires but cannot libpng
很明顯的,它是使用 libpng10 而不是使用系統內建的 libpng,然後開始安裝吧:
  • ./configure && make install
不過在configure時一直出現以下的錯誤:
  • configure: error: Bandwidthd requires but cannot find libgd
  找又找不到(rpm),安裝也沒有東西(yum),是怎樣!!! (集氣完快成了{..ooOO}!) 到網站看看有沒有什麼資訊( 網站上說:The GD library has moved to http://www.libgd.org/ ), 發現套件名稱都是以 gd 為開頭,那試試 yum search gd,果然找到一堆套件,還好我試了第一次就OK了,不然可能要發功放氣一下才行了!(本來在另一台主機測試時,是直接使用 yum install gd* ,馬上就OK了,但想想有需要安裝那怎多東西嗎?所以就再找一台來試,結果在 CentOS4.4/4.5 情況都一樣,在非常Luck的情況下,試了第一個套件就成功,還好還好,汗~~~)
  • yum install gd-devel <-- 兇手就是他,看我的元氣彈!!!
  再重新configure一次
  • ./configure && make install
  成功了,沒有錯誤訊息了。 安裝完成後,它會將 bandwidthd 安裝至 /usr/local/bandwidthd 下,接下來就是 bandwidthd 超級簡單的設定,請編輯:
  • vi /usr/local/bandwidthd/etc/bandwidthd.conf
  在第 10, 11, 12 行,把這三行註解(#):
  • # subnet 10.0.0.0 255.0.0.0
  • # subnet 192.168.0.0/16
  • # subnet 172.16.0.0/12
   最後加上一行自己網域的設定:
  • subnet 192.168.1.0/24
 一個Intranet, Class C, 指定你要統計的subnet,全部的設定就只有一行,超簡單吧!存檔之後,便可準備執行。執行bandwidthd:
  • cd /usr/local/bandwidthd
  • ./bandwidthd
然後我們只要在 web 主目錄建立一個Link即可:
  • cd /var/www/html
  • ln -s /usr/local/bandwidthd/htdocs bw ( 目錄名稱自己決定 )
接著您需要等個幾分鐘,便可用 http://IP/bw or http://domain/bw 看到網路中各主機的頻寬使用情況!
注意一
再來因為這個程式是使用 C 語言所寫,所以你的系統必須要有 gcc 和相關的套件,如果你在 configure 時會出現:
  make: cc: Command not found
  或是
  configure: error: no acceptable cc found in $PATH
那怎請先把 gcc 安裝起來。我的 CentOS4.4 剛裝完時,還真的沒有 gcc ,產生了第二個錯誤訊息:
  yum -y install gcc*
或是把 gcc 升級到最新版本:
  yum -y update gcc*
應該就可以解決 configure 時的問題了。

 

注意二
以下是 bandwidthd 的 README 中倒數第二段,有一段話:

By default, Bandwidthd now runs in promiscuous mode. This means it can be used to monitor traffic not routing through it's host. Just make sure that the host and the actual router are on the same hub (Not switch) and everything will be ok.
注意那個粗體字,所以,請把 Bandwidthd 的主機與你的骨幹用hub連接,應該就會有所有的流量了。或者,如果你的nat或router是自己架的Linux,那就直接裝在 nat / router 主機上也行。
Windows 安裝 Bandwidthd
  Bandwidthd 在 Windows 的安裝,更簡單100倍。我們快來看看!
  1. 先把檔案下載回來:http://nchc.dl.sourceforge.net/sourceforge/bandwidthd/bandwidthd-2.0.1-binary-windows.zip
  2. 解 壓縮後,會產生一個 bandwidthd 的目錄,移到你要放 program 的地方(一般是放到 /program file/ 之下)。然後先看一下 README.txt 和 INSTALL.Windows.txt 有一件事要確認,你是否有安裝 Winpcap 這個軟體,如果沒有的話,請先下載:http://www.winpcap.org/ ,最新版是 winpcap 4.0。
  3. 然後,修改 bandwidthd/etc/bandwidthd.conf ,將你要統計的 subnet 設定上去,存檔。
  4. 點擊 "Install Service.bat" 這支程式,把 bandwidthd 安裝到 Windows系統服務中。
  5. 「開始」--> 「我的電腦」 --> 滑鼠按右鍵 --> 「管理」 --> 「服務及應用程式」 --> 「服務」 --> 「 bandwidthd 」
  如果要停止 bandwidthd.exe 必須使用 「 Windows 工作管理員 」來直接停用四個 bandwidthd.exe。另外要注意,是否有 cygrunsrv.exe 這支程式,有的話一併Kill。 如果要把 bandwidthd 從「服務」中移除,請先把所有 bandwidthd 工作停止,然後點擊 "UnInstall Service.bat" 這支程式就可以了。
要看統計的結果,進入 bandwidthd/htdocs 點擊 index.html 就可以看到美美統計圖形了。可以開始抓……山豬了。
原创粉丝点击