Class 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 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 interface CollectdConfigFactory
        Throws:
        java.io.IOException - Thrown if the specified config file cannot be read/loaded
        java.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 interface CollectdConfigFactory
        Throws:
        java.io.IOException - if any.
      • packageExists

        public boolean packageExists​(java.lang.String name)
        Returns true if collection package exists
        Specified by:
        packageExists in interface CollectdConfigFactory
        Parameters:
        name - The package name to check
        Returns:
        True if the package exists
      • domainExists

        public boolean domainExists​(java.lang.String name)
        Returns true if collection domain exists
        Specified by:
        domainExists in interface CollectdConfigFactory
        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 interface CollectdConfigFactory
        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 interface CollectdConfigFactory
        Parameters:
        iface - OnmsIpInterface to lookup
        svcName - 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. Use isServiceCollectionEnabled(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 interface CollectdConfigFactory
        Parameters:
        ipAddr - IP address of the interface to lookup
        svcName - The service name to lookup
        Returns:
        true if Collectd config contains a package which includes the specified interface and has the specified service enabled.
      • 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 into interfaceInPackage(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 interface CollectdConfigFactory
        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 interface CollectdConfigFactory
        Parameters:
        iface - The interface to test against the package.
        Returns:
        True if the interface is included in the package, false otherwise.