查看完整版本: NTOP Network Monitor-- 讓網路流量完全透明化


adj 2007-11-14 21:08

NTOP Network Monitor-- 讓網路流量完全透明化

<FONT color=#6600cc><B>一.前言</B></FONT><BR>相信大家在管理公司網路流量的時後...面對Mrtg圖時...明明就知道整個流量是Peak的狀態...但就是不知道那台電腦在Download或者上傳資料...以致於整個Network bandwidth都塞爆...還得一台一台去查那台電腦流量很" busy "...這樣不是很累嗎?現在得知有 ntop 這樣好用的工具...實在是大家的福氣ㄌㄟ...安裝時可以參考NetMan兄的<A href="http://www.study-area.net/tips/ntop.htm" target=_blank><FONT color=#0000ff>如何設定 ntop </FONT></A>文件...或是直接看Readme都有教你如何安裝...做法大同小異...只是在compiler的過程中也許會遇到一些狀況...要想辦法排除就是...<BR>還有..如果你是把 ntop 放到NAT上來執行時...看你平常的流量會不會很大...以及NAT那台電腦是不是夠強啦...像偶們本身是用celeron 400的電腦來當做內部的NAT...平常有幾十G的流量在跑...圖形化的 ntop常常會停掉...而且也不能達到我要的即時知道內部電腦的流量狀況...這時你可以選用文字模式來監控(intop)...它雖然沒有Web介面來的好...不過 intop 比較符合大家的需求...web界面只是比較炫而已...<BR><FONT color=#6600cc><B><BR>二.準備</B></FONT><BR>測試系統: Red Hat Linux 7.1 and 7.3 都裝過沒問題...<BR><BR><FONT size=4><FONT color=red>官方網站:</FONT></FONT><BR>

<BR><A href="http://www.ntop.org/ntop.html" target=_blank><FONT color=black>NTOP Network Monitor</FONT></A><FONT color=black> </FONT><BR><BR>目前它有分Stable and Preview的版本...兩種也都裝過...<BR>Stable(2.0) : <A href="http://snapshot.ntop.org/stable/ntop-2.0-src.tgz" target=_blank><FONT color=#0000ff>http://snapshot.ntop.org/stable/ntop-2.0-src.tgz</FONT></A><BR>Preview(2.0.99) : <A href="http://snapshot.ntop.org/tgz/ntop-current.tgz" target=_blank><FONT color=#0000ff>http://snapshot.ntop.org/tgz/ntop-current.tgz</FONT></A><BR><B><FONT color=#0000ff></FONT></B><BR><FONT color=#6600cc><B><BR>三.開始實作</B></FONT><BR><FONT size=4><FONT color=blue>1.開始進行解壓工作(以Preview版本為例)</FONT></FONT>﹕ <BR><BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD>[root@mondeo home]# tar zxvf ntop-current.tgz</TD></TR></TBODY></TABLE>先compiler gdchart<BR><BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD>[root@mondeo home]# cd ntop-current/gdchart0.94c<BR>[root@linux gdchart0.94c]# ./configure . <BR>. <BR>Do not forget to build: <BR>1. gd-1.8.3/libpng-1.2.1<BR>2. zlib-1.1.4/</TD></TR></TBODY></TABLE><BR>最後會看到提醒你要build libpng and zlib.......再繼續下一步之前...必須先compiler 那兩樣...先build libpng...<BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD>[root@linux gdchart0.94c]# cd gd-1.8.3/libpng-1.2.1/<BR>[root@linux libpng-1.2.1]# cp scripts/makefile.linux Makefile<BR>[root@linux libpng-1.2.1]# make</TD></TR></TBODY></TABLE><BR>再build zlib﹕ <BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD>[root@linux gdchart0.94c]# cd ../../zlib-1.1.4<BR>[root@linux zlib-1.1.4]# ./configure<BR>[root@linux zlib-1.1.4]# make</TD></TR></TBODY></TABLE><BR>再來就可以compiler gdchart:<BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD><FONT size=3>[root@linux zlib-1.1.4]# cd ..<BR>[root@linux gdchart0.94c]# make</FONT></TD></TR></TBODY></TABLE>gdchart的部份到這邊告一段落...接下來主角上場 ntop ... <BR><BR><FONT color=blue><FONT size=4>2. Compiler ntop:</FONT> <BR></FONT>回到 ntop 目錄
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD><FONT size=3>[root@linux gdchart0.94c]# cd ../ntop/<BR>[root@linux ntop]# ./configure</FONT></TD></TR></TBODY></TABLE><BR>這個部份有遇到一些問題...因為通常NAT不會裝mysql...不過它預設是會去認mysql...所以如果你也有遇到mysql的問題的話...可以加個參數 --disable-mysql 把mysql給disable掉..下一步... <BR><BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD><FONT size=3>[root@linux ntop]# make</FONT></TD></TR></TBODY></TABLE>這部份會花比較久的時間...document上面有說可以make check看看...個人是覺得不用啦...因為這會多花大概一倍的時間來做這件事...有點多此一舉...接著再﹕ <BR><BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD>
<P align=left><FONT size=3>[root@linux ntop]# make install</FONT></P></TD></TR></TBODY></TABLE>如果都沒錯誤訊息的話...那你就成功啦..你就可以看到有ntop 以及 intop 可以使用...只剩如何執行它... <BR><BR><FONT size=4><FONT color=blue>3. 執行 ntop: 這邊先介紹圖形化介面..也就是web界面:</FONT> <BR></FONT>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD><FONT size=3>[root@linux ntop]# ntop -P /tmp -u nobody </FONT></TD></TR></TBODY></TABLE><BR>第一次執行它會要你輸入admin的password...它預設密碼也是admin...第二次執行就不用再輸入..這時你可以打開web browser..<BR>輸入: http://&lt;your_IP&gt;:3000 你就會看到如下圖Sample_1 (Network Load Statistics)...這是2.0.0的圖形化界面: <BR><BR>[img]http://dz.adj.idv.tw/attachment.php?aid=8[/img]<BR><BR>Sample_2(Global Protocol Distribution): <BR>[img]http://dz.adj.idv.tw/attachment.php?aid=9[/img]<BR><BR><BR>不過你會發現...執行上面指令會把terminal視窗佔住...你可以先"ctrl+z"先 stop 住...再下" bg %1"(假設它在你的jobs裡數字是1)...<BR>這樣就可以丟到背景執行...或是重新執行下面指令:
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD><FONT size=3>[root@linux ntop]# nohup ntop -P /tmp -u nobody &amp;</FONT></TD></TR></TBODY></TABLE><BR>這樣就可以讓你丟到background and leave this terminal don't stop this command....當然你也可以把這行加到/etc/rc.d/rc.local的最後一行...讓它一開機就自動執行...它還有許許多多的參數...你可以從web上來看看需要加上那些...。<BR><BR><FONT size=4><FONT color=blue>4.文字模式(intop):</FONT></FONT> <BR>文字模式個人比較常用...因為它不會在流量很大的時後...讓你的系統 loading 很重...而且得到的資訊是我比較想要的..由於執行後會產生幾個檔...因此建一個你自己要拿來存放的目錄比較不會搞混﹕<BR><BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD><FONT size=3>[root@linux ntop]# intop</FONT><BR>-- intop 0.0.1 (Jul 1 2002) -- The first interactive ntop program.<BR>(C) Copyright 2000 L. Deri and R. Carbone. All rights reserved.<BR>It allows you to control the power of ntop using fingers rather than mouse!<BR>This program is free software; you can redistribute it and/or modify<BR>it under the terms of the GNU General Public License as published by<BR>the Free Software Foundation; either version 2 of the License, or<BR>(at your option) any later version.<BR>This program is distributed in the hope that it will be useful,<BR>but WITHOUT ANY WARRANTY; without even the implied warranty of<BR>MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<BR>GNU General Public License for more details.<BR>Initializing intop engine.... Please wait.<BR>01/Jul/2002 23:45:24 Initializing IP services...<BR>01/Jul/2002 23:45:24 Initializing GDBM...<BR>01/Jul/2002 23:45:24 Resetting traffic statistics...<BR>01/Jul/2002 23:45:25 Started thread (1026) for network packet analyser.<BR>01/Jul/2002 23:45:25 Started thread (2051) for DNS address resolution.<BR>01/Jul/2002 23:45:25 Started thread (3076) for address purge.<BR>Type ? for help.<BR><BR>intop&gt; </TD></TR></TBODY></TABLE><BR>看到這個後...可以打? for help....或是來監聽網卡上面的流量:<BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD>intop&gt;sniff -i eth001/Jul/2002 23:47:16 Initializing network devices...<BR>01/Jul/2002 23:47:16 Truncated network size to 1024 hosts (real netmask 255.255.255.0)<BR>01/Jul/2002 23:47:16 Resetting traffic statistics...<BR>01/Jul/2002 23:47:16 Resetting traffic statistics...<BR>starting sniffer on eth0 (with no filter enabled)...<BR>intop@eth0&gt;<BR></TD></TR></TBODY></TABLE>這時後打top...就是你想要的資訊囉...公司那台電腦比較 busy...原則上都知道了...<BR>
<TABLE style="BACKGROUND: #ffffcc" class=t_table width="97%">
<TBODY>
<TR>
<TD><A href="mailto:intop@eth0" target=_blank>intop@eth0&gt;top</A> <BR>intop 0.0.1 (Jul&nbsp;&nbsp;1 2002) listening on [eth0]43 Pkts/5.7 Kb [IP 4.9 Kb/Other 828]&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Thpt: 0.0 /0.0<BR>Host&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Act&nbsp; &nbsp;-Rcvd-&nbsp; &nbsp;&nbsp; &nbsp;Sent&nbsp; &nbsp;&nbsp; &nbsp; TCP&nbsp; &nbsp;&nbsp; &nbsp; UDP&nbsp; &nbsp;&nbsp;&nbsp;ICMP<BR>192.168.0.2&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;B&nbsp; &nbsp; 3.7 Kb&nbsp; &nbsp; 1.3 Kb&nbsp; &nbsp; 3.7 Kb&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;0&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0<BR>192.168.0.10&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;B&nbsp; &nbsp; 1.3 Kb&nbsp; &nbsp; 3.8 Kb&nbsp; &nbsp; 1.1 Kb&nbsp; &nbsp;&nbsp; &nbsp; 162&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0<BR>kelly&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;S&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;0&nbsp; &nbsp;&nbsp; &nbsp; 243&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;0&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;0&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0<BR></TD></TR></TBODY></TABLE>執行的大概情形就是如上....<BR><FONT color=#6600cc><BR></FONT><FONT color=blue><FONT size=4>5.大功告成</FONT></FONT><BR>做到這個階段...算是大功告成...趕緊找一台機器來試試吧...從此內部電腦的流量就透明化啦...<BR>以上只是個人測試結果...如有錯誤...煩請指教!!!
頁: [1]
查看完整版本: NTOP Network Monitor-- 讓網路流量完全透明化