2013年2月9日 星期六

[研究] MRTG 2.16.2 安裝(yum)(CentOS 6.3 x86)


[研究] MRTG 2.16.2 安裝(yum)(CentOS 6.3 x86)

2013-02-09
Lu
(不建議直接轉貼內容,隨時會修改)

MRTG官方安裝方法
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html 

(1) 安裝基本套件



yum  -y  install   perl gd libpng zlib mrtg httpd net-snmp net-snmp-utils






(2) 設定與啟動 SNMP



vi /etc/snmp/snmpd.conf






增加兩行



view systemview included .1.3.6.1.2.1.2.2.1.10
view systemview included .1.3.6.1.2.1.2.2.1.16







數值意義請參考
http://oss.oetiker.ch/mrtg/doc/mrtg-mibhelp.en.html



service snmpd restart






(3) 設定 MRTG



vi  /etc/mrtg/mrtg.cfg







增加




Target[eth0]: 2:public@127.0.0.1
MaxBytes[eth0]: 1250000
Title[eth0]: Traffic Analysis
PageTop[eth0]: <H1>127.0.0.1 eth0</H1>










public 前面的數字可用下面偵測, 一般 eth0 代號是 2



[root@localhost ~]# ip link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:21:6d:3c brd ff:ff:ff:ff:ff:ff
[root@localhost ~]#







(4) 產生基本網頁

執行 3 次下面指令, 產生基本網頁




[root@localhost ~]# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
2013-02-09 20:41:17, Rateup WARNING: /usr/bin/rateup could not read the primary log file for eth0
2013-02-09 20:41:17, Rateup WARNING: /usr/bin/rateup The backup log file for eth0 was invalid as well
2013-02-09 20:41:17, Rateup WARNING: /usr/bin/rateup Can't remove eth0.old updating log file
2013-02-09 20:41:17, Rateup WARNING: /usr/bin/rateup Can't rename eth0.log to eth0.old updating log file
[root@localhost ~]# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
2013-02-09 20:41:17, Rateup WARNING: /usr/bin/rateup Can't remove eth0.old updating log file
[root@localhost ~]# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg







(5) 產生 MRTG 首頁

執行

indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html


service httpd restart






(6) 設定排程

編輯 /etc/crontab

vi /etc/crontab






增加一行




*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg  > /dev/null 2>&1






(7) 啟動 MRTG 監控




service httpd start
firefox http://localhost/mrtg &









(8) 快速安裝程式

yum  -y  install  perl gd libpng zlib mrtg httpd net-snmp net-snmp-utils

echo "view systemview included .1.3.6.1.2.1.2.2.1.10"  >>  /etc/snmp/snmpd.conf
echo "view systemview included .1.3.6.1.2.1.2.2.1.16"  >>  /etc/snmp/snmpd.conf
service snmpd restart

echo "Target[eth0]: 2:public@127.0.0.1"  >>  /etc/mrtg/mrtg.cfg
echo "MaxBytes[eth0]: 1250000"  >> /etc/mrtg/mrtg.cfg
echo "Title[eth0]: Traffic Analysis"  >> /etc/mrtg/mrtg.cfg
echo "PageTop[eth0]: <H1>127.0.0.1 eth0</H1>"  >> /etc/mrtg/mrtg.cfg

env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

echo  "*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg  > /dev/null 2>&1   " >>  /etc/crontab

sed -i -e "s@Deny from all@#Deny from all@" /etc/httpd/conf.d/mrtg.conf

service httpd restart
firefox http://localhost/mrtg &

(9) 開放其他機器查詢

vi  /etc/httpd/conf.d/mrtg.cfg


找到



<Location /mrtg>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    Allow from ::1
    # Allow from .example.com
</Location>



增加允許瀏覽 MRTG 的機器或網段




<Location /mrtg>
    Order deny,allow
    Deny from all

    Allow from 192.168.100.100
    Allow from 172.16
    Allow from 192.168.128.0/255.255.255.0
    Allow from 10.1.0.0/16

    Allow from 127.0.0.1
    Allow from ::1
    # Allow from .example.com
</Location>




重新啟動 httpd 讓設定生效




service httpd restart





(完)

[研究] mrtg-2.16.3.tar.gz 安裝 (CentOS 5.4 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?f=24&t=17992

[研究] MRTG 2.14.5 安裝(yum)(CentOS 5.4 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?f=24&t=17991

[研究] MRTG快速安裝程式精簡版(Fedora 8 )
http://forum.icst.org.tw/phpbb/viewtopic.php?f=24&t=14872

[研究] MRTG 快速安裝程式 (CentOS 5.1)
http://forum.icst.org.tw/phpbb/viewtopic.php?f=24&t=14871

[研究] F7 (Fedora 7) 上安裝MRTG (yum安裝)
http://forum.icst.org.tw/phpbb/viewtopic.php?f=16&t=13689

沒有留言:

張貼留言