MRTG 홈페이지 - http://oss.oetiker.ch/mrtg/pub/?M=D
[root]# rpm -qa | grep mrtg # 설치되어있던 mrtg가 있으면 삭제한다. rpm -e mrtg...
[root]# wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.16.2.tar.gz
[root]# ./configure --prefix=/usr/local/mrtg --with-gd=/usr/local/gd/lib/ --with-gd-inc=/usr/local/gd/include/ --with-z=/usr/local/lib/ --with-png=/usr/local/lib/
[root]# make && make install
[root]# yum list | grep snmp
[root]# yum update net-snmp
[root]# vi /etc/snmp/snmpd.conf
| ############################################################# com2sec local localhost 키워드 com2sec local 'MRTG가 작동될서버IP' 키워드 com2sec network 'mrtg 웹에서 접속할 주소' 키워드 ############################################################# group rwgroup v1 local group rwgroup v2c local group rwgroup v1 network group rwgroup v2c network ################################################### view all included .1 80 view systemview included system view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc ######################################################################### access rwgroup "" any noauth exact all all all access rogroup "" any noauth exact systemview none none ############################################################# |
[root]# service snmpd restart
[root]# mkdir /etc/mrtg
[root]# mkdir /home/mrtg
아파치 설정에 사용하고자 하는 도메인을 /home/mrtg에 연결해둔다.
[root]# vi /usr/bin/mrtg
| #!/bin/bash /usr/local/mrtg/bin/cfgmaker --global 'WorkDir: /home/mrtg' --global 'Options[_]: bits,growright' --global 'Language: korean' --output /etc/mrtg/$1.cfg 키워드@$1 /usr/local/mrtg/bin/mrtg /etc/mrtg/$1.cfg cd /home/mrtg http=`ls $1_*.html` error=$? if [ $error -eq 0 ] then echo echo "등록할 mrtg 주소" echo http://mrtg.zerocool.pe.kr/$http echo # echo "*/5 * * * * /usr/local/mrtg/bin/mrtg /etc/mrtg/$1.cfg" >> /var/spool/cron/root echo "/usr/local/mrtg/bin/mrtg /etc/mrtg/$1.cfg" >> /root/renewal echo "새로운 mrtg를 crond에 등록합니다." service crond restart else echo "$1 에러가 나서 종료됩니다. 점검후 다시 명령을 실행하시기 바랍니다." echo "잘못 생성된 파일들을 삭제합니다." rm -rf /etc/mrtg/$1* rm -rf /home/mrtg/$1* fi |
[root]# echo '#!bin/bash' > /root/renewal
[root]# chmod u+x /root/renewal
[root]# mrtg 'snmp설치된서버IP' ex) mrtg 168.126.0.1
** 위 명령을 실행했을때 아래와 같은 메세지가 나올 수 있다.
| SNMP Error: no response received SNMPv1_Session (remote host: "168.126.0.1" [168.126.0.1].161) community: "키워드" request ID: -983397401 PDU bufsize: 8000 bytes timeout: 2s retries: 5 backoff: 1) |
1. snmp.conf 와 mrtg 실행스크립트의 키워드가 서로 다르다.
2. 161 udp 포트가 막혀있다.
3. hosts.deny 에서 막혀있다.
보통 이정도의 경우중 하나다.
그리고 또 나올 수 있는 에러메세지 중 하나를 보면,
| ----------------------------------------------------------------------- ERROR: Mrtg will most likely not work properly when the environment variable LANG is set to UTF-8. Please run mrtg in an environment where this is not the case. Try the following command to start: env LANG=C ${0} ......... ----------------------------------------------------------------------- |
이런 메세지가 나올 경우 서버의 LANG 설정이 UTF-8로 되어있는것이다.
echo $LANG 해보면, 확인할 수 있다.
이 경우에는 서버의 설정을 ko_KR.EUCKR로 바꿔주는 방법이 있고,
mrtg 실행파일에서 저 에러메세지를 띄워주는 부분을 주석처리해서 무시하는 방법이 있다.
[root]# vi /usr/local/mrtg/bin/mrtg
| if ( $ENV{LANG} and $ENV{LANG} =~ /UTF.*8/i ){ my $args = join " ", map { /\s/ ? "\"$_\"" : $_ } @ARGV; $args ||= ""; print <<ERR; ----------------------------------------------------------------------- ERROR: Mrtg will most likely not work properly when the environment variable LANG is set to UTF-8. Please run mrtg in an environment where this is not the case. Try the following command to start: env LANG=C ${0} $args ----------------------------------------------------------------------- ERR exit 0; } |
65번째라인 정도에 위와 같은 if문이 있다.
이 부분이 언어셋 검사를 하는 부분이므로 이 라인들을 주석처리해버리면,
에러메세지 없이 mrtg페이지가 생성된다.
rss