SNMP+MRTG+WEBALIZER 설정
MintheWiki
|
Centos 배포본에 문제가 있어 MRTG stable 버전으로 다시 받아 작업 http://oss.oetiker.ch/mrtg/pub/mrtg-2.16.2.tar.gz |
|
CPU,RAM,DISK용량에 대한 모니터링도 필요함 |
목차 |
Overview
- SNMP 서비스를 활성화 하여 MRTG를 통해 서버의 네트웍 사용량을 분석하고, WebAlizer로 부터 웹서버 로그분석 결과를 리포팅 받는다.
- SNMP 프로토콜 종류 : v1,v2,v3(암호화 추가)
설치
- yum(mrtg,snmp)
관련링크
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch22_:_Monitoring_Server_Performance SNMP_개요 http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch23_:_Advanced_MRTG_for_Linux http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html
MIB
| OID | MIB |
|---|---|
| 1.3 | org |
| 1.3.6 | dod |
| 1.3.6.1 | internet |
| 1.3.6.1.1 | directory |
| 1.3.6.1.2 | mgmt |
| 1.3.6.1.3 | experimental |
| 1.3.6.1.4 | private |
| 1.3.6.1.4.1 | enterprises |
Configuring Simple SNMP on a Linux Server
- /etc/snmp/snmpd.conf 변경 : Read Only community string to crazy33guy(테스트 커뮤니티 ID)
rocommunity craz33guy ## sec.name source community ## ======== ====== ========= com2sec local localhost craz33guy #com2sec network_1 172.16.1.0/24 craz33guy #com2sec network_2 192.168.2.0/24 craz33guy #로컬만 접속 가능하도록 ## Access.group.name sec.model sec.name ## ================= ========= ======== group MyROGroup_1 v1 local #group MyROGroup_1 v1 network_1 #group MyROGroup_2 v2c network_2 ## MIB.view.name incl/excl MIB.subtree mask ## ============== ========= =========== ==== view all-mibs included .1 80 ## MIB ## group.name context sec.model sec.level prefix read write notif ## ========== ======= ========= ========= ====== ==== ===== ===== access MyROGroup_1 "" v1 noauth exact all-mibs none none access MyROGroup_2 "" v2c noauth exact all-mibs none none
- 자동시작 서비스로 셋업
[root@bigboy root]# chkconfig snmpd on [root@bigboy root]#
- 서비스 재시작
[root@bigboy root]# service snmpd start Starting snmpd: [ OK ] [root@bigboy root]#
- Test
[root@bigboy snmp]# snmpwalk -v 1 -c craz33guy localhost system SNMPv2-MIB::sysDescr.0 = STRING: Linux bigboy 2.4.18-14 #1 Wed Sep 4 11:57:57 EDT 2002 i586 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10 SNMPv2-MIB::sysUpTime.0 = Timeticks: (425) 0:00:04.25 SNMPv2-MIB::sysContact.0 = STRING: root@localhost SNMPv2-MIB::sysName.0 = STRING: bigboy ... ... ... [root@bigboy snmp]# snmpwalk -v 1 -c craz33guy localhost interface IF-MIB::ifNumber.0 = INTEGER: 3 IF-MIB::ifIndex.1 = INTEGER: 1 IF-MIB::ifIndex.2 = INTEGER: 2 IF-MIB::ifIndex.3 = INTEGER: 3 IF-MIB::ifDescr.1 = STRING: lo IF-MIB::ifDescr.2 = STRING: wlan0 IF-MIB::ifDescr.3 = STRING: eth0 ... ... ... [root@bigboy snmp]#
Mrtg 설정
- mrtg-snmpd 연결을 위한 환경설정 만들기
cfgmaker --output=/conf/mrtg/localhost.cfg \ -ifref=ip --global "workdir: /www22/songks/mrtg" \ --snmp-options=:::::2 comminuty-name@localhost
apache alias 설정
<Location /mrtg>
Order deny,allow
Deny from all
Allow from 124.5.X.X
# Allow from .example.com
</Location>
Mrtg index maker 실행
env LANG=C /usr/bin/mrtg /conf/mrtg/localhost.cfg indexmaker --output=/web/songks/mrtg/index.html /conf/mrtg/localhost.cfg
Cron 변경
- /etc/cron.d/mrtg : 5분마다 수행
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /conf/mrtg/localhost.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
Multiple Devices
1) Create a new configuration file using the steps from the previous section; choose a filename that is not mrtg.cfg.
2) Add a new MRTG line in /etc/cron.d/mrtg for each new configuration file you create.
0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg 0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/device1.cfg 0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/device2.cfg
3) Run the indexmaker command, and include all of your /etc/mrtg configuration files, to regenerate your Web index page.
[root@bigboy tmp]# indexmaker --output=/var/www/mrtg/index.html \ /etc/mrtg/mrtg.cfg /etc/mrtg/device1.cfg /etc/mrtg/device2.cfg
4) Other versions of Linux keep their MRTG cron entries inside the /etc/crontab file. Edit this file using the same syntax as the Fedora /etc/cron.d/mrtg file, and then restart the cron daemon to re-read the configuration:
[root@bigboy tmp]# service crond restart
WebAlizer 설정
- 설치 : yum(yum list | grep webalizer)
- /etc/webalizer.conf 를 특정 폴더로 복사
- webalizer.conf 내용중 필수 변경
- LogFile : 로그화일의 위치
- OutputDir : 결과물 출력
- HistoryName : history 저장
- Incremental
- IncrementalName
- DNSCache
- 실행화일예시 :
webalizer -c /conf/webalizer/trac.songks.net.conf
- cron job 등록 : cron.daily/
Cpu 모니터링
- server-info.cfg
- 실행
env LANG=C /usr/bin/mrtg /conf/mrtg/localhost.cfg env LANG=C /usr/bin/mrtg /conf/mrtg/server-info.cfg
indexmaker --output=/web/songks/mrtg/index.html /conf/mrtg/localhost.cfg /conf/mrtg/server-info.cfg
보안설정
- .htpasswd를 이용하여 1차 보안 설정
- ip별 접근권한 설정
특정IP 로그 남기지 않기
httpd.conf 변경
SetEnvIf Remote_Addr 192.168.100.13$ do_not_log CustomLog logs/access_log combined env=!do_not_log
국가별 출력 설정
http://www.digimoon.net/blog/315 http://blog.daum.net/_blog/BlogView.do?blogid=0HQa1&articleno=3888618&_bloghome_menu=recenttext#ajax_history_home

