TShopping

 找回密碼
 註冊
搜索
查看: 3086|回復: 2

[教學] Bandwidthd 快速安裝程式 (CentOS 5.1)

[複製鏈接]
發表於 2008-6-2 14:34:36 | 顯示全部樓層 |閱讀模式
 
Push to Facebook Push to Plurk Push to Twitter 
bandwidthd可以用來追蹤,並以圖型化、網頁化的方式來顯示TCP/IP網路中的使用
和MRTG 不同的是,'bandwidthd' 追蹤的是各別的IP 用量,而不像MRTG 是顯示某一網路介面的總量

CentOS 5.1 並沒有提供 Bandwidthd 套件, 要自己去下載安裝

http://bandwidthd.sourceforge.net/

小弟寫了一個快速安裝程式如下
(和 Fedora 7主要差別是 OS 版本判斷; 判斷是否安裝時候, rpm 顯示訊息不同)
  1. echo -e "\033[31m"
  2. echo -e " BandWidthD 2.0.1 Install Shell Script (CentOS 5.1) "
  3. echo -e " by lu 2008/04/17 "
  4. echo -e "\033[0m"


  5. DEBUG=n

  6. if [ "`cat /proc/version | grep centos | grep el5`" != "" ]; then
  7.    OS="CentOS 5.x"
  8.    echo "Detection your OS is CentOS 5.x"
  9. else
  10.    echo "[ERROR] Only Support CentOS 5.x"
  11.    exit
  12. fi

  13. echo -e "\033[31m"
  14. echo -e "############# Step ###############"
  15. echo -e " ntpdate tick.stdtime.gov.tw "
  16. echo -e "####################################"
  17. echo -e "\033[0m"

  18. echo -e "\033[32mKill nptd on running...\033[0m"
  19. ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
  20. for i in $ProcessID
  21. do
  22.    echo $i
  23.    kill -9 $i
  24. done
  25. ntpdate tick.stdtime.gov.tw
  26. if [ "$DEBUG" == "y" ]; then echo "ress any key to continue..." ; read ; fi

  27. echo -e "\033[31m"
  28. echo -e "############# Step ###############"
  29. echo -e " yum -y install something"
  30. echo -e "####################################"
  31. echo -e "\033[0m"


  32. echo -e "\033[32mKill yum on running...\033[0m"
  33. ProcessID="`ps aux | grep yum | awk '{print $2}' `"
  34. for i in $ProcessID
  35. do
  36.    echo $i
  37.    kill -9 $i
  38. done
  39. echo -e "\033[32mCheck : libpcap-devel libpng-devel gd-devel gcc httpd \033[0m"

  40. YUMARGS=""

  41. if [ "`rpm -q libpcap-devel | grep not`" != "" ]; then
  42.    YUMARGS="$YUMARGS libpcap-devel"
  43.    echo "libpcap-devel not installed"
  44. else      
  45.    echo "libpcap-devel installed"  
  46. fi  

  47. if [ "`rpm -q libpng-devel | grep not`" != "" ]; then
  48.    YUMARGS="$YUMARGS libpng-devel"
  49.    echo "libpng-devel not installed"
  50. else
  51.    echo "libpng-devel installed"  
  52. fi  

  53. if [ "`rpm -q gd-devel | grep not `" != "" ]; then
  54.    YUMARGS="$YUMARGS gd-devel"
  55.    echo "gd-devel not installed"
  56. else  
  57.    echo "gd-devel installed"
  58. fi  

  59. if [ "`rpm -q gcc | grep not `" != "" ]; then
  60.    YUMARGS="$YUMARGS gcc"
  61.    echo "gcc not installed"
  62. else
  63.    echo "gcc installed"  
  64. fi

  65. if [ "`rpm -q httpd | grep not`" != "" ]; then
  66.    YUMARGS="$YUMARGS httpd"
  67.    echo "httpd not installed"
  68. else
  69.    echo "httpd installed"  
  70. fi

  71. #echo $YUMARGS

  72. if [ ! "$YUMARGS" == "" ]; then
  73.    rm -fr /var/cache/yum
  74.    echo -e "\033[32myum -y install $YUMARGS \033[0m"  
  75.    yum -y install $YUMARGS
  76. fi

  77. echo -e "\033[31m"
  78. echo -e "############# Step ###############"
  79. echo -e " Install and Set BandWidthD"
  80. echo -e "####################################"
  81. echo -e "\033[0m"

  82. if [ ! -s bandwidthd-2.0.1.tgz ]; then
  83.    echo "bandwidth-2.0.1.tgz not found ! Please download from http://bandwidthd.sourceforge.net/ "
  84.    exit
  85. else
  86.    echo "bandwidth-2.0.1.tgz found !"
  87.    echo " "
  88. fi

  89. echo -e "\033[32mtar zxvf bandwidthd-2.0.1.tgz \033[0m"
  90. tar zxvf bandwidthd-2.0.1.tgz

  91. echo -e "\033[32mcd bandwidthd-2.0.1 \033[0m"
  92. cd bandwidthd-2.0.1
  93. pwd

  94. echo -e "\033[32m./configure \033[0m"
  95. ./configure

  96. echo -e "\033[32mmake \033[0m"
  97. make

  98. echo -e "\033[32mmake install \033[0m"
  99. make install

  100. echo -e "\033[32mvi /etc/httpd/conf.d/bandwidthd.conf \033[0m"

  101. echo "Alias /bandwidthd /usr/local/bandwidthd/htdocs"  >  /etc/httpd/conf.d/bandwidthd.conf
  102. echo "<Location /bandwidthd>"  >>  /etc/httpd/conf.d/bandwidthd.conf
  103. echo "    Order deny,allow"  >>  /etc/httpd/conf.d/bandwidthd.conf
  104. echo "#    Deny from all"  >>  /etc/httpd/conf.d/bandwidthd.conf
  105. echo "    Allow from 127.0.0.1"  >>  /etc/httpd/conf.d/bandwidthd.conf
  106. echo "    Allow from ::1"  >>  /etc/httpd/conf.d/bandwidthd.conf
  107. echo "    # Allow from .example.com"  >>  /etc/httpd/conf.d/bandwidthd.conf
  108. echo "</Location>"  >>  /etc/httpd/conf.d/bandwidthd.conf

  109. if [ "$DEBUG" == "y" ]; then echo "ress any key to continue..." ; read ; fi

  110. echo -e "\033[31m"
  111. echo -e "############# Step ###############"
  112. echo -e " Run bandwidthd "
  113. echo -e "####################################"
  114. echo -e "\033[0m"

  115. echo -e "\033[32mchkconfig httpd on \033[0m"
  116. chkconfig httpd on
  117. echo -e "\033[32mservice httpd start \033[0m"
  118. service httpd start
  119. echo

  120. echo -e "\033[32mBandWidthD Config : /usr/local/bandwidthd/etc/bandwidthd.conf \033[0m"
  121. echo -e "\033[32m                    modify subnet \033[0m"
  122. echo -e "\033[32mhttpd Config : /etc/httpd/conf.d/bandwidthd.conf \033[0m"
  123. echo

  124. echo -e "\033[32mkillall bandwidthd \033[0m"
  125. killall bandwidthd

  126. echo -e "\033[32mcd /usr/local/bandwidthd \033[0m"
  127. # You must run bandwidthd on special directory, else index.html will be generated on other directory
  128. cd /usr/local/bandwidthd
  129. pwd
  130. echo -e "\033[32m/usr/local/bandwidthd/bandwidthd \033[0m"
  131. /usr/local/bandwidthd/bandwidthd

  132. echo -e "\033[32mfirefox http://localhost/bandwidthd & \033[0m"
  133. firefox http://localhost/bandwidthd &
複製代碼

 

臉書網友討論
 樓主| 發表於 2008-6-2 14:38:14 | 顯示全部樓層
發表於 2009-2-22 13:34:28 | 顯示全部樓層
真的是太好了
長智識


您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2016-12-3 20:45 , Processed in 0.056799 second(s), 19 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表