Package org.opennms.netmgt.config
Class CollectdConfigFactory
- java.lang.Object
-
- org.opennms.netmgt.config.CollectdConfigFactory
-
- All Implemented Interfaces:
CollectdConfigFactory
public class CollectdConfigFactory extends 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 StringSELECT_METHOD_MIN
-
Constructor Summary
Constructors Constructor Description CollectdConfigFactory()CollectdConfigFactory(InputStream stream)For testing purposes only.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleandomainExists(String name)Returns true if collection domain existsCollectdConfigurationgetCollectdConfig()getCollectdConfigPackagegetPackage(String name)getPackagebooleaninterfaceInFilter(String iface, Package pkg)booleaninterfaceInPackage(String iface, Package pkg)Deprecated.This function should take normal model objects instead of bare IP addresses.booleaninterfaceInPackage(OnmsIpInterface iface, Package pkg)This method is used to determine if the named interface is included in the passed package definition.booleanisServiceCollectionEnabled(String ipAddr, String svcName)Deprecated.This function should take normal model objects instead of bare IP addresses and service names.booleanisServiceCollectionEnabled(OnmsIpInterface iface, 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").booleanisServiceCollectionEnabled(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").booleanpackageExists(String name)Returns true if collection package existsvoidreload()Reload the config from the default config filevoidsaveCurrent()Saves the current in-memory configuration to disk and reloads
-
-
-
Field Detail
-
SELECT_METHOD_MIN
public static final String SELECT_METHOD_MIN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CollectdConfigFactory
public CollectdConfigFactory() throws IOException- Throws:
IOException
-
CollectdConfigFactory
public CollectdConfigFactory(InputStream stream) throws IOException
For testing purposes only.- Parameters:
stream-- Throws:
IOException
-
-
Method Detail
-
reload
public void reload() throws IOExceptionReload the config from the default config file- Specified by:
reloadin interfaceCollectdConfigFactory- Throws:
IOException- Thrown if the specified config file cannot be read/loadedIOException- if any.
-
saveCurrent
public void saveCurrent() throws IOExceptionSaves the current in-memory configuration to disk and reloads- Specified by:
saveCurrentin interfaceCollectdConfigFactory- Throws:
IOException- if any.
-
getCollectdConfig
public CollectdConfiguration getCollectdConfig()
getCollectdConfig
- Specified by:
getCollectdConfigin interfaceCollectdConfigFactory- Returns:
- a
CollectdConfigurationobject.
-
packageExists
public boolean packageExists(String name)
Returns true if collection package exists- Specified by:
packageExistsin interfaceCollectdConfigFactory- Parameters:
name- The package name to check- Returns:
- True if the package exists
-
getPackage
public Package getPackage(String name)
getPackage
- Specified by:
getPackagein interfaceCollectdConfigFactory- Parameters:
name- aStringobject.- Returns:
- a
Packageobject.
-
domainExists
public boolean domainExists(String name)
Returns true if collection domain exists- Specified by:
domainExistsin 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:
isServiceCollectionEnabledin interfaceCollectdConfigFactory- Parameters:
service-OnmsMonitoredServiceto 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, 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:
isServiceCollectionEnabledin interfaceCollectdConfigFactory- Parameters:
iface-OnmsIpInterfaceto 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(String ipAddr, 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:
isServiceCollectionEnabledin 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(String iface, Package pkg)
- Specified by:
interfaceInFilterin interfaceCollectdConfigFactory
-
interfaceInPackage
public boolean interfaceInPackage(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:
interfaceInPackagein 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:
interfaceInPackagein interfaceCollectdConfigFactory- Parameters:
iface- The interface to test against the package.- Returns:
- True if the interface is included in the package, false otherwise.
-
-