Module org.snmp4j
Package org.snmp4j

Class SNMP4JSettings


  • public final class SNMP4JSettings
    extends java.lang.Object
    The SNMP4JSettings class implements a central configuration class of the SNMP4J framework. As a rule of thumb, changes to the default configuration should be made before any other classes of the SNMP4J API are instantiated or referenced by the application code.
    Since:
    1.5
    Version:
    2.2.4
    Author:
    Frank Fock
    • Field Detail

      • AGENTPP_ENTERPRISE_ID

        public static final int AGENTPP_ENTERPRISE_ID
        The enterprise ID of AGENT++ which is the root OID also for SNMP4J.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SNMP4JSettings

        public SNMP4JSettings()
    • Method Detail

      • setExtensibilityEnabled

        public static void setExtensibilityEnabled​(boolean enable)
        Enables (or disables) the extensibility feature of SNMP4J. When enabled, SNMP4J checks certain properties files that describe which transport mappings, address types, SMI syntaxes, security protocols, etc. should be supported by SNMP4J.

        By default, the extensibility feature is disabled which provides a faster startup and since no system properties are read, it ensures that SNMP4J can be used also in secure environments like applets.

        Parameters:
        enable - if true activates extensibility or if false disables it. In the latter case, SNMP4J's default configuration will be used with all available features.
        Since:
        1.2.2
      • isExtensibilityEnabled

        public static boolean isExtensibilityEnabled()
        Tests if the extensibility feature is enabled.
        Returns:
        if true the extensibility is enabled otherwise it is disabled. In the latter case, SNMP4J's default configuration will be used with all available features.
        Since:
        1.2.2
      • setForwardRuntimeExceptions

        public static void setForwardRuntimeExceptions​(boolean forwardExceptions)
        Enables or disables runtime exception forwarding.
        Parameters:
        forwardExceptions - true runtime exceptions are thrown on thread boundaries controlled by SNMP4J and related APIs. Default is false.
        Since:
        1.8.1
        See Also:
        forwardRuntimeExceptions
      • isForwardRuntimeExceptions

        public static boolean isForwardRuntimeExceptions()
        Indicates whether runtime exceptions should be thrown on thread boundaries controlled by SNMP4J and related APIs.
        Returns:
        true runtime exceptions are thrown on thread boundaries controlled by SNMP4J and related APIs. Default is false.
        Since:
        1.8.1
      • getThreadFactory

        public static ThreadFactory getThreadFactory()
        Gets the thread factory.
        Returns:
        a ThreadFactory.
        Since:
        1.9
      • setThreadFactory

        public static void setThreadFactory​(ThreadFactory newThreadFactory)
        Sets the thread factory for creating new threads of execution.
        Parameters:
        newThreadFactory - a ThreadFactory (must not be null).
        Since:
        1.9
      • getTimerFactory

        public static TimerFactory getTimerFactory()
        Gets the timer factory.
        Returns:
        a TimerFactory.
        Since:
        1.9
      • setTimerFactory

        public static void setTimerFactory​(TimerFactory newTimerFactory)
        Sets the timer factory for creating new timer instances.
        Parameters:
        newTimerFactory - a TimerFactory (must not be null).
        Since:
        1.9
      • getOIDTextFormat

        public static OIDTextFormat getOIDTextFormat()
        Gets the OID text format for textual representation of OIDs.
        Returns:
        an OIDTextFormat instance.
        Since:
        1.10
      • setOIDTextFormat

        public static void setOIDTextFormat​(OIDTextFormat newOidTextFormat)
        Sets the OID text format to be used by SNMP4J.
        Parameters:
        newOidTextFormat - the new OIDTextFormat (must not be null).
        Since:
        1.10
      • getVariableTextFormat

        public static VariableTextFormat getVariableTextFormat()
        Gets the variable text format for textual representation of variable bindings.
        Returns:
        an VariableTextFormat instance.
        Since:
        1.10
      • setVariableTextFormat

        public static void setVariableTextFormat​(VariableTextFormat newVariableTextFormat)
        Sets the variable text format to be used by SNMP4J.
        Parameters:
        newVariableTextFormat - the new VariableTextFormat (must not be null).
        Since:
        1.10
      • getThreadJoinTimeout

        public static long getThreadJoinTimeout()
        Gets the Thread join timeout used to join threads if no explicit timeout is set.
        Returns:
        the timeout millis.
        Since:
        1.10.2
      • setThreadJoinTimeout

        public static void setThreadJoinTimeout​(long millis)
        Sets the Thread join timeout used to join threads if no explicit timeout is set.
        Parameters:
        millis - the maximum time in milli-seconds to wait for a Thread to join if no explicit timeout has been set.
        Since:
        1.10.2
      • isAllowSNMPv2InV1

        public static boolean isAllowSNMPv2InV1()
      • setAllowSNMPv2InV1

        public static void setAllowSNMPv2InV1​(boolean allowSNMPv2InV1)
        Sets the compatibility flag for Counter64 usage in SNMPv1 PDUs and the ability to decode SNMPv2 traps in SNMPv1 version PDUs. The default is false. Note: By setting this to true you disable SNMP standard conformity.
        Parameters:
        allowSNMPv2InV1 - if set to true, SNMP4J will allow Counter64 objects in SNMPv1 PDUs although the SNMPv1 standard does not allow this. There are several buggy implementations which send such v1 PDUs.
        Since:
        2.2
      • isNoGetBulk

        public static boolean isNoGetBulk()
      • setNoGetBulk

        public static void setNoGetBulk​(boolean noGetBulk)
      • getEnterpriseID

        public static int getEnterpriseID()
        Gets the enterprise OID used for creating SNMP engine IDs and other enterprise specific identifiers.
        Returns:
        an enterprise ID. For example 4976 as enterprise ID (IANA number) for AGENT++ (SNMP4J). This value should be changed for other enterprises (i.e., companies or organizations).
      • setEnterpriseID

        public static void setEnterpriseID​(int enterpriseID)
        Sets the enterprise OID used for creating SNMP engine IDs and other enterprise specific identifiers.
        Parameters:
        enterpriseID - the new enterprise ID.
      • getMaxEngineIdCacheSize

        public static int getMaxEngineIdCacheSize()
        Gets the maximum number of engine IDs to be hold in the cache of the MPv3. A upper limit is necessary to avoid DoS attacks with unconfirmed SNMPv3 PDUs.
        Returns:
        the maximum number, by default 50.000 (~2MB of cached data).
        Since:
        2.3.4
      • setMaxEngineIdCacheSize

        public static void setMaxEngineIdCacheSize​(int maxEngineIdCacheSize)
        Sets the maximum number of engine IDs that can be cached by theMPv3.
        Parameters:
        maxEngineIdCacheSize - the maximum number of engine IDs in the cache, by default 50.000 (~2MB of cached data).
        Since:
        2.3.4
      • getSnmp4jStatistics

        public static SNMP4JSettings.Snmp4jStatistics getSnmp4jStatistics()
        Get the SNMP4J statistics level.
        Returns:
        the Snmp4jStatistics enum value.
        Since:
        2.4.2
      • setSnmp4jStatistics

        public static void setSnmp4jStatistics​(SNMP4JSettings.Snmp4jStatistics snmp4jStatistics)
        Sets the SNMP4J statistics level.
        Parameters:
        snmp4jStatistics - the level of statistics to be collected by SNMP4J and provided through CounterEvents.
        Since:
        2.4.2
      • isCheckUsmUserPassphraseLength

        public static boolean isCheckUsmUserPassphraseLength()
      • setCheckUsmUserPassphraseLength

        public static void setCheckUsmUserPassphraseLength​(boolean checkUsmUserPassphraseLength)