Class SNMP


  • public class SNMP
    extends java.lang.Object
    This class offers the functionality of the Simple Network Management. Typically SNMP is used, when there are a number of systems to be managed, and one or more systems managing them. The managed system that report information via SNMP to the managing systems.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int retries
      A parameter determining the number of retries to be made.
      static java.lang.String SNMP_COMMUNITY
      SNMP community string.
      static java.lang.String SNMP_ENTERPRISE
      The default value for the manage object's type.
      static int timeout
      A timeout parameter.
    • Constructor Summary

      Constructors 
      Constructor Description
      SNMP()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.tivoli.snmp.data.BadValue createBadValue()
      Creates a SNMP BadValue object.
      static com.tivoli.snmp.data.Boolean createBoolean​(boolean value)
      Creates a SNMP Boolean object.
      static com.tivoli.snmp.data.Counter createCounter​(long value)
      Creates a SNMP Counter object.
      static com.tivoli.snmp.data.Counter64 createCounter64​(long value)
      Creates a 64-bit SNMP Counter object.
      static com.tivoli.snmp.data.FixedLengthOctetString createFixedLengthOctetString​(java.lang.String value)
      Creates a SNMP OctetString object with fixed length.
      static com.tivoli.snmp.data.FullCounter64 createFullCounter64​(java.math.BigInteger value)
      Creates a SNMP FullCounter64 object.
      static com.tivoli.snmp.data.Gauge createGauge​(long value)
      Creates a SNMP Gauge object.
      static com.tivoli.snmp.data.IPAddress createIPAddress​(java.lang.String value)
      Creates a SNMP IPAddress object.
      static com.tivoli.snmp.data.NoChange createNoChange()
      Creates a SNMP NoChange object.
      static com.tivoli.snmp.data.NoSuchInstance createNoSuchInstance()
      Creates a SNMP NoSuchInstance object.
      static com.tivoli.snmp.data.NoSuchObject createNoSuchObject()
      Creates a SNMP NoSuchObject object.
      static com.tivoli.snmp.data.NotSupported createNotSupported()
      Creates a SNMP NotSupported object.
      static com.tivoli.snmp.data.Null createNull()
      Creates a SNMP Null object.
      static com.tivoli.snmp.data.OctetString createOctetString​(java.lang.String value)
      Creates a SNMP OctetString object.
      static com.tivoli.snmp.data.OID createOID​(java.lang.String value)
      Creates a SNMP OID (object identifier) object.
      static com.tivoli.snmp.data.Opaque createOpaque​(byte[] value)
      Creates a SNMP Opaque object.
      static com.tivoli.snmp.data.TimeTicks createTimeTicks​(long value)
      Creates a SNMP TimeTicks object.
      static void sendTrap​(java.lang.String host, int port, java.lang.String oid, java.lang.Object value)
      Sends an unsolicited SNMP TRAP message for an occurred event.
      static void sendTrap​(java.lang.String host, int port, java.lang.String community, java.lang.String enterprise, int genericTrap, int specificTrap, java.lang.String oid, java.lang.Object value)
      Sends an unsolicited SNMP TRAP message for an occurred event.
      static void sendTrap​(java.lang.String agentIP, java.lang.String host, int port, java.lang.String community, java.lang.String enterprise, int genericTrap, int specificTrap, java.lang.String oid, java.lang.Object value)
      Sends an unsolicited SNMP TRAP message for an occurred event.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SNMP_ENTERPRISE

        public static final java.lang.String SNMP_ENTERPRISE
        The default value for the manage object's type.
        See Also:
        Constant Field Values
      • SNMP_COMMUNITY

        public static final java.lang.String SNMP_COMMUNITY
        SNMP community string.
        See Also:
        Constant Field Values
      • timeout

        public static int timeout
        A timeout parameter.
      • retries

        public static int retries
        A parameter determining the number of retries to be made.
    • Constructor Detail

      • SNMP

        public SNMP()
    • Method Detail

      • sendTrap

        public static void sendTrap​(java.lang.String host,
                                    int port,
                                    java.lang.String oid,
                                    java.lang.Object value)
                             throws java.lang.Exception
        Sends an unsolicited SNMP TRAP message for an occurred event. Uses the local host address as agent IP and default values for community string, managed object's type, generic and specific trap types.
        Parameters:
        host - the host where the management system is.
        port - the TCP port to connect to.
        oid - the object identifier. If oid is null, value must be an Entry where the Attribute names will be used as OIDs.
        value - the value(s).
        Throws:
        java.lang.Exception - if a problem occurs.
      • sendTrap

        public static void sendTrap​(java.lang.String host,
                                    int port,
                                    java.lang.String community,
                                    java.lang.String enterprise,
                                    int genericTrap,
                                    int specificTrap,
                                    java.lang.String oid,
                                    java.lang.Object value)
                             throws java.lang.Exception
        Sends an unsolicited SNMP TRAP message for an occurred event. Uses the local host address as agent IP.
        Parameters:
        host - the host where the management system is.
        port - the TCP port to connect to.
        community - the SNMP community string.
        enterprise - the type of managed object that generates the trap.
        genericTrap - indicates one of a number of generic trap types (coldStart, warmStart, linkUp, linkDown, ...).
        specificTrap - indicates one of a number of enterprise specific trap codes.
        oid - the object identifier. If oid is null, value must be an Entry where the Attribute names will be used as OIDs.
        value - the value(s).
        Throws:
        java.lang.Exception - if a problem occurs.
      • sendTrap

        public static void sendTrap​(java.lang.String agentIP,
                                    java.lang.String host,
                                    int port,
                                    java.lang.String community,
                                    java.lang.String enterprise,
                                    int genericTrap,
                                    int specificTrap,
                                    java.lang.String oid,
                                    java.lang.Object value)
                             throws java.lang.Exception
        Sends an unsolicited SNMP TRAP message for an occurred event. It is initialized by the network element and sent to its management system. This way the management system does not have to check all the time the state of each agent's objects. Thus the effectiveness is significantly improved.
        Parameters:
        agentIP - the IP of the agent sending the message.
        host - the host where the management system is.
        port - the TCP port to connect to.
        community - the SNMP community string.
        enterprise - the type of managed object that generates the trap.
        genericTrap - indicates one of a number of generic trap types (coldStart, warmStart, linkUp, linkDown, ...).
        specificTrap - indicates one of a number of enterprise specific trap codes.
        oid - the object identifier. If oid is null, value must be an Entry where the Attribute names will be used as OIDs.
        value - the value(s).
        Throws:
        java.lang.Exception - if a problem occurs.
      • createBadValue

        public static com.tivoli.snmp.data.BadValue createBadValue()
        Creates a SNMP BadValue object.
        Returns:
        the created object.
      • createBoolean

        public static com.tivoli.snmp.data.Boolean createBoolean​(boolean value)
        Creates a SNMP Boolean object.
        Parameters:
        value - the boolean parameter to be converted.
        Returns:
        the created object.
      • createCounter

        public static com.tivoli.snmp.data.Counter createCounter​(long value)
        Creates a SNMP Counter object.
        Parameters:
        value - the long parameter to be converted.
        Returns:
        the created object.
      • createCounter64

        public static com.tivoli.snmp.data.Counter64 createCounter64​(long value)
        Creates a 64-bit SNMP Counter object.
        Parameters:
        value - the long parameter to be converted.
        Returns:
        the created object.
      • createFixedLengthOctetString

        public static com.tivoli.snmp.data.FixedLengthOctetString createFixedLengthOctetString​(java.lang.String value)
        Creates a SNMP OctetString object with fixed length.
        Parameters:
        value - the String parameter to be converted.
        Returns:
        the created object.
      • createFullCounter64

        public static com.tivoli.snmp.data.FullCounter64 createFullCounter64​(java.math.BigInteger value)
        Creates a SNMP FullCounter64 object.
        Parameters:
        value - the BigInteger parameter to be converted.
        Returns:
        the created object.
      • createGauge

        public static com.tivoli.snmp.data.Gauge createGauge​(long value)
        Creates a SNMP Gauge object.
        Parameters:
        value - the long parameter to be converted.
        Returns:
        the created object.
      • createIPAddress

        public static com.tivoli.snmp.data.IPAddress createIPAddress​(java.lang.String value)
        Creates a SNMP IPAddress object.
        Parameters:
        value - the String parameter to be converted.
        Returns:
        the created object.
      • createNoChange

        public static com.tivoli.snmp.data.NoChange createNoChange()
        Creates a SNMP NoChange object.
        Returns:
        the created object.
      • createNoSuchInstance

        public static com.tivoli.snmp.data.NoSuchInstance createNoSuchInstance()
        Creates a SNMP NoSuchInstance object.
        Returns:
        the created object.
      • createNoSuchObject

        public static com.tivoli.snmp.data.NoSuchObject createNoSuchObject()
        Creates a SNMP NoSuchObject object.
        Returns:
        the created object.
      • createNotSupported

        public static com.tivoli.snmp.data.NotSupported createNotSupported()
        Creates a SNMP NotSupported object.
        Returns:
        the created object.
      • createNull

        public static com.tivoli.snmp.data.Null createNull()
        Creates a SNMP Null object.
        Returns:
        the created object.
      • createOctetString

        public static com.tivoli.snmp.data.OctetString createOctetString​(java.lang.String value)
        Creates a SNMP OctetString object.
        Parameters:
        value - the String parameter to be converted.
        Returns:
        the created object.
      • createOID

        public static com.tivoli.snmp.data.OID createOID​(java.lang.String value)
        Creates a SNMP OID (object identifier) object.
        Parameters:
        value - the String parameter to be converted.
        Returns:
        the created object.
      • createOpaque

        public static com.tivoli.snmp.data.Opaque createOpaque​(byte[] value)
        Creates a SNMP Opaque object.
        Parameters:
        value - the byte array parameter to be converted.
        Returns:
        the created object.
      • createTimeTicks

        public static com.tivoli.snmp.data.TimeTicks createTimeTicks​(long value)
        Creates a SNMP TimeTicks object.
        Parameters:
        value - the long parameter to be converted.
        Returns:
        the created object.