Luky Library - 4.1.1 (20061117-1148)

luky.snmp
Class AdvancedSnmpManager

java.lang.Object
  extended by luky.events.MyEventManager
      extended by luky.snmp.AdvancedSnmpManager
All Implemented Interfaces:
Runnable, Observer

public class AdvancedSnmpManager
extends MyEventManager
implements Runnable, Observer

The AdvancedSnmpManager creates a re-entrend version of the SnmpManager the idea is to save significant memory and boost performance.

The fired ExtendedEvents hold event data "host" "oid" and "result"

Revision Changes :

Version:
2.02
Author:
Chris Lukassen
 

Field Summary
 
Fields inherited from class luky.events.MyEventManager
listenerList
 
Constructor Summary
AdvancedSnmpManager(String community, int port, int interval)
          Constructor.
 
Method Summary
 String addOid(String host, String oidName, String mib)
          adds a new Oid for this manager
 boolean initOk()
          tells if the constructor could initialize the snmp context correctly better not use the manager is it is false
 String performGet(String host, String oidName, String mib)
          performs a snmp get for oidName (optionally in mib) with value decodes the result
 String performGet(String host, String oidName, String mib, boolean decode)
          performs a snmp get for oidName (optionally in mib) with value
 String performSet(String host, String oidName, String mib, String value)
          performs a snmp set for oidName (optionally in mib) with value
 void run()
          performs a get operation for the added oid, in a continious polling
 void start()
          starts a new thread to poll stored oid, sends event on state change
 void stop()
          stop the polling, destoys the context of the poll
 void update(Observable obs, Object ov)
          Implementing the Observer interface.
 
Methods inherited from class luky.events.MyEventManager
addMyEventListener, fireMyEvent, removeMyEventListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdvancedSnmpManager

public AdvancedSnmpManager(String community,
                           int port,
                           int interval)
Constructor.

Parameters:
community - snmp community string (suggest: "public")
port - snmp port, 161 is normal
interval - delay between polls, in microseconds
Method Detail

addOid

public String addOid(String host,
                     String oidName,
                     String mib)
adds a new Oid for this manager

Parameters:
host - the host to be polled
oidName - can be a number .1.3.etc or a id eg. sysUptime.0
mib - mib file (full path) to translate a mib, if the oid needs it e.g. sysUptime.0
Returns:
the resolved oid

update

public void update(Observable obs,
                   Object ov)
Implementing the Observer interface. Receiving the response from the AdvancedSnmpManagerObject. Fires events to the listners

Specified by:
update in interface Observer
Parameters:
obs - the AdvancedSnmpManagerObject variable
ov - the varbind
See Also:
varbind

performSet

public String performSet(String host,
                         String oidName,
                         String mib,
                         String value)
performs a snmp set for oidName (optionally in mib) with value

Parameters:
oidName - can be a number .1.3.etc or a id eg. sysUptime.0
mib - mib file (full path) to translate a mib, if the oid needs it e.g. sysUptime.0
Returns:
decoded result

performGet

public String performGet(String host,
                         String oidName,
                         String mib)
performs a snmp get for oidName (optionally in mib) with value decodes the result

Parameters:
oidName - can be a number .1.3.etc or a id eg. sysUptime.0
mib - mib file (full path) to translate a mib, if the oid needs it e.g. sysUptime.0
Returns:
decoded result

performGet

public String performGet(String host,
                         String oidName,
                         String mib,
                         boolean decode)
performs a snmp get for oidName (optionally in mib) with value

Parameters:
oidName - can be a number .1.3.etc or a id eg. sysUptime.0
mib - mib file (full path) to translate a mib, if the oid needs it e.g. sysUptime.0
decode - boolean, specifing if the result should be decoded
Returns:
result

run

public void run()
performs a get operation for the added oid, in a continious polling

Specified by:
run in interface Runnable

initOk

public boolean initOk()
tells if the constructor could initialize the snmp context correctly better not use the manager is it is false

Returns:
the status in Constants format

start

public void start()
starts a new thread to poll stored oid, sends event on state change


stop

public void stop()
stop the polling, destoys the context of the poll


Luky Library - 4.1.1 (20061117-1148)