mrtg install for centos 5.8 Linux

mrtg install for centos 5.8

[root@localhost ~] yum install -y net-snmp* , gd, libpng , zlib 
[root@localhost ~] yum install -y mrtg


[root@localhost ~] mkdir -p /home/mrtg/cfg
[root@localhost ~] vi /etc/snmp/snmpd.conf

==============

 #       sec.name  source          community
 #com2sec notConfigUser  default       public
 com2sec cy  xxx.xxx.xxx.xxx       public ----> IP는 서버의 아피나 걍 default 로 해도 무방

 ####
 # Second, map the security name into a group name:

 #       groupName      securityModel securityName
 group   notConfigGroup v1           cy ----위의 source 명과 동일하게
 group   notConfigGroup v2c           cy ---- 마찬가지


 ####
 # 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    systemview    included   .1     80  ----subtree 값 변경

================

[root@localhost ~]  /etc/init.d/snmpd start
[root@localhost ~]  snmpwalk -On -v 2c -c public xxx.xxx.xxx.xxx
 (ip를 입력해서 mib 의 결과가 나와야 함 안나온다면 snmp.conf파일을 다시 수정 해야 함)

[root@localhost ~]$ install -m 700 /dev/null mrtg.sh
[root@localhost ~]$ vi mrtg.sh 

#/bin/sh
cfgmaker \
--global 'WorkDir: /usr/local/nginx/html/mrtg' \
--global 'Options[_]: bits,growright' \
--output /home/mrtg/cfg/cy.cfg \
public@xxx.xxx.xxx.xxx

============================================
cfgmaker 는 설치방법에따라 경로가 다름
workdir     : 수집할 자료값이 저장될위치
bits          : 기본단위
growright  :  새로운데이터가 오른쪽으로 생성
output      : cfg파일이 저장될 위치 
==============================================

[root@localhost ~]$ sh mrtg.sh 
[root@localhost ~]$ vi /home/mrtg/cfg/cy.cfg
  1 EnableIPv6: no
  2 WorkDir: /var/www/mrtg
  3 Options[_]: bits,growright
  4
  5 Target[xxx.xxx.xxx.xxx]: 1:public@xxx.xxx.xxx.xxx:
  6 SetEnv[xxx.xxx.xxx.xxx]: MRTG_INT_IP="xxx.xxx.xxx.xxx" MRTG_INT_DESCR="eth0"
  7 MaxBytes[xxx.xxx.xxx.xxx]: 125000000 ----> 요부분은 0으로 되어 있을껀데 내당 용량으루 변경
  8 Title[xxx.xxx.xxx.xxx]: Traffic Analysis for 2 -- localhost
  9 PageTop[xxx.xxx.xxx.xxx]: <h1>Traffic Analysis for 2 -- localhost</h1>
10         <div id="sysdetails">
11             <table>
12                 <tr>
13                     <td>System:</td>
14                     <td>localhost in Unknown (edit /etc/snmp/snmpd.conf)</td>
15                 </tr>
16                 <tr>
17                     <td>Maintainer:</td>
18                     <td>Root &lt;root@localhost&gt; (configure /etc/snmp/snmp.local.conf)</td>
19                 </tr>
20                 <tr>
21                     <td>Description:</td>
22                     <td>eth0  </td>
23                 </tr>
24                 <tr>
25                     <td>ifType:</td>
26                     <td>ethernetCsmacd (6)</td>
27                 </tr>
28                 <tr>
29                     <td>ifName:</td>
30                     <td>eth0</td>
31                 </tr>
32                 <tr>
33                     <td>Max Speed:</td>
34                     <td>0.0 bits/s</td>
35                 </tr>
36                 <tr>
37                     <td>Ip:</td>
38                     <td>115.68.87.115 ()</td>
39                 </tr>
40             </table>
41         </div>

다음과 같이 주석 해제를 해준다.
주석 해제시 앞쪽에 공간이 남아 있다면 아래 indexmake 가 안될 수 있음


[root@localhost ~]$ vi install -m 700 /dev/null index.sh
#/bin/sh

indexmaker --title "cytest MRTG page" \
--output /usr/local/nginx/html/mrtg/index.html \
/home/mrtg/cfg/cy.cfg
               
[root@localhost ~]$ sh index.sh

mrtg 세팅은 위와 같이 진행 하면 된다
아래 명령어는 cfg파일을 덫어 씌여 새로운 그래프를 그릴 수 있다
[root@localhost ~]$ mrtg /home/mrtg/cfg/cy.cfg

다음 명령어를 크론에 등록 한다.
[root@localhost ~]$vi /etc/crontab 

*/5 * * * * root mrtg /home/mrtg/cfg/cy.cfg >& /dev/null


아래와 같이 나오면 정상적으로 그래프가 그려지는 것이다.

지금 구축 상황은 서버 에서 snmp를 가져 오기 때문에 input은 다운 받고 output은 업로드라고 생각하면 된다
만약 스위치에 있는 snmp 값을 가져 와서 한다면 반대로 생각 해야 한다.









Leave Comments