public class SnmpPeerFactory extends Object implements SnmpAgentConfigFactory
SnmpAgentConfig
objects for specific
addresses. If an address cannot be located in the configuration then a
default peer instance is returned to the caller.
Note: Users of this class should make sure the
init() is called before calling any other method to ensure the
config is loaded before accessing other convenience methods.Constructor and Description |
---|
SnmpPeerFactory(org.springframework.core.io.Resource resource)
Constructor for SnmpPeerFactory.
|
Modifier and Type | Method and Description |
---|---|
void |
define(SnmpEventInfo info)
Enhancement: Allows specific or ranges to be merged into SNMP configuration
with many other attributes.
|
SnmpAgentConfig |
getAgentConfig(InetAddress agentAddress) |
SnmpAgentConfig |
getAgentConfig(InetAddress agentInetAddress,
int requestedSnmpVersion) |
SnmpAgentConfig |
getAgentConfig(InetAddress agentAddress,
String location)
getAgentConfig
|
SnmpAgentConfig |
getAgentConfig(InetAddress agentInetAddress,
String location,
int requestedSnmpVersion) |
SnmpAgentConfig |
getAgentConfigFromProfile(SnmpProfile snmpProfile,
InetAddress address)
getAgentConfig for a given profile
|
static File |
getFile() |
static SnmpPeerFactory |
getInstance()
Load the config from the default config file and create the singleton instance of this factory.
|
List<SnmpProfile> |
getProfiles()
Get all the SNMP profiles from SNMP Config.
|
protected Lock |
getReadLock() |
SnmpConfig |
getSnmpConfig()
getSnmpConfig
|
String |
getSnmpConfigAsString()
Creates a string containing the XML of the current SnmpConfig
|
int |
getVersionCode(Definition def,
SnmpConfig config,
int requestedSnmpVersion) |
protected Lock |
getWriteLock() |
static void |
init() |
boolean |
removeFromDefinition(InetAddress inetAddress,
String location,
String module)
Remove an address from the definitions.
|
void |
saveAgentConfigAsDefinition(SnmpAgentConfig snmpAgentConfig,
String location,
String module)
Create definition and merge this definition into Current SNMP Config.
|
void |
saveCurrent()
Saves the current settings to disk
|
void |
saveDefinition(Definition definition)
Merge this definition into current config.
|
void |
saveToFile(File file) |
static void |
setFile(File configFile)
setFile
|
static void |
setInstance(SnmpPeerFactory singleton)
setInstance
|
public SnmpPeerFactory(org.springframework.core.io.Resource resource)
Constructor for SnmpPeerFactory.
resource
- a Resource
object.protected Lock getReadLock()
protected Lock getWriteLock()
public static void init() throws IOException
IOException
public static SnmpPeerFactory getInstance()
IOException
- Thrown if the specified config file cannot be readpublic static void setInstance(SnmpPeerFactory singleton)
setInstance
singleton
- a SnmpPeerFactory
object.public static File getFile() throws IOException
IOException
public void saveCurrent() throws IOException
IOException
- if any.public void saveToFile(File file) throws UnsupportedEncodingException, FileNotFoundException, IOException
public SnmpAgentConfig getAgentConfig(InetAddress agentAddress)
public SnmpAgentConfig getAgentConfig(InetAddress agentAddress, String location)
SnmpAgentConfigFactory
getAgentConfig
getAgentConfig
in interface SnmpAgentConfigFactory
agentAddress
- a InetAddress
object.location
- a String
object.SnmpAgentConfig
object.public SnmpAgentConfig getAgentConfigFromProfile(SnmpProfile snmpProfile, InetAddress address)
SnmpAgentConfigFactory
getAgentConfig for a given profile
getAgentConfigFromProfile
in interface SnmpAgentConfigFactory
snmpProfile
- a @Definition
object.address
- a InetAddress
object.SnmpAgentConfig
object.public SnmpAgentConfig getAgentConfig(InetAddress agentInetAddress, int requestedSnmpVersion)
public SnmpAgentConfig getAgentConfig(InetAddress agentInetAddress, String location, int requestedSnmpVersion)
public int getVersionCode(Definition def, SnmpConfig config, int requestedSnmpVersion)
public SnmpConfig getSnmpConfig()
getSnmpConfig
SnmpConfig
object.public void define(SnmpEventInfo info)
info
- a SnmpEventInfo
object.public void saveDefinition(Definition definition)
SnmpAgentConfigFactory
saveDefinition
in interface SnmpAgentConfigFactory
definition
- Definition that has SNMP parameters associated with a specific IP address or Range.public boolean removeFromDefinition(InetAddress inetAddress, String location, String module)
SnmpAgentConfigFactory
removeFromDefinition
in interface SnmpAgentConfigFactory
inetAddress
- IP address that needs to be removed from definition.location
- location at which this ipaddress belongs.module
- module from which the definition is getting removed.public void saveAgentConfigAsDefinition(SnmpAgentConfig snmpAgentConfig, String location, String module)
SnmpAgentConfigFactory
saveAgentConfigAsDefinition
in interface SnmpAgentConfigFactory
snmpAgentConfig
- agentConfig that might have succeeded in SNMP walk/get.location
- the location that this agent config belongs.module
- module from which the definition is getting saved.public List<SnmpProfile> getProfiles()
SnmpAgentConfigFactory
getProfiles
in interface SnmpAgentConfigFactory
public String getSnmpConfigAsString()
Copyright © 2021. All rights reserved.