Package uk.co.westhawk.snmp.beans
Class SNMPBean
java.lang.Object
uk.co.westhawk.snmp.beans.SNMPBean
- Direct Known Subclasses:
IsHostReachableBean
,NcdPerfDataBean
,SNMPRunBean
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
action()
This method should send the SNMP request.void
Add a property change listener.Returns the local bind address.Returns the community name that is used to send the SNMP request.getHost()
Returns the host (name or ipadress) which is addressed.Returns the message (if any).int
getPort()
Returns the port no which is used.Returns the socket type.void
Remove a property change listener.void
Sets the local bind address.void
Sets the community name that is used to send the SNMP request.void
Sets the host (name or ipadress) which will be asked for the SNMP request.void
setPort
(int p) Sets the port no which is used.void
Sets the port no which is used as a String.void
Sets socket type.
-
Constructor Details
-
SNMPBean
public SNMPBean()The default constructor. -
SNMPBean
The constructor that will set the host and the port no.- Parameters:
h
- the hostnamep
- the port no- See Also:
-
SNMPBean
The constructor that will set the host, the port no and the local bind address.- Parameters:
h
- the hostnamep
- the port nob
- the local bind addresst
- the socket type- Since:
- 4_14
- See Also:
-
-
Method Details
-
action
This method should send the SNMP request. All properties should be set before this method is called.- Throws:
PduException
IOException
-
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
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
Sets the port no which is used as a String.- Parameters:
p
- The number of the port as a String- See Also:
-
getCommunityName
Returns the community name that is used to send the SNMP request.- See Also:
-
setCommunityName
Sets the community name that is used to send the SNMP request. The default is public.- See Also:
-
getBindAddress
Returns the local bind address.- Returns:
- the name of the local bind address
- Since:
- 4_14
- See Also:
-
setBindAddress
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
Returns the socket type.- Returns:
- the socket type.
- Since:
- 4_14
- See Also:
-
setSocketType
Sets socket type. The default is null. This bean will only start the request when action is called.- Since:
- 4_14
- See Also:
-
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
Add a property change listener. -
removePropertyChangeListener
Remove a property change listener.
-