Package uk.co.westhawk.snmp.stack
Class DefaultUsmAgent
java.lang.Object
uk.co.westhawk.snmp.stack.DefaultUsmAgent
- All Implemented Interfaces:
UsmAgent
This implementation of UsmAgent tries to discover the parameters by
doing the default USM discovery process on localhost.
Note that it is not guaranteed that the agent will allow discovery by itself. Also, if the SNMP agent reboots while the stack is running, it will not pick up the new boots and time.
Users are advised and encouraged to provide a better, more accurate implementation of UsmAgent.
- Version:
- $Revision: 3.10 $ $Date: 2009/03/05 15:51:42 $
- Author:
- Birgit Arkesteijn
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default name of the local host, localhost.static final intThe default port number of the local host, 161.Fields inherited from interface uk.co.westhawk.snmp.stack.UsmAgent
MYFAKEHOSTNAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the authoritative Engine Boots.Returns the authoritative SNMP Engine ID.intReturns the authoritative Engine Time.longReturns the value of the usmStatsNotInTimeWindows counter.longReturns the value of the usmStatsUnknownEngineIDs counter.voidsetAgentName(String host) Sets my own hostname, i.e. the name of the agent or authoritative engine.voidsetAgentPort(int p) Sets my own port number, i.e. the port number of the agent or authoritative engine.voidSets the SNMP context.
-
Field Details
-
LOCAL_HOST
The default name of the local host, localhost.- See Also:
-
LOCAL_PORT
public static final int LOCAL_PORTThe default port number of the local host, 161.- See Also:
-
-
Constructor Details
-
DefaultUsmAgent
public DefaultUsmAgent()
-
-
Method Details
-
getSnmpEngineId
Returns the authoritative SNMP Engine ID. If the discovery failed, null will be returned.- Specified by:
getSnmpEngineIdin interfaceUsmAgent- Returns:
- The Engine ID
- See Also:
-
getSnmpEngineBoots
public int getSnmpEngineBoots()Returns the authoritative Engine Boots. If the discovery failed, 1 will be returned.- Specified by:
getSnmpEngineBootsin interfaceUsmAgent- Returns:
- The Engine Boots
-
getSnmpEngineTime
public int getSnmpEngineTime()Returns the authoritative Engine Time. If the discovery failed, 1 will be returned.- Specified by:
getSnmpEngineTimein interfaceUsmAgent- Returns:
- The Engine Time
-
setSnmpContext
Sets the SNMP context. It will do a discovery if needed.- Specified by:
setSnmpContextin interfaceUsmAgent
-
setAgentName
Sets my own hostname, i.e. the name of the agent or authoritative engine. By default localhost is used. Sets the hostaddress as well, using java.net.InetAddress.- Throws:
UnknownHostException- Thrown when java.net.InetAddress cannot resolve the name- See Also:
-
setAgentPort
public void setAgentPort(int p) Sets my own port number, i.e. the port number of the agent or authoritative engine. By default 161 is used.- See Also:
-
getUsmStatsUnknownEngineIDs
public long getUsmStatsUnknownEngineIDs()Description copied from interface:UsmAgentReturns the value of the usmStatsUnknownEngineIDs counter. The stack needs this when responding to a discovery request.- Specified by:
getUsmStatsUnknownEngineIDsin interfaceUsmAgent- Since:
- 4_14
-
getUsmStatsNotInTimeWindows
public long getUsmStatsNotInTimeWindows()Description copied from interface:UsmAgentReturns the value of the usmStatsNotInTimeWindows counter. The stack needs this when responding to a discovery request.- Specified by:
getUsmStatsNotInTimeWindowsin interfaceUsmAgent- Since:
- 4_14
-