2014年8月12日 星期二

[研究] MRTG 2.17.4 快速安裝程式(tar.gz)(CentOS 7.0 x86_64)

[研究] MRTG 2.17.4 快速安裝程式(tar.gz)(CentOS 7.0 x86_64)

2014-08-12

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

注意,CentOS 7.0 的網卡不稱為 eth0,在 小弟電腦上是 eno16777736


[root@localhost ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.128.101  netmask 255.255.255.0  broadcast 192.168.128.255
        inet6 fe80::20c:29ff:fe97:fae4  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:97:fa:e4  txqueuelen 1000  (Ethernet)
        RX packets 36520  bytes 51448968 (49.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19662  bytes 1412340 (1.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 871  bytes 257568 (251.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 871  bytes 257568 (251.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]#



快速安裝程式如下:


# mrtg-2.17.4.tar.gz_install.sh
echo -e "\033[31;42m ********** Install mrtg-2.17.4.tar.gz on CentOS 7.0 x64_86 ********** \033[0m"
echo -e "\033[31m 2014/8/12 ********** \033[0m"
echo -e "\033[31m by Shau-Rong Lu ********** \033[0m"

# Check SELinux status
if  [ "`grep SELINUX=disabled /etc/selinux/config`" == "" ]; then

# disable SELinux now
/usr/sbin/setenforce 0

# disable SELinux after every reboot
# echo "/usr/sbin/setenforce 0" >> /etc/rc.local  

#or
# disable SELinux always
sed -i -e "s@SELINUX=enforcing@#SELINUX=enforcing@"   /etc/selinux/config
sed -i -e "s@SELINUX=permissive@#SELINUX=permissive@"   /etc/selinux/config
sed -i -e "/SELINUX=/aSELINUX=disabled"   /etc/selinux/config
fi

# Kill yum on running...
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done

# ************************************************

yum  -y  install gcc perl gd libpng zlib httpd net-snmp net-snmp-utils  gd-devel libpng-devel zlib-devel wget

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

cd /usr/local/src
wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.17.4.tar.gz
tar  zxvf   mrtg-2.17.4.tar.gz
cd  mrtg-2.17.4
./configure --prefix=/usr/local/mrtg-2
make
make install

mkdir /var/www/html/mrtg

# 產生 /etc/mrtg.cfg

/usr/local/mrtg-2/bin/cfgmaker  --global 'WorkDir: /var/www/html/mrtg'  --global 'Options[_]: bits,growright'  --output /etc/mrtg.cfg  community@localhost.localdomain

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

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

# 根據 /etc/mrtg.cfg 內容,產生基本圖片

env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/mrtg.cfg
env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/mrtg.cfg
env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/mrtg.cfg

# 根據 /etc/mrtg.cfg 內容,產生首頁

/usr/local/mrtg-2/bin/indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html

# 設定排成,每5分鐘產生一次新圖片

echo "*/5 * * * *  root env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/mrtg.cfg  --logging /var/log/mrtg.log"   >>  /etc/crontab
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 &

(下圖) 都是 0 bytes,有問題,待研究


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

mrtg.cfg 中  public 前面的數字可用下面偵測, 一般 eth0 或 eno16777736 代號是 2

[root@localhost mrtg-2.17.4]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:97:fa:e4 brd ff:ff:ff:ff:ff:ff
[root@localhost mrtg-2.17.4]#

PS: 開放其他機器查詢

vim  /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.17.4 快速安裝程式(tar.gz)(CentOS 7.0 x64_86)
http://shaurong.blogspot.com/2014/08/mrtg-2174-targzcentos-70-x6486.html

[研究] MRTG 2.17.4 快速安裝程式(tar.gz)(CentOS 6.5 x64_86)
http://shaurong.blogspot.com/2014/08/mrtg-2174-targzcentos-65-x6486.html

[研究] MRTG 2.16.2 安裝(yum)(CentOS 6.5 x64_86)
http://shaurong.blogspot.com/2014/08/mrtg-2162-yumcentos-65-x6486.html

[研究] MRTG 2.17.4 快速安裝程式(tar.gz)(CentOS 6.3 x86)
http://shaurong.blogspot.com/2012/12/mrtg-2174targz-centos-63-x86.html

[研究] MRTG 2.17.4 安裝(tar.gz)(CentOS 6.3 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=79225

[研究] MRTG 2.17.2安裝(yum)(Fedora 16 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=21201

[研究] MRTG 2.17.2安裝(yum)(CentOS 6.2 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=21196

[研究] MRTG 2.17.1 安裝(tar.gz)(CentOS 6.0 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20208

[研究] MRTG 2.17.0 安裝(tar.gz)(Fedora 14 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19191

[研究] MRTG 2.16.4 安裝(yum)(Fedora 14 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19192

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

[研究] MRTG 2.16.2安裝(yum)(CentOS 6.0 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20207

[研究] MRTG 2.16.2 安裝(yum)(CentOS 6.3 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=79309

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

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

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

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

[研究] MRTG 安裝(Fedora Core 4)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=7014

[研究] MRTG 安裝 (Fedora Core 3)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=8168

沒有留言:

張貼留言