Class Session


  • public class Session
    extends com.logicmonitor.common.sse.utils.SSEResource
    Snmp session, include function such as: open, walk
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Session.Builder
      A helper class to help to build the Session for snmp
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close this session
      java.lang.String get​(java.lang.String oid)
      Get oid value
      boolean isReleased()
      Whether if this session is released
      static Session open​(java.lang.String host)
      Open snmp host
      static Session open​(java.lang.String host, int timeoutMillis)
      Open snmp host
      static Session open​(java.lang.String host, java.lang.String community, java.lang.String version)
      Open snmp host
      static Session open​(java.lang.String host, java.lang.String community, java.lang.String version, int pduTimeoutInMills)
      Open snmp host
      static Session open​(java.lang.String host, java.lang.String community, java.lang.String version, int pduTimeoutInMills, int port)
      Open snmp host
      static Session openV3​(java.lang.String host, java.lang.String securityName)
      Snmp v3 support on DEFAULT_TIMEOUT
      static Session openV3​(java.lang.String host, java.lang.String securityName, int timeoutMillis)
      Snmp v3 support
      static Session openV3​(java.lang.String host, java.lang.String securityName, java.lang.String authProto, java.lang.String authPhrase)
      Snmp v3 support on DEFAULT_TIMEOUT
      static Session openV3​(java.lang.String host, java.lang.String securityName, java.lang.String authProto, java.lang.String authPhrase, int timeoutMillis)
      Snmp v3 support on DEFAULT_TIMEOUT
      static Session openV3​(java.lang.String host, java.lang.String securityName, java.lang.String authProto, java.lang.String authPhrase, java.lang.String privProto, java.lang.String privPhrase)
      Snmp v3 support on DEFAULT_TIMEOUT
      static Session openV3​(java.lang.String host, java.lang.String securityName, java.lang.String authProto, java.lang.String authPhrase, java.lang.String privProto, java.lang.String privPhrase, int pduTimeoutInMills)
      Snmp v3 support on DEFAULT_SNMP_PORT
      static Session openV3​(java.lang.String host, java.lang.String securityName, java.lang.String authProto, java.lang.String authPhrase, java.lang.String privProto, java.lang.String privPhrase, int pduTimeoutInMills, int port)
      Snmp v3 support
      static Session openV3​(java.lang.String host, java.lang.String securityName, java.lang.String authProto, java.lang.String authPhrase, java.lang.String privProto, java.lang.String privPhrase, int pduTimeoutInMills, int port, java.lang.String contextName, java.lang.String contextEngineId)  
      void release()
      Release this session
      java.lang.String toString()  
      java.util.ArrayList<java.lang.String> walk​(java.lang.String oid)
      Get oid value list use walk
      java.util.ArrayList<java.lang.String> walk​(java.lang.String oid, long walkTimeoutInMills)
      Get oid value list use walk
      java.util.Map<java.lang.String,​java.lang.String> walkAsMap​(java.lang.String oid)
      Get oid value map use walk
      java.util.Map<java.lang.String,​java.lang.String> walkAsMap​(java.lang.String oid, long walkTimeoutInMills)
      Get oid value map use walk
      • Methods inherited from class com.logicmonitor.common.sse.utils.SSEResource

        register, unregister
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isReleased

        public boolean isReleased()
        Whether if this session is released
        Specified by:
        isReleased in class com.logicmonitor.common.sse.utils.SSEResource
        Returns:
        Whether if this session is released
      • release

        public void release()
        Release this session
        Specified by:
        release in class com.logicmonitor.common.sse.utils.SSEResource
      • open

        public static Session open​(java.lang.String host)
                            throws java.io.IOException
        Open snmp host
        Parameters:
        host - The address of snmp host
        Returns:
        Session of this snmp host
        Throws:
        java.io.IOException - If some other I/O error occurs
      • open

        public static Session open​(java.lang.String host,
                                   int timeoutMillis)
                            throws java.io.IOException
        Open snmp host
        Parameters:
        host - The address of snmp host
        timeoutMillis - Timeout(millis)
        Returns:
        Session of this snmp host
        Throws:
        java.io.IOException - If some other I/O error occurs
      • open

        public static Session open​(java.lang.String host,
                                   java.lang.String community,
                                   java.lang.String version)
                            throws java.io.IOException
        Open snmp host
        Parameters:
        host - The address of snmp host
        community - Snmp community string
        version - Snmp version string
        Returns:
        Session of this snmp host
        Throws:
        java.io.IOException - If some other I/O error occurs
      • open

        public static Session open​(java.lang.String host,
                                   java.lang.String community,
                                   java.lang.String version,
                                   int pduTimeoutInMills)
                            throws java.io.IOException
        Open snmp host
        Parameters:
        host - The address of snmp host
        community - Snmp community string
        pduTimeoutInMills - PDU timeout(mills)
        Returns:
        Session of this snmp host
        Throws:
        java.io.IOException - If some other I/O error occurs
      • open

        public static Session open​(java.lang.String host,
                                   java.lang.String community,
                                   java.lang.String version,
                                   int pduTimeoutInMills,
                                   int port)
                            throws java.io.IOException
        Open snmp host
        Parameters:
        host - The address of snmp host
        community - Snmp community string
        pduTimeoutInMills - PDU timeout(mills)
        port - Snmp host port
        Returns:
        Session of this snmp host
        Throws:
        java.io.IOException - If some other I/O error occurs
      • openV3

        public static Session openV3​(java.lang.String host,
                                     java.lang.String securityName)
                              throws java.io.IOException
        Snmp v3 support on DEFAULT_TIMEOUT
        Parameters:
        host - Snmp host address
        securityName - Snmp V3 security name
        Returns:
        The session of snmp host conneceted
        Throws:
        java.io.IOException - If some other I/O error occurs
      • openV3

        public static Session openV3​(java.lang.String host,
                                     java.lang.String securityName,
                                     int timeoutMillis)
                              throws java.io.IOException
        Snmp v3 support
        Parameters:
        host - Snmp host address
        securityName - Snmp V3 security name
        timeoutMillis - The timeout of connect snmp host(millis)
        Returns:
        The session of snmp host conneceted
        Throws:
        java.io.IOException - If some other I/O error occurs
      • openV3

        public static Session openV3​(java.lang.String host,
                                     java.lang.String securityName,
                                     java.lang.String authProto,
                                     java.lang.String authPhrase)
                              throws java.io.IOException
        Snmp v3 support on DEFAULT_TIMEOUT
        Parameters:
        host - Snmp host address
        securityName - Snmp V3 security name
        authProto - Snmp V3 auth proto
        authPhrase - Snmp V3 auth phrase
        Returns:
        The session of snmp host conneceted
        Throws:
        java.io.IOException - If some other I/O error occurs
      • openV3

        public static Session openV3​(java.lang.String host,
                                     java.lang.String securityName,
                                     java.lang.String authProto,
                                     java.lang.String authPhrase,
                                     int timeoutMillis)
                              throws java.io.IOException
        Snmp v3 support on DEFAULT_TIMEOUT
        Parameters:
        host - Snmp host address
        securityName - Snmp V3 security name
        authProto - Snmp V3 auth proto
        authPhrase - Snmp V3 auth phrase
        Returns:
        The session of snmp host conneceted
        Throws:
        java.io.IOException - If some other I/O error occurs
      • openV3

        public static Session openV3​(java.lang.String host,
                                     java.lang.String securityName,
                                     java.lang.String authProto,
                                     java.lang.String authPhrase,
                                     java.lang.String privProto,
                                     java.lang.String privPhrase)
                              throws java.io.IOException
        Snmp v3 support on DEFAULT_TIMEOUT
        Parameters:
        host - Snmp host address
        securityName - Snmp V3 security name
        authProto - Snmp V3 auth proto
        authPhrase - Snmp V3 auth phrase
        privProto - Snmp V3 private proto
        privPhrase - Snmp V3 privte phrase
        Returns:
        The session of snmp host conneceted
        Throws:
        java.io.IOException - If some other I/O error occurs
      • openV3

        public static Session openV3​(java.lang.String host,
                                     java.lang.String securityName,
                                     java.lang.String authProto,
                                     java.lang.String authPhrase,
                                     java.lang.String privProto,
                                     java.lang.String privPhrase,
                                     int pduTimeoutInMills)
                              throws java.io.IOException
        Snmp v3 support on DEFAULT_SNMP_PORT
        Parameters:
        host - Snmp host address
        securityName - Snmp V3 security name
        authProto - Snmp V3 auth proto
        authPhrase - Snmp V3 auth phrase
        privProto - Snmp V3 private proto
        privPhrase - Snmp V3 privte phrase
        pduTimeoutInMills - The timeout of pdu(mills)
        Returns:
        The session of snmp host conneceted
        Throws:
        java.io.IOException - If some other I/O error occurs
      • openV3

        public static Session openV3​(java.lang.String host,
                                     java.lang.String securityName,
                                     java.lang.String authProto,
                                     java.lang.String authPhrase,
                                     java.lang.String privProto,
                                     java.lang.String privPhrase,
                                     int pduTimeoutInMills,
                                     int port)
                              throws java.io.IOException
        Snmp v3 support
        Parameters:
        host - Snmp host address
        securityName - Snmp V3 security name
        authProto - Snmp V3 auth proto
        authPhrase - Snmp V3 auth phrase
        privProto - Snmp V3 private proto
        privPhrase - Snmp V3 privte phrase
        pduTimeoutInMills - The timeout of pdu(mills)
        port - Snmp host port
        Returns:
        The session of snmp host conneceted
        Throws:
        java.io.IOException - If some other I/O error occurs
      • openV3

        public static Session openV3​(java.lang.String host,
                                     java.lang.String securityName,
                                     java.lang.String authProto,
                                     java.lang.String authPhrase,
                                     java.lang.String privProto,
                                     java.lang.String privPhrase,
                                     int pduTimeoutInMills,
                                     int port,
                                     java.lang.String contextName,
                                     java.lang.String contextEngineId)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public void close()
        Close this session
      • get

        public java.lang.String get​(java.lang.String oid)
                             throws java.io.IOException
        Get oid value
        Parameters:
        oid - Snmp oid
        Returns:
        OID value
        Throws:
        java.io.IOException - If some other I/O error occurs
      • walk

        public java.util.ArrayList<java.lang.String> walk​(java.lang.String oid)
                                                   throws java.io.IOException
        Get oid value list use walk
        Parameters:
        oid - Snmmp oid
        Returns:
        OID value list
        Throws:
        java.io.IOException - If some other I/O error occurs
      • walk

        public java.util.ArrayList<java.lang.String> walk​(java.lang.String oid,
                                                          long walkTimeoutInMills)
                                                   throws java.io.IOException
        Get oid value list use walk
        Parameters:
        oid - Snmp oid
        walkTimeoutInMills - Timeout(mills)
        Returns:
        OID value list
        Throws:
        java.io.IOException - If some other I/O error occurs
      • walkAsMap

        public java.util.Map<java.lang.String,​java.lang.String> walkAsMap​(java.lang.String oid)
                                                                         throws java.io.IOException
        Get oid value map use walk
        Parameters:
        oid - Snmp oid
        Returns:
        OID value map
        Throws:
        java.io.IOException - If some other I/O error occurs
      • walkAsMap

        public java.util.Map<java.lang.String,​java.lang.String> walkAsMap​(java.lang.String oid,
                                                                                long walkTimeoutInMills)
                                                                         throws java.io.IOException
        Get oid value map use walk
        Parameters:
        oid - Snmp oid
        walkTimeoutInMills - Timeout(mills)
        Returns:
        OID value map
        Throws:
        java.io.IOException - If some other I/O error occurs