Class SNMPBean

java.lang.Object
uk.co.westhawk.snmp.beans.SNMPBean
Direct Known Subclasses:
IsHostReachableBean, NcdPerfDataBean, SNMPRunBean

public abstract class SNMPBean extends Object

This bean forms the base of the SNMP beans.

It provides the setting of the properties that are always needed when sending a SNMP request:

  • host, default is localhost
  • port, default is 161
  • community name, default is public
  • bindAddr, default is null
  • socket type, default is Standard

The bean will only come into action when the method action() is called. This should be done after the properties have been set.

This bean also provide the methods for adding and removing property change listeners and firing property change events.

Note: This bean will create a socket. This might result in a SecurityException because of the Java security policy.

  • If you are an applet: you're only connect back to its source web server
  • If you are an application or servlet: java allows you to send it. The host might refuse your connection.

The SNMP request will only succeed if:

  • java security policy allows the opening of the socket
  • the host/port combination is reachable from your location (you can check that with the ping (command line) command.
  • the combination of OID and community name is correct
Version:
$Revision: 1.12 $ $Date: 2006/01/26 12:38:30 $
Author:
Birgit Arkesteijn
See Also:
  • Constructor Details

  • Method Details

    • action

      public abstract void action() throws PduException, IOException
      This method should send the SNMP request. All properties should be set before this method is called.
      Throws:
      PduException
      IOException
    • getHost

      public String getHost()
      Returns the host (name or ipadress) which is addressed. This is the host where the SNMP server is running.
      Returns:
      the name of the host
      See Also:
    • setHost

      public void setHost(String h)
      Sets the host (name or ipadress) which will be asked for the SNMP request. This is the host where the SNMP server is running. The default is localhost. This bean will only start the request when action is called.
      See Also:
    • getPort

      public int getPort()
      Returns the port no which is used. That is the no of the port on the host where the SNMP server is running.
      See Also:
    • setPort

      public void setPort(int p)
      Sets the port no which is used. That should be the no of the port on the host where the SNMP server is running. The default is 161. This bean will only start the request when action is called.
      Parameters:
      p - The number of the port
      See Also:
    • setPort

      public void setPort(String p)
      Sets the port no which is used as a String.
      Parameters:
      p - The number of the port as a String
      See Also:
    • getCommunityName

      public String getCommunityName()
      Returns the community name that is used to send the SNMP request.
      See Also:
    • setCommunityName

      public void setCommunityName(String c)
      Sets the community name that is used to send the SNMP request. The default is public.
      See Also:
    • getBindAddress

      public String getBindAddress()
      Returns the local bind address.
      Returns:
      the name of the local bind address
      Since:
      4_14
      See Also:
    • setBindAddress

      public void setBindAddress(String b)
      Sets the local bind address. The default is null. This bean will only start the request when action is called.
      Since:
      4_14
      See Also:
    • getSocketType

      public String getSocketType()
      Returns the socket type.
      Returns:
      the socket type.
      Since:
      4_14
      See Also:
    • setSocketType

      public void setSocketType(String t)
      Sets socket type. The default is null. This bean will only start the request when action is called.
      Since:
      4_14
      See Also:
    • getMessage

      public String getMessage()
      Returns the message (if any). The message is used to give the user feedback if anything is happened with the request or the connection.
      Returns:
      the message
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
      Add a property change listener.
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener l)
      Remove a property change listener.
      See Also: