Anda di halaman 1dari 17

Java MIB Browser

Laurent de Moussac CS 6255 Fall 2001

Introduction
Writing a Java MIB browser : Using introduced concepts Different tools (ANTLR, JDMK)
MIB Browser Application

Global structure
SMICNG :
Converts RFC to a specific format (MOSY)

SMICNG

ANTLR

ANTLR :
Parser, creates data structures

Application in Java JDMK :


Java Dynamic Management Kit

Java Application GUI swing

JDMK

ANTLR (by Terrence Parr)


Useful tool to create lexers, parsers, AST walkers in Java (or in C) High level language, avoid the low level parsing utilities Rules using RegExp Lexer and Parser

JDMK
Sun Toolkit Agents and Managers Provides an API for accessing :
SNMP HTTP, HTTPS, RMI Scheduling, Monitoring

Architecture independent (Java !) MIB Compiler (not used in this project)

JDMK SNMP
Very simple to use SNMP V1 to V3 Synchronous or Asynchronous Classes to describe requests, MIB objects, MIB OIDs etc Browsable Javadoc with the API Can be used for agents or managers
Warning : Bug in the 1.1 compiler

Code example for JDMK


SnmpOidTableSupport oidTable = new RFC1213_MIBOidTable(); SnmpOid.setSnmpOidTable(oidTable); SnmpPeer agent = new SnmpPeer(host, Integer.parseInt(port)); SnmpParameters params = new SnmpParameters("public", "private"); agent.setSnmpParam(params); SnmpSession session= new SnmpSession("SyncManager session"); session.setDefaultPeer(agent); SnmpVarBindList list = new SnmpVarBindList("SyncManager varbind list"); list.addVarBind("sysDescr.0"); SnmpRequest request = session.snmpGetRequest(null, list); boolean completed = request.waitForCompletion(10000);

SnmpVarBindList result = request.getResponseVarBindList(); System.out.println(result); session.destroySession();

SyncManager.java

Set up the OID Table


SnmpOidTableSupport oidTable = new RFC1213_MIBOidTable(); SnmpOid.setSnmpOidTable(oidTable) ; The table class can be automatically generated Necessary to use this format
SyncManager.java

Create a peer
SnmpPeer agent = new SnmpPeer(host, Integer.parseInt(port)); SnmpParameters params = new SnmpParameters("public", "private"); agent.setSnmpParam(params);

High level interface As if it were local

Create an SNMP session


SnmpSession session= new SnmpSession("SyncManager session"); session.setDefaultPeer(agent);
The session manages the requests and the reply

Generate list of OIDs


SnmpVarBindList list = new SnmpVarBindList("SyncManager varbind list"); list.addVarBind("sysDescr.0");

Allows to generate requests on multiple OIDs Generally used with only one element

Generate the request


SnmpRequest request = session.snmpGetRequest(null, list); boolean completed = request.waitForCompletion(10000);

Actual request. Can only be created from an existing session.

Get the result


SnmpVarBindList result = request.getResponseVarBindList (); System.out.println(result); session.destroySession(); The results are added to the request object

My MIB-Browser
Can load different RFC files
Need to be converted in MOSY by SmicNG

Can walk a branch of the tree Cache of previously fetched values


Table indexes reset is manual

Get, GetNext and Set Set was not tested Written in Java (architecture independent)

Issues
Table indexes: when to update ? String and physical addresses Problem of display on some OS or for remote connection.

Evolution / Conclusion
Parse RFC directly (get rid off SmicNG) Support for trap messages Support for SNMP V3
Easier to implement than expected Versatility of JDMK

Exam questions ?
What tools can be used to make SNMP requests in Java ? How would you differentiate real strings from physical addresses if you had to implement a MIB Browser ?

Anda mungkin juga menyukai