Package org.opennms.netmgt.config
Class CollectdConfigFactory
- java.lang.Object
-
- org.opennms.netmgt.config.CollectdConfigFactory
-
- All Implemented Interfaces:
CollectdConfigFactory
public class CollectdConfigFactory extends java.lang.Object implements CollectdConfigFactory
This is the singleton class used to load the configuration for the OpenNMS Collection Daemon from the collectd-configuration.xml file. A mapping of the configured URLs to the IP list they contain is built at init() time so as to avoid numerous file reads. 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.- Author:
- James Zuo, Mike Davidson, Sowmya Nataraj
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SELECT_METHOD_MIN
-
Constructor Summary
Constructors Constructor Description CollectdConfigFactory()
CollectdConfigFactory(java.io.InputStream stream)
For testing purposes only.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
domainExists(java.lang.String name)
Returns true if collection domain existsCollectdConfiguration
getCollectdConfig()
getCollectdConfigPackage
getPackage(java.lang.String name)
getPackageboolean
interfaceInFilter(java.lang.String iface, Package pkg)
boolean
interfaceInPackage(java.lang.String iface, Package pkg)
Deprecated.This function should take normal model objects instead of bare IP addresses.boolean
interfaceInPackage(OnmsIpInterface iface, Package pkg)
This method is used to determine if the named interface is included in the passed package definition.boolean
isServiceCollectionEnabled(java.lang.String ipAddr, java.lang.String svcName)
Deprecated.This function should take normal model objects instead of bare IP addresses and service names.boolean
isServiceCollectionEnabled(OnmsIpInterface iface, java.lang.String svcName)
Returns true if the specified interface is included by at least one package which has the specified service and that service is enabled (set to "on").boolean
isServiceCollectionEnabled(OnmsMonitoredService service)
Returns true if the specified service's interface is included by at least one package which has the specified service and that service is enabled (set to "on").boolean
packageExists(java.lang.String name)
Returns true if collection package existsvoid
reload()
Reload the config from the default config filevoid
saveCurrent()
Saves the current in-memory configuration to disk and reloads
-
-
-
Field Detail
-
SELECT_METHOD_MIN
public static final java.lang.String SELECT_METHOD_MIN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CollectdConfigFactory
public CollectdConfigFactory() throws java.io.IOException
- Throws:
java.io.IOException
-
CollectdConfigFactory
public CollectdConfigFactory(java.io.InputStream stream) throws java.io.IOException
For testing purposes only.- Parameters:
stream
-- Throws:
java.io.IOException
-
-
Method Detail
-
reload
public void reload() throws java.io.IOException
Reload the config from the default config file- Specified by:
reload
in interfaceCollectdConfigFactory
- Throws:
java.io.IOException
- Thrown if the specified config file cannot be read/loadedjava.io.IOException
- if any.
-
saveCurrent
public void saveCurrent() throws java.io.IOException
Saves the current in-memory configuration to disk and reloads- Specified by:
saveCurrent
in interfaceCollectdConfigFactory
- Throws:
java.io.IOException
- if any.
-
getCollectdConfig
public CollectdConfiguration getCollectdConfig()
getCollectdConfig
- Specified by:
getCollectdConfig
in interfaceCollectdConfigFactory
- Returns:
- a
CollectdConfiguration
object.
-
packageExists
public boolean packageExists(java.lang.String name)
Returns true if collection package exists- Specified by:
packageExists
in interfaceCollectdConfigFactory
- Parameters:
name
- The package name to check- Returns:
- True if the package exists
-
getPackage
public Package getPackage(java.lang.String name)
getPackage
- Specified by:
getPackage
in interfaceCollectdConfigFactory
- Parameters:
name
- aString
object.- Returns:
- a
Package
object.
-
domainExists
public boolean domainExists(java.lang.String name)
Returns true if collection domain exists- Specified by:
domainExists
in interfaceCollectdConfigFactory
- Parameters:
name
- The domain name to check- Returns:
- True if the domain exists
-
isServiceCollectionEnabled
public boolean isServiceCollectionEnabled(OnmsMonitoredService service)
Returns true if the specified service's interface is included by at least one package which has the specified service and that service is enabled (set to "on").- Specified by:
isServiceCollectionEnabled
in interfaceCollectdConfigFactory
- Parameters:
service
-OnmsMonitoredService
to check- Returns:
- true if Collectd config contains a package which includes the specified interface and has the specified service enabled.
-
isServiceCollectionEnabled
public boolean isServiceCollectionEnabled(OnmsIpInterface iface, java.lang.String svcName)
Returns true if the specified interface is included by at least one package which has the specified service and that service is enabled (set to "on").- Specified by:
isServiceCollectionEnabled
in interfaceCollectdConfigFactory
- Parameters:
iface
-OnmsIpInterface
to lookupsvcName
- The service name to lookup- Returns:
- true if Collectd config contains a package which includes the specified interface and has the specified service enabled.
-
isServiceCollectionEnabled
public boolean isServiceCollectionEnabled(java.lang.String ipAddr, java.lang.String svcName)
Deprecated.This function should take normal model objects instead of bare IP addresses and service names. UseisServiceCollectionEnabled(OnmsIpInterface, String)
instead.Returns true if the specified interface is included by at least one package which has the specified service and that service is enabled (set to "on").- Specified by:
isServiceCollectionEnabled
in interfaceCollectdConfigFactory
- Parameters:
ipAddr
- IP address of the interface to lookupsvcName
- The service name to lookup- Returns:
- true if Collectd config contains a package which includes the specified interface and has the specified service enabled.
-
interfaceInFilter
public boolean interfaceInFilter(java.lang.String iface, Package pkg)
- Specified by:
interfaceInFilter
in interfaceCollectdConfigFactory
-
interfaceInPackage
public boolean interfaceInPackage(java.lang.String iface, Package pkg)
Deprecated.This function should take normal model objects instead of bare IP addresses. Move this implementation intointerfaceInPackage(OnmsIpInterface, Package)
.This method is used to determine if the named interface is included in the passed package definition. If the interface belongs to the package then a value of true is returned. If the interface does not belong to the package a false value is returned. Note: Evaluation of the interface against a package filter will only work if the IP is already in the database.- Specified by:
interfaceInPackage
in interfaceCollectdConfigFactory
- Parameters:
iface
- The interface to test against the package.- Returns:
- True if the interface is included in the package, false otherwise.
-
interfaceInPackage
public boolean interfaceInPackage(OnmsIpInterface iface, Package pkg)
This method is used to determine if the named interface is included in the passed package definition. If the interface belongs to the package then a value of true is returned. If the interface does not belong to the package a false value is returned. Note: Evaluation of the interface against a package filter will only work if the IP is already in the database.- Specified by:
interfaceInPackage
in interfaceCollectdConfigFactory
- Parameters:
iface
- The interface to test against the package.- Returns:
- True if the interface is included in the package, false otherwise.
-
-