Tuesday January 24, 2006 ![]() |
JMX, SNMP, Java, etc...Daniel Fuchs blogs on JMX, SNMP, Java, etc... |
Simple is not always Easy, and SNMP is a good example for this. In this blog I will try to broach on a few simple things about SNMP, and I hope you will find this introduction useful. SNMP stands for Simple Network Management Protocol - and is one of the most widely spread internet management protocols. It is based on UDP (though there exists an RFC defining SNMP over TCP) and uses BER for encoding. SNMP is an internet technology - specified by means of RFCs (Requests For Comments), which are issued through the Internet Engineering Task Force (IETF) SNMP defines both how to structure management information (data model exposed for management), and how to access it (protocol). According to SNMP, the management information is structured into MIBs (Management Information Bases). A MIB is defined using a formal language called Structure of Management Information (SMI) - whose syntax uses a subset of ASN.1. So when we speak of SNMP we usually mean two things:
The basic verbs of the SNMP protocol are GET, SET, and
GETNEXT (SNMPv2 adds GETBULK). An SNMP entity can also send
asynchronous events (a TRAP in SNMPv1, a NOTIFICATION or an
INFORM in SNMPv2). What you GET and SET are individual variables
of simple types (to simplify, strings/integers/enumerations) which can be
either scalar - or located in tables.
I can also recommend some good books on SNMP:
Now at this point, you're probably wondering why you're reading this blog,
and what all of this has to do with JMX, Java, etc... In a further blog, I am planning to delve further into the workings of SNMP and the JVM-MANAGEMENT-MIB. I may also make use of the Java Dynamic Management Kit - which includes a Java SNMP toolkit - in order to demonstrate how the JVM can be monitored through SNMP So until then, stay tuned! PS: see also my next entries in this series: [What is the JVM SNMP Agent?] [Life, the Universe, and Everything... or the Hitchhiker's Guide to SNMP] [Understanding the Structure of Management Information (SMI)... or the Hitchhiker's Guide to SNMP, Part-II] [Don't fall in the traps... or the Hitchhiker's Guide to SNMP, Part-III] [Traces in the JVM SNMP Agent], [Welcome to the SNMP table!.. or the Hitchhiker's Guide to SNMP, Part-IV]. Posted by dfuchs ( Jan 24 2006, 10:11:21 PM CET ) Permalink Comments [7] |
Posted by Rory on February 16, 2006 at 01:02 PM CET #
The JVM SNMP agent just provides information about the JVM in which it's running - it won't allow you to get information from any other SNMP devices.
If you want to retrieve information from SNMP devices - you will need to use an SNMP API for Java - like for instance the Java DMK (see link on this page) - or other libraries/toolkit which you will easily find with a Google Search.
Does that answer your question?
Posted by Daniel Fuchs on February 16, 2006 at 04:20 PM CET #
Posted by pooja on May 07, 2007 at 08:27 AM CEST #
You're heading the wrong way here.
What you need to do is:
1) Understand what an SNMP trap is and how it is used
2) Understand what are the requirement that drives you to convert a JMX Notification into a trap
3) Understand what the SNMP manager who will receive the trap will do with it.
By answering these three questions you will be able to know what kind of traps you need, and how they should look like.
Then you will a) write a MIB in which you will define these trap, or b) you will find MIBs which already define the traps you need.
If it's a) then you will need to find out whether you company as an IANA assigned number for SNMP. For instance, as I have already explained, Sun Microsystems has number 42.
If your company doesn't have such a number and you want to write your MIB, then you will need to apply for that.
When your MIB is written, you can use mibgen if you want to generate a table [OID-label,OID-value]. It's the only interesting thing that mibgen generates for traps. However, you do not really need to perform this step. You can use directly the OID-values when you build your Trap PDU. You don't really need mibgen to send trap. Just send them.
What you really need to do is to define the traps you want to send, and write this definition into a MIB, so that you can explain what the trap is and how it is supposed to be used.
See: Don't fall in the traps... to learn more about traps, and the Java DMK 5.1 Tutorial to learn how to send traps.
I also suggest reading "Understanding SNMP MIBs", by Perkins & McGinnis, Prentice Hall.
-- daniel
Posted by daniel on May 09, 2007 at 04:27 PM CEST #
Hi,
Excellent post, I am new to snmp this blog has helped me a lot in understanding it. We need to generate snmp traps from our java application, can you suggest me from where to start? what open source libraries are available?
some tutorials?
Posted by sudhir on November 26, 2007 at 08:07 AM CET #
Hi Sudhir,
What I would suggest is to start with the trap defininition. First you should determine what kind of application is going to consume the traps, and what it will do with these traps. This will help you understand which trap you need to generate, and what kind of information they should contain.
While doing this you must take into account the limitation of the SNMP protocol: size limitation, and the fact that the trap may be lost - either by the network, or because of buffer overflow on the client side if your application emits too many traps with a high frequency.
When this is done you can start writing your trap definitions (your MIB). Put as much explanation as you can in the object descriptions: the reader should understand what this is all about just by reading the MIB.
You may have already read this post:
"Don't fall in the traps"
http://blogs.sun.com/jmxetc/entry/don_t_fell_in_the
if not you probably should ;-)
As regards to open source libraries you might want to use OpenDMK http://opendmk.dev.java.net/ - or else I'm sure that a quick google for snmp+java will reveal other candidates.
Hope this helps!
-- daniel
Posted by daniel on November 26, 2007 at 10:48 AM CET #
Hi denial,
Thanks for your reply.
We need to generate simple application alerts, this traps will be consumed by snmp manager (IBM Tivoli).
Posted by sudhir on November 26, 2007 at 11:37 AM CET #