net-snmp installation and configuration
Recently I spent much time to learn SNMP to try to setup a snmp server for the developers. The following is the steps of installation and configuration of net-snmp, a popular and open source snmp server and agent .
http://www.myfaq.com.cn/2005September/2005-09-13/208338.html
DOWNLOAD AND INSTALL
1.download the source.
http://sourceforge.net/projects/net-snmp
or the official web: http://www.net-snmp.org/
2.Extract the packet.
tar -zxvf net-snmp-5.4.tar.gz
3.Compile the packet.
cd net-snmp-5.4
./configure (for example ./configure
--with-mib-modules="agentx")
make
make test
make install
4.Copy the example configure file
cp EXAMPLE.conf /usr/local/share/snmp/snmpd.conf
5.Modify the configure file as following
Change the COMMUNITY to democommunity which is a community string
6.check the process of snmpd and kill it and then run it
ps -A | grep snmp kill xxxx snmpd -d -L
7.have a try.
snmpget -v 1 -c democommunity localhost system.sysUpTime.0
INSTALL A MIB
1. A mibs file like JM-TEST-1-MIB.txt. the following is the content.
JM-TEST-1-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY,
OBJECT-TYPE,
INTEGER
FROM SNMPv2-SMI;
jmtest MODULE-IDENTITY
LAST-UPDATED "200203210000Z"
ORGANIZATION "Temple U"
CONTACT-INFO
"None yet."
DESCRIPTION
"AgentX testing MIB"
REVISION "200203210000Z"
DESCRIPTION
"None yet."
::= { experimental 72}
firstKey OBJECT-TYPE
SYNTAX INTEGER (0..100)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Value initialized to 0 and on each
access:
- Return current val.
- increment"
::= { jmtest 1 }
END
2.Copy the mib file to the correct locations
cp JM-TEST-1-MIB.txt /usr/local/share/snmp/mibs
3.Let the snmp tools to recognize the mibs
echo
"mibs +JM-TEST-1-MIB" >> /usr/local/share/snmp/snmp.conf
4.Use the snmptranslate to verify if the mib is loaded.
snmptranslate -IR -Tp experimental
and should get the following show:
Unlinked OID in JM-TEST-1-MIB: jmtest ::= { experimental 72 }
+--experimental(3)
|
+--jmtest(72)
+-- -RW- INTEGER firstKey(1)
Range: 0..100
http://net-snmp.cn/snmp/32.html