|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.snmp.beans.SnmpServer | +--com.adventnet.snmp.beans.SnmpTarget
This class is a lightweight SNMP session for use with other beans in applications and applets. It sends synchronous SNMP requests. It contains an array of OIDs specifying variables used in SNMP operations, and list of values for set and trap operations. MIB support and other SNMP functions are built into this class. The SnmpTarget bean is used for many of the common operations that we do with a SNMP agent such as get, getnext, set and trap operations. MIB support and other SNMP functions are built into this class. This bean can be used to make a single variable request, multiple variable requests, walking a table and a number of operations, including loading MIBs to support SNMP operations, getting all instances of a variable type, etc
To use in an application, simply instantiate, specify the object IDs, and perform operations. For example,
SnmpTarget target = new SnmpTarget(); target.setTargetHost("localhost"); // set host, or other parameters target.setObjectID(".1.3.6.1.2.1.1.1.0"); // or 1.1.0 with standard prefix String result = target.snmpGet();To use in an applet use an alternate constructor, but the procedure is the same. For example,
if (result == null) System.err.println("Failed: "+target.getErrorString()); else System.out.println("Response: "+result);
SnmpTarget target = new SnmpTarget(appletInstance); target.setTargetHost("localhost"); // set host, or other parameters target.setObjectID(".1.3.6.1.2.1.1.1.0"); // or 1.1.0 with standard prefix String result = target.snmpGet();This class supports multiple variable requests, and a number of operations, including loading MIBs to support SNMP operations, getting all instances of a variable type, etc..
if (result == null) System.err.println("Failed: "+target.getErrorString()); else System.out.println("Response: "+result);
For multiple variable requests, set the OID list using the setObjectIDList(String[]) or setSnmpOIDList(SnmpOID[]) methods. Your SNMP operations with this SnmpTarget will use this list.
We can also register for events from the SnmpTarget component, so that we can notify another object whenever a response is received for any request. This may be useful for example in applying the result of a query to multiple objects. However, in most cases, the synchronous use of this component will not use events and event registration. The listeners that are registered for receiving responses from the agent should register, using setSendTimeoutEvents(true) to get the timeout events, which otherwise, will not be passed to the listener. This class can be used directly, and it will also be used by beans, e.g. SnmpPoller bean, which provides SNMP services. For garbage collection of the resources used, releaseResources() method should be invoked. Different SnmpTarget instances on the same JVM, will reuse the SnmpAPI, SnmpSession and MibOperations instance. So, for releasing these resources, releaseResources() method should be called on every SnmpTarget instance created and when this method is called on the final instance of SnmpTarget, these will be garbage collected.
Field Summary | |
boolean |
serialize
based on this flag v3 table like USMUserTable and SnmpEngineTable will be serialized |
static byte |
SNMPGET
Constant for SNMP get request. |
static byte |
SNMPGETBULK
Constant for SNMP V2 Get Bulk request. |
static byte |
SNMPGETNEXT
Constant for SNMP get next request. |
static byte |
SNMPINFORM
Constant for SNMP V2 INFORM request. |
static byte |
SNMPREPORT
Constant for SNMP V2 Report request. |
static byte |
SNMPRESPONSE
Constant for SNMP response request |
static byte |
SNMPSET
Constant for SNMP set request. |
static byte |
SNMPTRAP
Constant for SNMP trap request. |
static byte |
SNMPV2TRAP
Constant for SNMP V2 Trap request. |
static int |
VERSION1
Constant for SNMP Version 1. |
static int |
VERSION2C
Constant for SNMP Version 2C. |
static int |
VERSION3
Constant for SNMP Version 3. |
Fields inherited from class com.adventnet.snmp.beans.SnmpServer |
AUTH_NO_PRIV, AUTH_PRIV, MD5_AUTH, NO_AUTH, NO_AUTH_NO_PRIV, oidList, SHA_AUTH |
Constructor Summary | |
SnmpTarget()
This constructor is used in applications. |
|
SnmpTarget(java.applet.Applet applet)
Use this constructor for applets. |
|
SnmpTarget(java.applet.Applet applet,
int port,
java.lang.String session)
Use this constructor for creating a new session for this applet. |
|
SnmpTarget(int protocol,
ProtocolOptions options)
This constructor is used for applications which use protocol other than UDP/IP. |
|
SnmpTarget(int port,
java.lang.String session)
This constructor is used for creating a new session for this application. |
|
SnmpTarget(java.lang.String[] localAddrs,
java.lang.String sessionName)
Use this constructor for applications in which the session needs to be bound to some local address. |
Method Summary | |
void |
addLogClient(LoggerProperties loggerProps)
Adds the Log client for which the target has to redirect the log messages. |
void |
addLogClient(LogInterface client)
Add the Log client for which the target has to redirect the log messages |
int |
addObjectID(java.lang.String s)
This method adds an SnmpOID specified by string to the SnmpOID list. |
void |
addResultListener(ResultListener l)
Adds a listener for events from this target. |
int |
addSnmpOID(SnmpOID oid)
This method adds an SnmpOID to the previously set list of SnmpOID |
void |
addSnmpPropertyListener(SnmpPropertyListener l)
Adds SnmpPropertyListener to the SnmpPropertyListener list. |
void |
addV3HandShakeResultListener(V3HandShakeResultListener l)
Adds a listener to receive the events when SnmpEngineID discovery and time Synchronization is performed by the method async_create_v3_tables. |
protected void |
genEvent(SnmpPDU pdu)
Generates the events to the listeners |
protected void |
genTimeoutEvent(SnmpPDU pdu)
Generates the events to the listeners |
boolean |
getAttemptComplete()
Returns if the splitting pdu is enabled to get the complete data by splitting the varbinds into multiple request. |
boolean |
getAttemptPartial()
Returns the boolean state of whether this target will try to get partial data from an agent if the request is a multiple variable request. |
java.lang.String |
getAuthPassword()
Gets the SNMP V3 AuthPassword |
int |
getAuthProtocol()
Gets the SNMP V3 AuthProtocol |
java.lang.String |
getCommunity()
Gets the SNMP target Community |
SnmpResultObject |
getCompleteResponse()
Gets the complete data from the agent by splitting the varbinds into multiple requests.This can set if request pdu is very big. |
java.lang.String |
getContextID()
Gets the SNMP V3 contextID. |
java.lang.String |
getContextName()
get the SNMP V3 Context name |
boolean |
getDebug()
This method returns true if debug mode is enabled and false otherwise |
int |
getErrorCode()
Gets the error code for the last request. |
int |
getErrorIndex()
To get the error index corresponding to the errored oid in the pdu. |
java.lang.String |
getErrorString()
Gets the error string for the request sent. |
int |
getExceptionCode()
Gets the exception code for the last request. |
boolean |
getIgnoreSpecificControlCodes()
Gets the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values. |
int |
getMaxNumRows()
Gets the maximum number of rows that can be processed, default value is 1000. |
int |
getMaxRepetitions()
Gets the SNMP target max repetitions value for a getbulk request. |
java.lang.String |
getMibModules()
This method returns all the MIBs that are loaded in this applet/application. |
MibOperations |
getMibOperations()
get the MibOperations object reference. |
int |
getNonRepeaters()
Gets the SNMP target non-repeaters value for a getbulk request Default is 0. |
java.lang.String |
getObjectID()
This method returns the first object ID as a string |
java.lang.String |
getObjectID(int index)
This method returns the object ID at index as a string |
java.lang.String[] |
getObjectIDList()
This method returns the list of object IDs as a string array or null, if no OIDs is set previously. |
java.lang.String |
getPrincipal()
Gets the SNMP V3 Principal |
java.lang.String |
getPrivPassword()
Gets the SNMP V3 PrivPassword |
int |
getRetries()
Gets the SNMP target retries value. |
java.lang.String |
getSecurityLevel()
Gets the SNMP V3 SecurityLevel |
int |
getSecurityModel()
Gets the SNMP V3 securityModel |
boolean |
getSendTimeoutEvents()
Returns the boolean state of whether this target will send timeout events to a registered listener. |
SnmpOID |
getSnmpOID()
This method returns the first SnmpOID from the list of object IDs or null, if no OID is set previously. |
SnmpOID[] |
getSnmpOIDList()
This method returns the list of object IDs as an array of SnmpOID or null if no OID is set previously. |
int |
getSnmpVersion()
Gets the SNMP target SNMP Version. |
java.lang.String |
getTargetHost()
Gets the SNMP target hostname |
int |
getTargetPort()
get the SNMP target port number |
int |
getTimeout()
Gets the SNMP target timeout value |
int |
getVarBindCount()
Returns the number of varbinds used with the splitted pdu. |
java.lang.String |
getWriteCommunity()
Gets the SNMP target write Community to be used for set requests |
static boolean |
isInSubTree(SnmpOID rootoid,
SnmpOID objid)
Check if objid has rootoid as an ancestor. |
boolean |
isSerialize()
Returns the status of Serialization of v3 tables ( USMUserTable and SnmpEngineTable ) |
void |
loadMibs(java.lang.String mibs)
Load the mibs specified by white-space separated list of mibs. |
void |
releaseResources()
Though the resources will be cleaned up by the garbage collector, if the application is no more using the SnmpTarget bean instance, this method can be used to immediately release the resources. |
void |
removeLogClient()
Removes the Log client for which the target has been registered to redirect the log Messages. |
void |
removeResultListener(ResultListener l)
Removes a listener for events from this target. |
void |
removeSnmpPropertyListener(SnmpPropertyListener l)
Removes the SnmpPropertyListener from the list maintained by this target. |
void |
removeV3HandShakeListener(V3HandShakeResultListener l)
Removes the listener registered for getting events. |
void |
setAttemptComplete(boolean flag)
Enables the flag to get the complete data from the agent by splitting the varbinds into multiple request.This can set if request pdu is very big. |
void |
setAttemptPartial(boolean b)
Sets the boolean state of whether this target will try to get a partial data from an agent if the request is a multi variable request. |
void |
setAuthPassword(java.lang.String password)
Sets the SNMP V3 AuthPassword |
void |
setAuthProtocol(int protocol)
Sets the SNMP V3 AuthProtocol |
void |
setCommunity(java.lang.String s)
Sets the SNMP target Community |
void |
setContextID(java.lang.String ctxtID)
Sets the SNMP V3 contextID. |
void |
setContextName(java.lang.String cName)
set the SNMP V3 Context name |
void |
setDebug(boolean debug)
This method determines if debug output will be printed |
void |
setIgnoreSpecificControlCodes(boolean specConCode)
Sets the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values. |
void |
setMaxNumRows(int maxRows)
Sets the maximum number of rows that can be processed, default value is 1000. |
void |
setMaxRepetitions(int i)
Sets the SNMP target max repetitions value for a getbulk request. |
void |
setMibModules(java.lang.String mibs)
This method sets the MIB to be loaded in this applet/application. |
void |
setNonRepeaters(int i)
Sets the SNMP target non-repeaters value for a getbulk request Default is 0. |
void |
setObjectID(int index,
java.lang.String s)
This method sets the object ID value at index based on specified string |
void |
setObjectID(java.lang.String s)
This method sets the object ID specified by the String value. |
void |
setObjectIDList(java.lang.String[] s)
This method sets the list of object IDs based on the specified string array. |
void |
setParams(java.lang.String host,
java.lang.String port,
java.lang.String community,
java.lang.String mib,
java.lang.String oid)
To set Multiple parameters like TargetHost,Port,Community,MibModule and OID. |
void |
setParams(java.lang.String host,
java.lang.String port,
java.lang.String community,
java.lang.String mib,
java.lang.String[] oidlist)
To set Multiple parameters like TargetHost,Port,Community,MibModule and OIDList. |
void |
setPrincipal(java.lang.String s)
Sets the SNMP V3 Principal |
void |
setPrivPassword(java.lang.String password)
Sets the SNMP V3 PrivPassword |
void |
setRetries(int i)
Sets the SNMP target retries value. |
void |
setSecurityLevel(byte sLevel)
Sets the SNMP V3 SecurityLevel.The value will be 0 ,1 or 3. |
void |
setSecurityModel(int securityModel)
Sets the SNMP V3 SecurityModel |
void |
setSendTimeoutEvents(boolean b)
This should be set to true if the listener should be notified of the timeout events in case if the request timesout. |
void |
setSnmpOID(SnmpOID oid)
This method sets the SnmpOID |
void |
setSnmpOIDList(SnmpOID[] list)
This method sets the list of object IDs as the given array of SnmpOID |
void |
setSnmpVersion(int i)
Sets the SNMP target SNMP Version. |
void |
setTargetHost(java.lang.String s)
This method sets the SNMP target hostname |
void |
setTargetPort(int i)
set the SNMP target port number |
void |
setTimeout(int i)
Sets the SNMP target timeout value |
void |
setVarBindCount(int count)
Set the number of varbinds per request to get the complete data from the agent by splitting the varbinds into multiple request in case if the request pdu is very big. |
void |
setWriteCommunity(java.lang.String s)
Sets the SNMP target write Community to be used for set requests |
java.lang.String |
snmpGet()
Queries the target and returns as a string the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. |
SnmpVar |
snmpGet(SnmpOID oid)
Gets the SNMP variable identified by specified Object Identifier. |
java.lang.String[][] |
snmpGetAllList()
Gets all instances of variables in the OID list. |
SnmpVarBind[][] |
snmpGetAllVariableBindings()
Gets all instances of variables in the OID list. |
SnmpVar[][] |
snmpGetAllVariables()
Gets all instances of variables in the OID list. |
java.lang.String[][] |
snmpGetBulkList()
Get bulk on list of variables in the OID list. |
SnmpVarBind[][] |
snmpGetBulkVariableBindings()
Get bulk on list of variables in the OID list. |
SnmpVar[][] |
snmpGetBulkVariables()
Get bulk on list of variables in the OID list. |
java.lang.String[] |
snmpGetList()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. |
SnmpVar[] |
snmpGetList(SnmpOID[] oids)
Gets the list of SNMP variables identified by the Object Identifier list stored in this SnmpTarget instance. |
java.lang.String |
snmpGetNext()
Queries the target and returns as a string the next SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. |
SnmpVar |
snmpGetNext(SnmpOID oid)
Gets the SNMP variable identified by specified Object Identifier. |
java.lang.String[] |
snmpGetNextList()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. |
SnmpVar[] |
snmpGetNextList(SnmpOID[] oids)
Gets the list of SNMP variables identified by the Object Identifier list stored in this SnmpTarget instance. |
SnmpVar |
snmpGetNextVariable()
Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. |
SnmpVarBind |
snmpGetNextVariableBinding()
Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. |
SnmpVarBind[] |
snmpGetNextVariableBindings()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. |
SnmpVar[] |
snmpGetNextVariables()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. |
SnmpVar |
snmpGetVariable()
Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. |
SnmpVarBind |
snmpGetVariableBinding()
Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. |
SnmpVarBind[] |
snmpGetVariableBindings()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. |
SnmpVar[] |
snmpGetVariables()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. |
void |
snmpSendInformAcknowledgement(long uptime,
SnmpOID oid,
SnmpVar[] values,
int reqID)
|
SnmpVarBind[] |
snmpSendInformRequest(long uptime,
SnmpOID trapOid,
SnmpVar[] values)
This method is used to send an SNMPV2 inform pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. |
java.lang.String[] |
snmpSendInformRequest(long uptime,
java.lang.String trapOid,
java.lang.String[] values)
This method is to send an SNMPV2 inform pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. |
void |
snmpSendNotification(long uptime,
SnmpOID trapOid,
SnmpVar[] values)
This method is used to send an SNMPV2 notification pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. |
void |
snmpSendNotification(long uptime,
java.lang.String trapOid,
java.lang.String[] values)
This method is used to send an SNMPV2 notification pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. |
void |
snmpSendTrap(SnmpOID enterprise,
java.lang.String agenthost,
int genericType,
int specificType,
long uptime,
SnmpVar[] values)
This method is used to send an SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. |
void |
snmpSendTrap(java.lang.String enterprise,
java.lang.String agenthost,
int genericType,
int specificType,
long uptime,
java.lang.String[] values)
This method is used to send an SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. |
java.lang.String |
snmpSet(java.lang.String value)
This method is used to do an SNMP set to the target using value specified of the first variable on the variable list. |
java.lang.String |
snmpSet(java.lang.String value,
byte type)
This method is used to do an SNMP set to the target of the first variable on the variable list using value specified. |
java.lang.String[] |
snmpSetList(java.lang.String[] values)
This method sets the list of SNMP variable bindings on the agent using the Object Identifier list previously set in this SnmpTarget instance. |
SnmpVar |
snmpSetVariable(SnmpVar var)
This method is used to do an SNMP set with specified value to the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. |
SnmpVar[] |
snmpSetVariables(SnmpVar[] values)
This method is used to do an SNMP set, with values specified, the list of SNMP variable bindings on the agent, using the Object Identifier list previously set in this SnmpTarget instance. |
void |
vetoableChange(java.beans.PropertyChangeEvent e)
This method is called when a vetoableChange event is fired from the propertySetting bean. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.adventnet.snmp.beans.CustomizerTemplate |
create_v3_tables, getSnmpEngineTable, getUSMTable, initSecurityProvider, isSupportedSecurityModel, manage_v3_tables |
Field Detail |
public static final byte SNMPGET
public static final byte SNMPGETNEXT
public static final byte SNMPRESPONSE
public static final byte SNMPSET
public static final byte SNMPTRAP
public static final byte SNMPGETBULK
public static final byte SNMPINFORM
public static final byte SNMPV2TRAP
public static final byte SNMPREPORT
public static final int VERSION1
public static final int VERSION2C
public static final int VERSION3
public boolean serialize
Constructor Detail |
public SnmpTarget()
public SnmpTarget(int protocol, ProtocolOptions options)
public SnmpTarget(int port, java.lang.String session)
public SnmpTarget(java.applet.Applet applet)
public SnmpTarget(java.applet.Applet applet, int port, java.lang.String session)
public SnmpTarget(java.lang.String[] localAddrs, java.lang.String sessionName)
localAddrs
- The local addresses to which the session needs
to be bound.sessionName
- Specify unique sessionNames for the instances
which need to use different SnmpSession instances to send data.Method Detail |
public void loadMibs(java.lang.String mibs) throws MibException, java.io.IOException, java.io.FileNotFoundException
MibException
- is thrown while parser error occurs.java.io.IOException
- is thrown when IO error occurs.java.io.FileNotFoundException
- is thrown if the file is not found.public java.lang.String snmpGet()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar snmpGetVariable()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVarBind snmpGetVariableBinding()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar snmpGet(SnmpOID oid)
ErrorMessages
,
getErrorCode()
,
getErrorString()
public java.lang.String[] snmpGetList()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar[] snmpGetVariables()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVarBind[] snmpGetVariableBindings()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar[] snmpGetList(SnmpOID[] oids)
oids
- - an Array of SnmpOIDErrorMessages
,
getErrorCode()
,
getErrorString()
public java.lang.String snmpGetNext()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar snmpGetNextVariable()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVarBind snmpGetNextVariableBinding()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar snmpGetNext(SnmpOID oid)
ErrorMessages
,
getErrorCode()
,
getErrorString()
public java.lang.String[] snmpGetNextList()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar[] snmpGetNextVariables()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVarBind[] snmpGetNextVariableBindings()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar[] snmpGetNextList(SnmpOID[] oids)
ErrorMessages
,
getErrorCode()
,
getErrorString()
public java.lang.String snmpSet(java.lang.String value) throws DataException
DataException
- is thrown if data is invalidErrorMessages
,
getErrorCode()
,
getErrorString()
public java.lang.String snmpSet(java.lang.String value, byte type) throws DataException
DataException
- is thrown if data is invalidErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar snmpSetVariable(SnmpVar var) throws DataException
DataException
- is thrown if data is invalidErrorMessages
,
getErrorCode()
,
getErrorString()
public java.lang.String[] snmpSetList(java.lang.String[] values) throws DataException
DataException
- is thrown if data is invalidErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar[] snmpSetVariables(SnmpVar[] values) throws DataException
DataException
- is thrown if data is invalidErrorMessages
,
getErrorCode()
,
getErrorString()
public void snmpSendTrap(java.lang.String enterprise, java.lang.String agenthost, int genericType, int specificType, long uptime, java.lang.String[] values) throws DataException
DataException
- is thrown if data is invalidErrorMessages
,
getErrorCode()
,
getErrorString()
public void snmpSendTrap(SnmpOID enterprise, java.lang.String agenthost, int genericType, int specificType, long uptime, SnmpVar[] values) throws DataException
DataException
- is thrown if data is invalidErrorMessages
,
getErrorCode()
,
getErrorString()
public void snmpSendNotification(long uptime, SnmpOID trapOid, SnmpVar[] values) throws DataException
uptime
- The sysUptime value. This is the first oid sent with the
notification. The corresponding oid need not be present
in the oidList.values
- It contains an array of SnmpVar values corresponding to the
oids in the oidList.trapOid
- This should contain the oid corresponding to the snmpTrapOID.DataException
- is thrown for invalid values.ErrorMessages
,
getErrorCode()
,
getErrorString()
public void snmpSendNotification(long uptime, java.lang.String trapOid, java.lang.String[] values) throws DataException
uptime
- The sysUptime value. This is the first oid sent with the
notification. The corresponding oid need not be present
in the oidList.values
- Contains an array of string values corresponding to the
oids in the oidList.trapOid
- This should contain the oid string corresponding to the snmpTrapOID.DataException
- is thrown for invalid values.ErrorMessages
,
getErrorCode()
,
getErrorString()
public java.lang.String[] snmpSendInformRequest(long uptime, java.lang.String trapOid, java.lang.String[] values) throws DataException
uptime
- The sysUptime value. This is the first oid sent with the
notification. The corresponding oid need not be present
in the oidList.values
- Contains an array of string values corresponding to the
oids in the oidList.trapOid
- This should contain the oid string corresponding to the snmpTrapOID.DataException
- is thrown for invalid values.ErrorMessages
,
getErrorCode()
,
getErrorString()
public void snmpSendInformAcknowledgement(long uptime, SnmpOID oid, SnmpVar[] values, int reqID) throws DataException
public SnmpVarBind[] snmpSendInformRequest(long uptime, SnmpOID trapOid, SnmpVar[] values) throws DataException
uptime
- The sysUptime value. This is the first oid sent with the
notification. The corresponding oid need not be present
in the oidList.values
- Contains an array of SnmpVar values corresponding to the
oids in the oidList.trapOid
- This should contain the oid corresponding to the snmpTrapOID.DataException
- is thrown for invalid values.ErrorMessages
,
getErrorCode()
,
getErrorString()
public int addObjectID(java.lang.String s)
s
- - the string may be in any format like 1.5.0 or sysNamepublic int addSnmpOID(SnmpOID oid)
oid
- SnmpOID to be added.public java.lang.String getObjectID(int index)
index
- index in the oidlist whose value is looked up.public java.lang.String getObjectID()
public void setObjectID(java.lang.String s)
s
- the oid to be set.public void setObjectID(int index, java.lang.String s)
index
- index where the oid is to be set in the oidlists
- oid to be set.public java.lang.String[] getObjectIDList()
public void setObjectIDList(java.lang.String[] s)
s
- a String array of OIDs.public SnmpOID getSnmpOID()
public boolean getDebug()
public void setDebug(boolean debug)
debug
- true to get the debug message and false otherwise.public java.lang.String getMibModules()
public void setMibModules(java.lang.String mibs)
mibs
- white-space seperated list of mib file to be loaded.public void setSnmpOID(SnmpOID oid)
oid
- instance of SnmpOID.public SnmpOID[] getSnmpOIDList()
public void setSnmpOIDList(SnmpOID[] list)
list
- array of SnmpOIDs.public java.lang.String getTargetHost()
getTargetHost
in interface CustomizerTemplate
public void setTargetHost(java.lang.String s)
setTargetHost
in interface CustomizerTemplate
public int getTargetPort()
getTargetPort
in interface CustomizerTemplate
public void setTargetPort(int i)
setTargetPort
in interface CustomizerTemplate
public java.lang.String getContextName()
public void setContextName(java.lang.String cName)
public java.lang.String getContextID()
public void setContextID(java.lang.String ctxtID)
ctxtID
- The contextID to be set on this target.public java.lang.String getPrincipal()
public void setPrincipal(java.lang.String s)
setPrincipal
in interface CustomizerTemplate
public int getSecurityModel()
public void setSecurityModel(int securityModel)
public int getAuthProtocol()
public void setAuthProtocol(int protocol)
setAuthProtocol
in interface CustomizerTemplate
public java.lang.String getAuthPassword()
public void setAuthPassword(java.lang.String password)
setAuthPassword
in interface CustomizerTemplate
public java.lang.String getPrivPassword()
public void setPrivPassword(java.lang.String password)
setPrivPassword
in interface CustomizerTemplate
public java.lang.String getCommunity()
public void setCommunity(java.lang.String s)
public java.lang.String getWriteCommunity()
public void setWriteCommunity(java.lang.String s)
public boolean getIgnoreSpecificControlCodes()
getIgnoreSpecificControlCodes
in class SnmpServer
public void setIgnoreSpecificControlCodes(boolean specConCode)
setIgnoreSpecificControlCodes
in class SnmpServer
specConCode
- true implies that they are printed as they are
false implies that their hex value is printed.public int getTimeout()
public void setTimeout(int i)
value
- in Seconds. Default is 5Secs.public int getRetries()
public void setRetries(int i)
public int getMaxRepetitions()
public void setMaxRepetitions(int i)
public int getNonRepeaters()
public void setNonRepeaters(int i)
public int getSnmpVersion()
public void setSnmpVersion(int i)
setSnmpVersion
in interface CustomizerTemplate
public java.lang.String getErrorString()
public int getErrorCode()
public int getExceptionCode()
public int getErrorIndex()
public boolean getAttemptPartial()
public void setAttemptPartial(boolean b)
public boolean getAttemptComplete()
public void setAttemptComplete(boolean flag)
public int getVarBindCount()
public void setVarBindCount(int count)
public boolean getSendTimeoutEvents()
public void setSendTimeoutEvents(boolean b)
public void addSnmpPropertyListener(SnmpPropertyListener l)
public void removeSnmpPropertyListener(SnmpPropertyListener l)
public void addResultListener(ResultListener l)
public void removeResultListener(ResultListener l)
public void addV3HandShakeResultListener(V3HandShakeResultListener l)
V3HandShakeResultListener
- the Listener to be registered for
getting ebents.public void removeV3HandShakeListener(V3HandShakeResultListener l)
V3HandShakeResultListener
- the listener to be removed.public MibOperations getMibOperations()
protected void genTimeoutEvent(SnmpPDU pdu)
genTimeoutEvent
in class SnmpServer
protected void genEvent(SnmpPDU pdu)
genEvent
in class SnmpServer
public java.lang.String[][] snmpGetAllList()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar[][] snmpGetAllVariables()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVarBind[][] snmpGetAllVariableBindings()
ErrorMessages
,
getErrorCode()
,
getErrorString()
public java.lang.String[][] snmpGetBulkList()
data for details, i.e. use getErrorString()
to see the reason for failure.
Please see RFC 1905 if you're not familiar with getbulk.
Beyond the first set of non-repeater OIDS, i.e. OIDs that
want only a single next value, the data can be viewed as a table,
where we're getting rows upto "max repetitions" rows.
The returned data is composed of a two-dimensional array
where the first "nonRepeaters" columns have only the first
data element filled in. The remaining have the rows filled
in as expected. Typically, non-repeaters is 0, and we'd be
returning a completely filled-in 2-D array of values.
The OID List after this request is set to the last set of OIDs
in the returned bulk data, except for the initial non-repeaters
for which it is set to the first and only returned OID.
The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED,
REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED,
SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,
UNKNOWN_ERR, INVALID_NON_REP SNMP error's defined in ErrorMessages
INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
,
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVar[][] snmpGetBulkVariables()
data for details, i.e. use getErrorString()
to see the reason for failure.
Please see RFC 1905 if you're not familiar with getbulk.
Beyond the first set of non-repeater OIDS, i.e. OIDs that
want only a single next value, the data can be viewed as a table,
where we're getting rows upto "max repetitions" rows.
The returned data is composed of a two-dimensional array
where the first "nonRepeaters" columns have only the first
data element filled in. The remaining have the rows filled
in as expected. Typically, non-repeaters is 0, and we'd be
returning a completely filled-in 2-D array of values.
The OID List after this request is set to the last set of OIDs
in the returned bulk data, except for the initial non-repeaters
for which it is set to the first and only returned OID.
The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED,
REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED,
SESSION_REMOTE_HOST_UNKNOWN,SECURITYEXP_CONNECTING_REMOTE_HOST,
UNKNOWN_ERR, INVALID_NON_REP SNMP error's defined in ErrorMessages
INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
,
ErrorMessages
,
getErrorCode()
,
getErrorString()
public SnmpVarBind[][] snmpGetBulkVariableBindings()
data for details, i.e. use getErrorString()
to see the reason for failure.
Please see RFC 1905 if you're not familiar with getbulk.
Beyond the first set of non-repeater OIDS, i.e. OIDs that
want only a single next value, the data can be viewed as a table,
where we're getting rows upto "max repetitions" rows.
The returned data is composed of a two-dimensional array
where the first "nonRepeaters" columns have only the first
data element filled in. The remaining have the rows filled
in as expected. Typically, non-repeaters is 0, and we'd be
returning a completely filled-in 2-D array of values.
The OID List after this request is set to the last set of OIDs
in the returned bulk data, except for the initial non-repeaters
for which it is set to the first and only returned OID.
The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION,
OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED,
SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,
UNKNOWN_ERR, INVALID_NON_REP, SNMP error's defined in ErrorMessages.
INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
,
ErrorMessages
,
getErrorCode()
,
getErrorString()
public static boolean isInSubTree(SnmpOID rootoid, SnmpOID objid)
public java.lang.String getSecurityLevel()
public void setSecurityLevel(byte sLevel)
setSecurityLevel
in interface CustomizerTemplate
public boolean isSerialize()
isSerialize
in interface CustomizerTemplate
public void vetoableChange(java.beans.PropertyChangeEvent e)
vetoableChange
in interface java.beans.VetoableChangeListener
public void setMaxNumRows(int maxRows)
public int getMaxNumRows()
public void setParams(java.lang.String host, java.lang.String port, java.lang.String community, java.lang.String mib, java.lang.String oid)
host
- target hostport
- target portcommunity
- community namemib
- mib fileoid
- OIDpublic void setParams(java.lang.String host, java.lang.String port, java.lang.String community, java.lang.String mib, java.lang.String[] oidlist)
host
- target hostport
- target portcommunity
- community namemib
- mib fileoidlist
- a String array of OIDspublic void addLogClient(LogInterface client)
client-
- LogInterfacepublic void removeLogClient()
public SnmpResultObject getCompleteResponse()
public void addLogClient(LoggerProperties loggerProps) throws LogException
loggerProps
- - A LoggerProperties instance having the properties
of the Logger such as loggingLevel.public void releaseResources()
releaseResources
in class SnmpServer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |