(http://www.digimoon.net/)
아래 사이트에서 최신 버전을 다운받습니다. 소스 컴파일 설치로 해 보겠습니다.
http://sourceforge.net/project/showfiles.php?group_id=12694&package_id=11571
저는 소스 설치 시 압축파일은 일반적으로 /usr/local/src 디렉토리에 받습니다.
[root@test ~]# cd /usr/local/src/
[root@test src]# wget http://downloads.sourceforge.net/net-snmp/net-snmp-5.4.1.tar.gz?modtime=1185535805&big_mirror=1
[1] 2432
--17:12:19-- http://downloads.sourceforge.net/net-snmp/net-snmp-5.4.1.tar.gz?modtime=1185535805
=> `net-snmp-5.4.1.tar.gz?modtime=1185535805'
Resolving downloads.sourceforge.net... [root@test src]# 66.35.250.203
Connecting to downloads.sourceforge.net[66.35.250.203]:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.4.1.tar.gz [following]
--17:12:19-- http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.4.1.tar.gz
=> `net-snmp-5.4.1.tar.gz.1'
Resolving nchc.dl.sourceforge.net... 211.79.61.10
Connecting to nchc.dl.sourceforge.net[211.79.61.10]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5,122,455 [application/x-gzip] 100%[======================================================================>] 5,122,455 1.37M/s ETA 00:00 17:12:23 (1.35 MB/s) - `net-snmp-5.4.1.tar.gz.1' saved [5,122,455/5,122,455]
[1]+ Done wget http://downloads.sourceforge.net/net-snmp/net-snmp-5.4.1.tar.gz?modtime=1185535805
[root@test src]# ls
net-snmp-5.4.1.tar.gz
[root@test src]# wget http://downloads.sourceforge.net/net-snmp/net-snmp-5.4.1.tar.gz?modtime=1185535805&big_mirror=1
[1] 2432
--17:12:19-- http://downloads.sourceforge.net/net-snmp/net-snmp-5.4.1.tar.gz?modtime=1185535805
=> `net-snmp-5.4.1.tar.gz?modtime=1185535805'
Resolving downloads.sourceforge.net... [root@test src]# 66.35.250.203
Connecting to downloads.sourceforge.net[66.35.250.203]:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.4.1.tar.gz [following]
--17:12:19-- http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.4.1.tar.gz
=> `net-snmp-5.4.1.tar.gz.1'
Resolving nchc.dl.sourceforge.net... 211.79.61.10
Connecting to nchc.dl.sourceforge.net[211.79.61.10]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5,122,455 [application/x-gzip] 100%[======================================================================>] 5,122,455 1.37M/s ETA 00:00 17:12:23 (1.35 MB/s) - `net-snmp-5.4.1.tar.gz.1' saved [5,122,455/5,122,455]
[1]+ Done wget http://downloads.sourceforge.net/net-snmp/net-snmp-5.4.1.tar.gz?modtime=1185535805
[root@test src]# ls
net-snmp-5.4.1.tar.gz
압축을 풀고 압축을 푼 디렉토리로 이동합니다.
[root@test src]# tar xfz net-snmp-5.4.1.tar.gz
[root@test src]# cd net-snmp-5.4.1
[root@test net-snmp-5.4.1]# ls
acconfig.h config.sub include mibs README.agentx README.tru64
acinclude.m4 configure INSTALL mkinstalldirs README.aix README.win32
aclocal.m4 configure.in install-sh net-snmp-config.in README.hpux11 sedscript.in
agent COPYING local NEWS README.irix snmplib
AGENT.txt dist ltmain.sh ov README.krb5 stamp-h
apps doc Makefile.in perl README.osX stamp-h.in
ChangeLog dotgdbinit Makefile.rules PORTING README.Panasonic_AM3X.txt testing
CHANGES doxygen.conf Makefile.top python README.snmpv3 TODO
CodingStyle EXAMPLE.conf.def maketarget README README.solaris win32
config.guess FAQ man README.agent-mibs README.thread
[root@test net-snmp-5.4.1]#
[root@test src]# cd net-snmp-5.4.1
[root@test net-snmp-5.4.1]# ls
acconfig.h config.sub include mibs README.agentx README.tru64
acinclude.m4 configure INSTALL mkinstalldirs README.aix README.win32
aclocal.m4 configure.in install-sh net-snmp-config.in README.hpux11 sedscript.in
agent COPYING local NEWS README.irix snmplib
AGENT.txt dist ltmain.sh ov README.krb5 stamp-h
apps doc Makefile.in perl README.osX stamp-h.in
ChangeLog dotgdbinit Makefile.rules PORTING README.Panasonic_AM3X.txt testing
CHANGES doxygen.conf Makefile.top python README.snmpv3 TODO
CodingStyle EXAMPLE.conf.def maketarget README README.solaris win32
config.guess FAQ man README.agent-mibs README.thread
[root@test net-snmp-5.4.1]#
소스컴파일 설치의 전형적인 명령어 절차인 configure->make->make install 를 차례대로 밟아주면 됩니다.
우선 컴파일 환경설정 명령어인 confuigure 부터 실행합니다.
[root@test net-snmp-5.4.1]# ./configure
중간에 몇몇 과정을 진행하기 위해 엔터키를 누르라는 안내문이 나올 겁니다. 내용 개의치 말고 그냥 엔터만 누르며 진행하면 디폴트값으로 세팅됩니다. 대여섯 차례 가량 누르며 넘어 갑니다.
그러면 끄트머리에 아래와 같은 메시지가 출력되며 컴파일 환경 설정 작업이 끝납니다.
---------------------------------------------------------
Net-SNMP configuration summary:
--------------------------------------------------------- SNMP Versions Supported: 1 2c 3
Net-SNMP Version: 5.4.1
Building for: linux
Network transport support: Callback Unix TCP UDP
SNMPv3 Security Modules: usm
Agent MIB code: default_modules => snmpv3mibs mibII ucd_snmp notification notification-log-mib target agent_mibs agentx disman/event disman/schedule utilities host
Embedded Perl support: enabled
SNMP Perl modules: building -- embeddable
SNMP Python modules: disabled
Authentication support: MD5 SHA1
Encryption support: DES AES ---------------------------------------------------------
[root@test net-snmp-5.4.1]#
Net-SNMP configuration summary:
--------------------------------------------------------- SNMP Versions Supported: 1 2c 3
Net-SNMP Version: 5.4.1
Building for: linux
Network transport support: Callback Unix TCP UDP
SNMPv3 Security Modules: usm
Agent MIB code: default_modules => snmpv3mibs mibII ucd_snmp notification notification-log-mib target agent_mibs agentx disman/event disman/schedule utilities host
Embedded Perl support: enabled
SNMP Perl modules: building -- embeddable
SNMP Python modules: disabled
Authentication support: MD5 SHA1
Encryption support: DES AES ---------------------------------------------------------
[root@test net-snmp-5.4.1]#
이제 컴파일을 할 차례입니다.
[root@test net-snmp-5.4.1]# make
끄트머리에 아래와 같이 메시지가 나오면 컴파일에 성공한 겁니다.
chmod 755 ../blib/arch/auto/NetSNMP/TrapReceiver/TrapReceiver.so
cp TrapReceiver.bs ../blib/arch/auto/NetSNMP/TrapReceiver/TrapReceiver.bs
chmod 644 ../blib/arch/auto/NetSNMP/TrapReceiver/TrapReceiver.bs
Manifying ../blib/man3/NetSNMP::TrapReceiver.3pm
make[2]: Leaving directory `/usr/local/src/net-snmp-5.4.1/perl/TrapReceiver'
make[1]: Leaving directory `/usr/local/src/net-snmp-5.4.1/perl'
[root@localhost net-snmp-5.4.1]#
cp TrapReceiver.bs ../blib/arch/auto/NetSNMP/TrapReceiver/TrapReceiver.bs
chmod 644 ../blib/arch/auto/NetSNMP/TrapReceiver/TrapReceiver.bs
Manifying ../blib/man3/NetSNMP::TrapReceiver.3pm
make[2]: Leaving directory `/usr/local/src/net-snmp-5.4.1/perl/TrapReceiver'
make[1]: Leaving directory `/usr/local/src/net-snmp-5.4.1/perl'
[root@localhost net-snmp-5.4.1]#
이제 설치합니다.
[root@test net-snmp-5.4.1]# make install
끄트머리에 아래와 같이 출력되면 설치까지 무사히 성공한 겁니다.
Installing /usr/share/man/man3/SNMP.3
Installing /usr/share/man/man3/NetSNMP::default_store.3pm
Installing /usr/share/man/man3/NetSNMP::OID.3pm
Installing /usr/share/man/man3/NetSNMP::agent.3pm
Installing /usr/share/man/man3/NetSNMP::netsnmp_request_infoPtr.3pm
Installing /usr/share/man/man3/NetSNMP::TrapReceiver.3pm
Installing /usr/share/man/man3/NetSNMP::ASN.3pm
Installing /usr/share/man/man3/NetSNMP::agent::default_store.3pm
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Bundle/NetSNMP/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
make[1]: Leaving directory `/usr/local/src/net-snmp-5.4.1/perl'
[root@test net-snmp-5.4.1]#
Installing /usr/share/man/man3/NetSNMP::default_store.3pm
Installing /usr/share/man/man3/NetSNMP::OID.3pm
Installing /usr/share/man/man3/NetSNMP::agent.3pm
Installing /usr/share/man/man3/NetSNMP::netsnmp_request_infoPtr.3pm
Installing /usr/share/man/man3/NetSNMP::TrapReceiver.3pm
Installing /usr/share/man/man3/NetSNMP::ASN.3pm
Installing /usr/share/man/man3/NetSNMP::agent::default_store.3pm
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Bundle/NetSNMP/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
make[1]: Leaving directory `/usr/local/src/net-snmp-5.4.1/perl'
[root@test net-snmp-5.4.1]#
snmpd는 snmpd.conf 파일을 환경설정 파일로 사용합니다.
압축을 풀었던 디렉토리에 EXAMPLE.conf 라는 샘플파일이 있습니다. 아래에 붉은색으로 표시한 파일입니다.
이 파일을 /usr/local/share/snmpd 디렉토리에 snmpd.conf라는 파일명으로 복사해 주어야 합니다.
[root@test net-snmp-5.4.1]# ls
acconfig.h config.sub include mibs README.agent-mibs README.win32
acinclude.m4 configure INSTALL mk README.agentx sedscript
aclocal.m4 configure.in install-sh mkinstalldirs README.aix sedscript.in
agent configure-summary libtool net-snmp-config README.hpux11 snmplib
AGENT.txt COPYING local net-snmp-config.in README.irix stamp-h
apps dist ltmain.sh net-snmp-config-x README.krb5 stamp-h.in
ChangeLog doc Makefile NEWS README.osX testing
CHANGES dotgdbinit Makefile.in ov README.Panasonic_AM3X.txt TODO
CodingStyle doxygen.conf Makefile.rules perl README.snmpv3 win32
config.guess EXAMPLE.conf Makefile.top PORTING README.solaris
config.log EXAMPLE.conf.def maketarget python README.thread
config.status FAQ man README README.tru64
[root@test net-snmp-5.4.1]# cp EXAMPLE.conf /usr/local/share/snmp/snmpd.conf
[root@test net-snmp-5.4.1]#
acconfig.h config.sub include mibs README.agent-mibs README.win32
acinclude.m4 configure INSTALL mk README.agentx sedscript
aclocal.m4 configure.in install-sh mkinstalldirs README.aix sedscript.in
agent configure-summary libtool net-snmp-config README.hpux11 snmplib
AGENT.txt COPYING local net-snmp-config.in README.irix stamp-h
apps dist ltmain.sh net-snmp-config-x README.krb5 stamp-h.in
ChangeLog doc Makefile NEWS README.osX testing
CHANGES dotgdbinit Makefile.in ov README.Panasonic_AM3X.txt TODO
CodingStyle doxygen.conf Makefile.rules perl README.snmpv3 win32
config.guess EXAMPLE.conf Makefile.top PORTING README.solaris
config.log EXAMPLE.conf.def maketarget python README.thread
config.status FAQ man README README.tru64
[root@test net-snmp-5.4.1]# cp EXAMPLE.conf /usr/local/share/snmp/snmpd.conf
[root@test net-snmp-5.4.1]#
복사했으면 이제 snmpd.conf 파일 내용을 수정해 주는 작업이 필요합니다.
vi 편집기로 열어 아래처럼 나온 부분을 유심히 보면...
####
# First, map the community name (COMMUNITY) into a security name
# (local and mynetwork, depending on where the request is coming
# from): # sec.name source community
com2sec local localhost COMMUNITY
com2sec mynetwork NETWORK/24 COMMUNITY
주석을 읽어보면 COMMUNITY라는 지시자는 로컬이나 네트워크 상에서 보안 이름으로 사용된다는 걸 알 수 있습니다.# First, map the community name (COMMUNITY) into a security name
# (local and mynetwork, depending on where the request is coming
# from): # sec.name source community
com2sec local localhost COMMUNITY
com2sec mynetwork NETWORK/24 COMMUNITY
2행을 모두 주석처리하거나 COMMUNITY 지시자를 모두 'public' 지시자로 변경합니다.
참고로 주석 처리하는 경우 데몬이 제대로 올라오지 못하는 경우가 있다고 하네요.
참고로 public 이라는 지시자를 쓰면 보안상 안좋다고 하는데 해당 지시자의 쓰임새에 대해 처음부터 자세히 알기 보다는 일단은 별다른 고민 없이 snmpd의 원활한 초기 구동을 위해서 public으로 변경해 주도록 합시다.
com2sec local localhost public
# com2sec mynetwork NETWORK/24 public
# com2sec mynetwork NETWORK/24 public
com2sec mynetwork NETWORK/24 public
위 행을 주석처리한 이유는 서버 자체에서 snmpd를 돌려 이 서버에서 수집되는 정보를 다시 서버 자체에 구축된 mrtg에서 분석하는 데엔 그냥 localhost 만 참고하면 되기 때문입니다.
mrtg로 네트워크 전체에 물린 자원을 분석하고 싶다면 'NETWORK/24' <- 이 부분을 적당히 수정하면 됩니다.
이제 세팅 작업은 모두 끝났습니다. snmpd를 구동해 보도록 합시다.
snmpd는 udp 161번 포트를 사용합니다. 그러므로 iptables과 같은 방화벽 솔루션으로 포트가 차단되어 있는 경우 먼저 해제부터 하고 실행시키도록 합니다.
[root@test net-snmp-5.4.1]# /usr/local/sbin/snmpd
[root@test net-snmp-5.4.1]# ps -ef | grep snmpd
root 24931 1 1 07:25 ? 00:00:00 /usr/local/sbin/snmpd
root 24933 2130 0 07:25 pts/0 00:00:00 grep snmpd
[root@test net-snmp-5.4.1]# netstat -nulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:921 0.0.0.0:* 1593/rpc.statd
udp 0 0 0.0.0.0:924 0.0.0.0:* 1593/rpc.statd
udp 0 0 0.0.0.0:161 0.0.0.0:* 24931/snmpd
udp 0 0 0.0.0.0:111 0.0.0.0:* 1568/portmap
udp 0 0 0.0.0.0:631 0.0.0.0:* 1827/cupsd
[root@test net-snmp-5.4.1]#
[root@test net-snmp-5.4.1]# ps -ef | grep snmpd
root 24931 1 1 07:25 ? 00:00:00 /usr/local/sbin/snmpd
root 24933 2130 0 07:25 pts/0 00:00:00 grep snmpd
[root@test net-snmp-5.4.1]# netstat -nulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:921 0.0.0.0:* 1593/rpc.statd
udp 0 0 0.0.0.0:924 0.0.0.0:* 1593/rpc.statd
udp 0 0 0.0.0.0:161 0.0.0.0:* 24931/snmpd
udp 0 0 0.0.0.0:111 0.0.0.0:* 1568/portmap
udp 0 0 0.0.0.0:631 0.0.0.0:* 1827/cupsd
[root@test net-snmp-5.4.1]#
snmpd가 잘 올라와 있군요.
그럼 snmpd가 서버의 자원을 제대로 수집하고 있는지도 확인해 보도록 하죠.
[root@test net-snmp-5.4.1]# snmpwalk -Os -c public -v 1 localhost system
sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-8.1.6.el5 #1 SMP Thu Jun 14 17:46:09 EDT 2007 i686
sysObjectID.0 = OID: netSnmpAgentOIDs.10
sysUpTimeInstance = Timeticks: (10179) 0:01:41.79
sysContact.0 = STRING: Me <me@somewhere.org>
sysName.0 = STRING: localhost.localdomain
sysLocation.0 = STRING: Right here, right now.
sysORLastChange.0 = Timeticks: (0) 0:00:00.00
sysORID.1 = OID: snmpFrameworkMIBCompliance
sysORID.2 = OID: snmpMPDCompliance
sysORID.3 = OID: usmMIBCompliance
sysORID.4 = OID: snmpMIB
sysORID.5 = OID: tcpMIB
sysORID.6 = OID: ip
sysORID.7 = OID: udpMIB
sysORID.8 = OID: vacmBasicGroup
sysORDescr.1 = STRING: The SNMP Management Architecture MIB.
sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model.
sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
sysORDescr.5 = STRING: The MIB module for managing TCP implementations
sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
sysORDescr.7 = STRING: The MIB module for managing UDP implementations
sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
sysORUpTime.1 = Timeticks: (0) 0:00:00.00
sysORUpTime.2 = Timeticks: (0) 0:00:00.00
sysORUpTime.3 = Timeticks: (0) 0:00:00.00
sysORUpTime.4 = Timeticks: (0) 0:00:00.00
sysORUpTime.5 = Timeticks: (0) 0:00:00.00
sysORUpTime.6 = Timeticks: (0) 0:00:00.00
sysORUpTime.7 = Timeticks: (0) 0:00:00.00
sysORUpTime.8 = Timeticks: (0) 0:00:00.00
[root@localhost net-snmp-5.4.1]#
sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-8.1.6.el5 #1 SMP Thu Jun 14 17:46:09 EDT 2007 i686
sysObjectID.0 = OID: netSnmpAgentOIDs.10
sysUpTimeInstance = Timeticks: (10179) 0:01:41.79
sysContact.0 = STRING: Me <me@somewhere.org>
sysName.0 = STRING: localhost.localdomain
sysLocation.0 = STRING: Right here, right now.
sysORLastChange.0 = Timeticks: (0) 0:00:00.00
sysORID.1 = OID: snmpFrameworkMIBCompliance
sysORID.2 = OID: snmpMPDCompliance
sysORID.3 = OID: usmMIBCompliance
sysORID.4 = OID: snmpMIB
sysORID.5 = OID: tcpMIB
sysORID.6 = OID: ip
sysORID.7 = OID: udpMIB
sysORID.8 = OID: vacmBasicGroup
sysORDescr.1 = STRING: The SNMP Management Architecture MIB.
sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model.
sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
sysORDescr.5 = STRING: The MIB module for managing TCP implementations
sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
sysORDescr.7 = STRING: The MIB module for managing UDP implementations
sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
sysORUpTime.1 = Timeticks: (0) 0:00:00.00
sysORUpTime.2 = Timeticks: (0) 0:00:00.00
sysORUpTime.3 = Timeticks: (0) 0:00:00.00
sysORUpTime.4 = Timeticks: (0) 0:00:00.00
sysORUpTime.5 = Timeticks: (0) 0:00:00.00
sysORUpTime.6 = Timeticks: (0) 0:00:00.00
sysORUpTime.7 = Timeticks: (0) 0:00:00.00
sysORUpTime.8 = Timeticks: (0) 0:00:00.00
[root@localhost net-snmp-5.4.1]#
위와 같이 나오면 아주 잘 작동하고 있다는 뜻입니다. ^^
그럼 하나 더 확인해 봅시다. 메모리 사용량을 볼까요?
[root@test net-snmp-5.4.1]# snmpwalk -Os -c public -v 1 localhost mem
memIndex.0 = INTEGER: 0
memErrorName.0 = STRING: swap
memTotalSwap.0 = INTEGER: 522104 kB
memAvailSwap.0 = INTEGER: 522104 kB
memTotalReal.0 = INTEGER: 255704 kB
memAvailReal.0 = INTEGER: 36032 kB
memTotalFree.0 = INTEGER: 558136 kB
memMinimumSwap.0 = INTEGER: 16000 kB
memShared.0 = INTEGER: 0 kB
memBuffer.0 = INTEGER: 19624 kB
memCached.0 = INTEGER: 162500 kB
memSwapError.0 = INTEGER: noError(0)
memSwapErrorMsg.0 = STRING:
[root@localhost net-snmp-5.4.1]#
memIndex.0 = INTEGER: 0
memErrorName.0 = STRING: swap
memTotalSwap.0 = INTEGER: 522104 kB
memAvailSwap.0 = INTEGER: 522104 kB
memTotalReal.0 = INTEGER: 255704 kB
memAvailReal.0 = INTEGER: 36032 kB
memTotalFree.0 = INTEGER: 558136 kB
memMinimumSwap.0 = INTEGER: 16000 kB
memShared.0 = INTEGER: 0 kB
memBuffer.0 = INTEGER: 19624 kB
memCached.0 = INTEGER: 162500 kB
memSwapError.0 = INTEGER: noError(0)
memSwapErrorMsg.0 = STRING:
[root@localhost net-snmp-5.4.1]#