Luky Library - 4.1.1 (20061117-1148)

luky.snmp
Class SnmpManager

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

public class SnmpManager
extends MyEventManager
implements Runnable, Observer

The SnmpManger application will use the OneGetPdu to request a MIB variable. It contains a mib resolver and thread spawner.
Create your object and use performGet() to trigger the result,
or call start to commence a continous polling that will fire events on a state change.

Version:
$Revision: 1.2 $ $Date: 2002/10/22 16:34:15 $
Author:
Birgit Arkesteijn and Chris Lukassen
 

Field Summary
 int interval
           
 
Fields inherited from class luky.events.MyEventManager
listenerList
 
Constructor Summary
SnmpManager(String host, String community, int port, int interval, String mib, String oid)
          Constructor.
 
Method Summary
 void init(int interval, String mib)
          init routing.
 boolean initOk()
           
 String performGet()
          performs a get operation for a single poll, not a continious polling
 String performSet()
          performs a set operation for a single oid, not a continious polling
 void run()
          performs a get operation for a single oid, in a continious polling
 void setOid(String oid)
          sets a new Oid for this manager
 void setOid(String oid, String mib)
          sets a new Oid for this manager
 void setSnmpSetValue(String value)
           
 void start()
          starts a new thread to poll 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
 

Field Detail

interval

public int interval
Constructor Detail

SnmpManager

public SnmpManager(String host,
                   String community,
                   int port,
                   int interval,
                   String mib,
                   String oid)
Constructor.

Parameters:
host - target host
community - snmp community string (suggest: "public")
port - snmp port, 161 is normal
interval - delay between polls, in microseconds
mib - mib file (full path) to translate a mib, if the oid needs it e.g. sysUptime.0
oid - can be a number .1.3.etc or a id eg. sysUptime.0
Method Detail

setOid

public void setOid(String oid,
                   String mib)
sets a new Oid for this manager

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

setOid

public void setOid(String oid)
sets a new Oid for this manager

Parameters:
oid - can be a number .1.3.etc or a id eg. sysUptime.0

init

public void init(int interval,
                 String mib)
init routing.

Parameters:
interval - delay between polls, in microseconds
mib - mib file (full path) to translate a mib, if the oid needs it e.g. sysUptime.0 can The files can be seperated by a space, tab, new line, carriage return and pipe symbol. ("../mibs/RFC1213-MIB ../mibs/IF-MIB"); MIBs can also be loaded from string URLs. In case of loading the files from space seperated directories, the whole String should be given within the double quotes. for e.g. if the MIB file is present in the directory 'Program Files', ("\"../../mibs/Program Files/RFC1213-MIB\"")

update

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

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

setSnmpSetValue

public void setSnmpSetValue(String value)

performGet

public String performGet()
performs a get operation for a single poll, not a continious polling


performSet

public String performSet()
performs a set operation for a single oid, not a continious polling


run

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

Specified by:
run in interface Runnable

initOk

public boolean initOk()

start

public void start()
starts a new thread to poll 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)