레이블이 MRTG인 게시물을 표시합니다. 모든 게시물 표시
레이블이 MRTG인 게시물을 표시합니다. 모든 게시물 표시

2015년 1월 29일 목요일

MRTG 설치하기




기본적으로 APM 설치가 되어있어야 한다.


APM yum 설치하기




1. 준비사항

CentOS, APM




2. snmp 설치

1) snmp 설치
[root@nell /]# yum install net-snmp*





 2) /etc/snmp/snmpd.conf 설정


# First, map the community name "public" into a "security name"
#       sec.name  source          community
#com2sec notConfigUser  default       public
com2sec fserver          127.0.0.1     community

# Second, map the security name into a group name:
#       groupName      securityModel securityName
#group   notConfigGroup v1           notConfigUser
#group   notConfigGroup v2c           notConfigUser
group    fgroup         v1      fserver
group    fgroup         v2c    fserver
# Third, create a view for us to let the group have rights to:
# Make at least  snmpwalk -v 1 localhost -c public system fast again.
#       name           incl/excl     subtree         mask(optional)
#view    systemview    included   .1.3.6.1.2.1.1
#view    systemview    included   .1.3.6.1.2.1.25.1.1
view     all           included   .1
# Finally, grant the group read-only access to the systemview view.
#       group          context sec.model sec.level prefix read   write  notif
#access  notConfigGroup ""      any       noauth    exact  systemview none none
access   fgroup         ""      any       noauth    exact  all        none none


3) snmp 데몬 실행

/etc/init.d/snmpd start







3. MRTG 설치

[root@nell /]#  cd /usr/src
[root@nell /]#  wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.17.4.tar.gz
[root@nell /]#  tar xvfz mrtg-2.17.4.tar.gz
[root@nell /]#  cd mrtg-2.17.4
[root@nell /]#  ./configure –with-gd=/usr/local/gd –with-z=/usr/local/zlib –with-png=/usr/local/libpng
[root@nell /]#  make
[root@nell /]#  make install




4. MRTG 웹 설정

  1) 웹설정 (<Directory> 설정)
[root@nell /]#  adduser mrtg
[root@nell /]#  mkdir /home/mrtg/public_html
[root@nell /]#  mkdir /home/mrtg/public_html/localhost
[root@nell /]#  mkdir /home/mrtg/conf
[root@nell /]#  chmod 755 /home/mrtg
[root@nell /]#  chown mrtg.mrtg /home/mrtg
[root@nell /]#  vi /etc/httpd/conf/httpd.conf

~ 중략 ~
<IfModule mod_userdir.c>
    # UserDir disabled
    UserDir public_html

</IfModule>
<Directory /home/*/public_html>
</Directory>
~ 중략 ~








2) cfgmaker
   (모니터링할 대상항목의 Config 파일을 생성하는 작업 )


[root@nell /]#  cd /usr/local/mrtg-2/bin
[root@nell /]#  ./cfgmaker –global 'WorkDir: /home/mrtg/public_html/localhost' –global 'Options[_]: bits,growright' –output /home/mrtg/conf/localhost.cfg community@127.0.0.1







3) 모니터링 Config 수정
  (/home/mrtg/conf/localhost.cfg 하단부에 추가 합니다.)




### CPU Load Average ###
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:community@127.0.0.1
MaxBytes[cpu]: 2000
#Unscaled[cpu]: dwmy
Options[cpu]: integer, gauge,withzeroes, growright, noinfo, nopercent
YLegend[cpu]: CPU Load Average
ShortLegend[cpu]: (%)
LegendI[cpu]: Aver 1/minite
LegendO[cpu]: Aver 5/min
Legend1[cpu]: Aver 1/minite
Legend2[cpu]: Aver 5/min
Title[cpu]: CPU Load
PageTop[cpu]: </p><h1>CPU Load Average</h1>
### Rate of CPU use ###
Target[cpu_use]: .1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.52.0:community@127.0.0.1
MaxBytes[cpu_use]: 100
Options[cpu_use]: growright, noinfo, nopercent
YLegend[cpu_use]: CPU usage(%)
ShortLegend[cpu_use]: (%)
LegendI[cpu_use]: User
LegendO[cpu_use]: System
Legend1[cpu_use]: CPU usage(User)(%)
Legend2[cpu_use]: CPU usage(System)(%)
Title[cpu_use]: Rate of CPU use
PageTop[cpu_use]: <h1>Rate of CPU use</h1>
### Memory Free ###
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:community@127.0.0.1
MaxBytes1[mem]: 7513968
MaxBytes2[mem]: 7513968
Unscaled[mem]: dwmy
Options[mem]: gauge, growright, noinfo
YLegend[mem]: Mem Free(Bytes)
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: RAM [MBytes]
Legend2[mem]: Swap Memory [MBytes]
Title[mem]: Memory Free
PageTop[mem]: <h1>Memory Free</h1>






4) indexmaker 및 mrtg 쿼리
[root@nell /]#  cd /usr/local/mrtg-2/bin
[root@nell /]#  ./indexmaker –title "Localhost" /home/mrtg/conf/localhost.cfg > /home/mrtg/public_html/localhost/index.html
[root@nell /]#  env LANG=C /usr/local/mrtg-2/bin/mrtg /home/mrtg/conf/localhost.cfg


------------------------------------------------


5. 웹사이트 및 crontab 적용
 
 1) 리다이렉션 페이지 생성

[root@nell /]#  cat > /home/mrtg/public_hml/index.html
<meta http-equiv="refresh" content="1;url=./localhost/index.html">




  2) 모니터링 스크립트 작성 및 crontab 등록


[root@nell /]#   cat > /script/mrtg.sh

#!/bin/bash
env LANG=C /usr/local/mrtg-2/bin/mrtg /home/mrtg/conf/localhost.cfg



[root@nell /]#  crontab -e 
*/1 * * * * /scripts/mrtg.sh