linux 2014-8-19 10:39
在 CentOS 6.x 版安裝 install mrtg
<p>安裝MRTG 監控網路流量,透過SNMP協定擷取網路流量資料,並使用網頁瀏覽流量報表~</p><p><br></p>
<p><font color="Blue" size="3">一、安裝必要套件說明</font></p>
<p>1.httpd 網頁伺服器</p>
<p>2.mrtg mrtg主程式</p>
<p>3.mrtg-libs</p>
<p>4.net-snmp</p>
<p>5.net-snmp-utils</p>
<p>6.perl</p>
<p>7.gd</p>
<p> </p>
<p><font color="Blue" size="3">二、執行安裝</font></p>
<p>yum install -y httpd mrtg mrtg-libs net-snmp net-snmp-utils perl gd</p>
<p> </p>
<p><font color="Blue" size="3">三、設定SNMP</font></p>
<p>1.vi /etc/snmp/snmpd.conf</p>
<p> 找到<span class="fullpost">com2sec notConfigUser default public</span></p>
<p><span class="fullpost"> 改為</span></p>
<p><span class="fullpost"> #com2sec notConfigUser default public<br> com2sec local localhost public<br> com2sec mynetwork 你自己主機的ip public</span></p>
<p><br></p><p>2. 再來是找 group notConfigGroup v1 notConfigUser 這一段,然後改成如下所示:<br><br> #group notConfigGroup v1 notConfigUser<br> #group notConfigGroup v2c notConfigUser<br> group MyRWGroup v1 local<br> group MyRWGroup v2c local<br> group MyROGroup v1 mynetwork<br> group MyROGroup v2c mynetwork</p><p><br></p><p>3. 接著是找 view all included .1 80 這一段,然後改成如下所示:(把前面的 # 去掉)<br><br> ## incl/excl subtree mask<br> view all included .1 80<br><br>4. 找到 #access MyROGroup "" any noauth 0 all none none 這一段,改成如下所示:<br><br> #access MyROGroup "" any noauth 0 all none none<br> #access MyRWGroup "" any noauth 0 all all all<br> access MyROGroup "" any noauth prefix all none none<br> access MyRWGroup "" any noauth prefix all all all<br><span class="fullpost"></span></p><p><br><span class="fullpost"></span></p><p><span class="fullpost">存檔後重新啟動 snmpd<br></span></p><p><span class="fullpost"></span></p>
<p><span class="fullpost"># service snmpd restart</span></p><p># chkconfig snmpd on</p>
<p><br></p><p><font color="Blue" size="3">四、設定MRTG</font></p>
<p> 1.使用cfgmaker產出設定檔</p>
<p> [root@adj ~]# cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg/mrtg.cfg public@localhost</p><br> #產生基本網頁<br> #執行 3 次下面指令, 產生基本網頁<br> env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg<br> env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg<br> env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg<br>
<br><p> 2.產出網頁</p>
<p><code> [root@adj ~]# indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg<br></code></p>
<p> 3.重新啟動apache</p>
<p> service httpd restart</p>
<p> 4.測試</p>
<p> http://127.0.0.1/mrtg</p><p><br></p>
<p><font color="Blue" size="3">五、設定每5分鐘收集一次流量資訊</font></p>
<p>執行crontab -e<br><br>於檔案中加上下列文字後檔離開<br>*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg</p><p><br></p><p><font color="Blue" size="3">六、開放其他機器查詢MRTG&調整編碼</font><br>
<br>
# vi /etc/httpd/conf.d/mrtg.conf</p><p>將 Allow from 127.0.0.1</p><p>改成 Allow from 127.0.0.1 <font color="Red">11.22..33.44/24</font></p><p><br></p><p>Apache 重新整理過後...這樣就可以啦~~<font color="Red"><br></font>
</p>