1. 설치
# yum install net-snmp* mrtg*
2. 사용자 및 디렉토리 생성
# useradd mrtg
# mkdir /home/mrtg/public_html
# mkdir /home/mrtg/conf
3. 설정
아파치 웹서버에 virtualhost 설정을 추가합니다.
<VirtualHost *:80> DocumentRoot "/home/mrtg/public_html" ServerName mrtg.sysdocu.tistory.com ErrorLog "logs/mrtg.sysdocu.tistory.com-error_log" CustomLog "logs/mrtg.sysdocu.tistory.com-access_log" common </VirtualHost> |
아파치 데몬을 restart 하여 virtualhost 설정을 적용합니다.
# /usr/local/apache/bin/apachectl restart
그다음 아래 파일을 열고 내용을 입력합니다.
# vi /etc/snmp/snmpd.conf
com2sec local 192.168.10.2 g_snmp group ManagedGroup v1 local group ManagedGroup v2c local group ManagedGroup usm local view all included .1 80 access ManagedGroup "" any noauth exact all all none disk / disk /backup
|
* 디스크는 2개로, 각각의 파티션은 /, /backup 으로 구성되었을때의 예입니다.
# vi /home/mrtg/conf/mrtg.cfg
EnableIPv6: no WorkDir: /home/mrtg/public_html Language: korean Options[_]: bits,growright LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt Target[192.168.10.2_cpu]: ssCpuUser.0&ssCpuIdle.0:g_snmp@192.168.10.2 Options[192.168.10.2_cpu]: gauge,nopercent,growright MaxBytes[192.168.10.2_cpu]: 100 Title[192.168.10.2_cpu]: dev1 - User vs Idle CPU Usage Unscaled[192.168.10.2_cpu]: ywmd ShortLegend[192.168.10.2_cpu]: % YLegend[192.168.10.2_cpu]: CPU Utilization Legend1[192.168.10.2_cpu]: User CPU in % (Load) Legend2[192.168.10.2_cpu]: Idle CPU in % (Load) Legend3[192.168.10.2_cpu]: Legend4[192.168.10.2_cpu]: LegendI[192.168.10.2_cpu]: User LegendO[192.168.10.2_cpu]: Idle PageTop[192.168.10.2_cpu]: <h1>CPU 사용량</h1> <TABLE> <TR><TD>호스트명:</TD> <TD>SYSDOCU</TD></TR> <TR><TD>IP:</TD> <TD>192.168.10.2</TD></TR> </TABLE> Target[192.168.10.2_load]: laLoad.1&laLoad.2:g_snmp@192.168.10.2 * 100 Options[192.168.10.2_load]: gauge,integer,nopercent,growright WithPeak[192.168.10.2_load]: dev1 MaxBytes[192.168.10.2_load]: 10000 Title[192.168.10.2_load]: dev1 - Load Average YLegend[192.168.10.2_load]: Load Average ShortLegend[192.168.10.2_load]: Legend1[192.168.10.2_load]: Load average for 1 Min Legend2[192.168.10.2_load]: Load average for 5 Min Legend3[192.168.10.2_load]: Max load average for 1 Min Legend4[192.168.10.2_load]: Max Load average for 5 Min LegendI[192.168.10.2_load]: 1min: LegendO[192.168.10.2_load]: 5min: YTicsFactor[192.168.10.2_load]: 0.01 PageTop[192.168.10.2_load]: <h1>CPU 부하율</h1> <TABLE> <TR><TD>호스트명:</TD> <TD>SYSDOCU</TD></TR> <TR><TD>IP</TD> <TD>192.168.10.2</TD></TR> </TABLE> Target[192.168.10.2_mem]: (memTotalReal.0&memTotalSwap.0:g_snmp@192.168.10.2 - memBuffer.0&memAvailSwap.0:g_snmp@192.168.10.2 - memCached.0&memIndex.0:g_snmp@192.168.10.2 - memAvailReal.0&memIndex.0:g_snmp@192.168.10.2) / memTotalReal.0&memTotalSwap.0:g_snmp@192.168.10.2 * 100 Options[192.168.10.2_mem]: nopercent,growright,gauge,noinfo Title[192.168.10.2_mem]: Free Memory MaxBytes[192.168.10.2_mem]: 100 kilo[192.168.10.2_mem]: 1024 YLegend[192.168.10.2_mem]: bytes ShortLegend[192.168.10.2_mem]: % Unscaled[192.168.10.2_mem] : ymwd LegendI[192.168.10.2_mem]: Real Memory: LegendO[192.168.10.2_mem]: Swap Memory: Legend1[192.168.10.2_mem]: Free memory, not including swap, in bytes PageTop[192.168.10.2_mem]: <h1>Memory 사용량</h1> <TABLE> <TR><TD>호스트명:</TD> <TD>SYSDOCU</TD></TR> <TR><TD>IP</TD> <TD>192.168.10.2</TD></TR> </TABLE> Target[192.168.10.2_hdd1]: dskPercent.1&dskPercent.2:g_snmp@192.168.10.2 Title[192.168.10.2_hdd1]: Disk Partition Usage MaxBytes[192.168.10.2_hdd1]: 100 ShortLegend[192.168.10.2_hdd1]: % YLegend[192.168.10.2_hdd1]: Disk usage LegendI[192.168.10.2_hdd1]: / LegendO[192.168.10.2_hdd1]: /backup Options[192.168.10.2_hdd1]: gauge,growright,nopercent Unscaled[192.168.10.2_hdd1]: ymwd PageTop[192.168.10.2_hdd1]: <H1>디스크 사용량</H1> <TABLE> <TR><TD>호스트명:</TD> <TD>SYSDOCU</TD></TR> <TR><TD>IP:</TD> <TD></TD></TR> <TR><TD>/</TD><TD> </TD></TR> <TR><TD>/backup</TD><TD> </TD></TR> </TABLE> |
4. index 페이지 만들기
# indexmaker --title "SYSDOCU MRTG" --output /home/mrtg/public_html/index.html /home/mrtg/conf/mrtg.cfg
5. 스케쥴러 등록
아래 명령을 통해 mrtg 데이타를 생성합니다.
처음 명령을 내릴경우 경고메세지가 뜨지만, 이는 처음이라 데이타 파일이 없다는 뜻입니다.
몇번 더 실행하면 나타나지 않는것을 볼수 있습니다.
# /usr/bin/mrtg /home/mrtg/conf/mrtg.cfg
지속적으로 5분마다 데이타 갱신이 되도록 crontab 에 등록합니다.
# crontab -e
mailto="" */5 * * * * /usr/bin/mrtg /home/mrtg/conf/mrtg.cfg --logging /var/log/mrtg.log |