查看完整版本: 在 CentOS 6.x 版安裝 install mrtg


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&nbsp;&nbsp; 網頁伺服器</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>&nbsp;</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>&nbsp;</p>
<p><font color="Blue" size="3">三、設定SNMP</font></p>
<p>1.vi /etc/snmp/snmpd.conf</p>
<p>&nbsp; 找到<span class="fullpost">com2sec notConfigUser default public</span></p>
<p><span class="fullpost">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 改為</span></p>
<p><span class="fullpost">&nbsp;&nbsp; #com2sec notConfigUser&nbsp; default&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public<br>&nbsp;&nbsp; &nbsp; com2sec local localhost public<br>&nbsp;&nbsp;&nbsp;&nbsp; com2sec mynetwork 你自己主機的ip public</span></p>
<p><br></p><p>2. 再來是找 group notConfigGroup v1 notConfigUser 這一段,然後改成如下所示:<br><br>&nbsp;&nbsp;&nbsp; #group notConfigGroup v1 notConfigUser<br>&nbsp;&nbsp;&nbsp; #group notConfigGroup v2c notConfigUser<br>&nbsp;&nbsp;&nbsp; group MyRWGroup v1 local<br>&nbsp;&nbsp;&nbsp; group MyRWGroup v2c local<br>&nbsp;&nbsp;&nbsp; group MyROGroup v1 mynetwork<br>&nbsp;&nbsp;&nbsp; group MyROGroup v2c mynetwork</p><p><br></p><p>3. 接著是找 view all included .1 80 這一段,然後改成如下所示:(把前面的 # 去掉)<br><br>&nbsp;&nbsp;&nbsp; ## incl/excl subtree mask<br>&nbsp;&nbsp;&nbsp; view all included .1 80<br><br>4. 找到 #access MyROGroup "" any noauth 0 all none none 這一段,改成如下所示:<br><br>&nbsp;&nbsp;&nbsp; #access MyROGroup "" any noauth 0 all none none<br>&nbsp;&nbsp;&nbsp; #access MyRWGroup "" any noauth 0 all all all<br>&nbsp;&nbsp;&nbsp; access MyROGroup "" any noauth prefix all none none<br>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.使用cfgmaker產出設定檔</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [root@adj ~]# cfgmaker --global 'WorkDir: /var/www/mrtg' --output /etc/mrtg/mrtg.cfg public@localhost</p><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #產生基本網頁<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #執行 3 次下面指令, 產生基本網頁<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg<br>
<br><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.產出網頁</p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp; [root@adj ~]# indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg<br></code></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.重新啟動apache</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service httpd restart</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.測試</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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&amp;調整編碼</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>
頁: [1]
查看完整版本: 在 CentOS 6.x 版安裝 install mrtg