|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.bb.dp.poller.plugins.ServiceMonitorDNS
This class is designed to be used by the service poller framework to test the availability of the DNS service on remote interfaces. The class implements the ServiceMonitor interface that allows it to be used along with other plug-ins by the service poller framework.
Field Summary | |
private static int |
DEFAULT_PORT
Default DNS port. |
private static int |
DEFAULT_RETRY
Default retries. |
private static int |
DEFAULT_TIMEOUT
Default timeout. |
private static String |
SERVICE_NAME
Name of monitored service. |
Fields inherited from interface org.opennms.bb.dp.poller.plugins.ServiceMonitor |
SERVICE_AVAILABLE, SERVICE_STATUS_MASK, SERVICE_UNAVAILABLE, SURPRESS_EVENT_MASK |
Constructor Summary | |
ServiceMonitorDNS()
|
Method Summary | |
private static long |
convertTimeToLong(String valueToConvert)
Converts the passed time string to a time value that is measured in milliseconds. |
private void |
getResponse(DNSAddressRequest request,
DatagramSocket socket)
Receives the data packet and retrieves the address from the packet. |
void |
initialize(ConfigurationProxy proxy,
Properties parameters)
Initialize the service monitor. |
void |
initialize(NetworkInterface iface)
Called by the poller framework when an interface is being added to the scheduler. |
int |
poll(NetworkInterface iface,
EventProxy eproxy,
Properties parameters)
Poll the specified address for DNS service availability. |
void |
release()
Called by the poller framework when the plug-in is being unloaded. |
void |
release(NetworkInterface iface)
Called by the poller framework when an interface is being removed from the scheduler. |
private void |
sendRequest(DNSAddressRequest request,
DatagramSocket socket,
InetAddress nameServer,
int port)
Sends a DNSAddressRequest to the name server. |
String |
serviceName()
Returns the name of the service that the plug-in monitors ("DNS"). |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static final String SERVICE_NAME
private static final int DEFAULT_PORT
private static final int DEFAULT_RETRY
private static final int DEFAULT_TIMEOUT
Constructor Detail |
public ServiceMonitorDNS()
Method Detail |
public String serviceName()
Returns the name of the service that the plug-in monitors ("DNS").
serviceName
in interface ServiceMonitor
public void initialize(ConfigurationProxy proxy, Properties parameters) throws ServiceMonitorException
Initialize the service monitor.
initialize
in interface ServiceMonitor
proxy
- The object that can be used to load/save config information.parameter
- The parameters from the appropiate package(s).ServiceMonitorException
- Thrown if
an unrecoverable error occurs that prevents the plug-in from functioning.public void release() throws ServiceMonitorException
Called by the poller framework when the plug-in is being unloaded. Any resources still being used by the monitor are released.
release
in interface ServiceMonitor
ServiceMonitorException
- Thrown if
an error occurs during deallocation.public void initialize(NetworkInterface iface) throws ServiceMonitorException
Called by the poller framework when an interface is being added to the scheduler. Here we perform any necessary initialization to prepare the NetworkInterface object for polling.
initialize
in interface ServiceMonitor
iface
- The network interface to be added to the scheduler.ServiceMonitorException
- Thrown if
an unrecoverable error occurs that prevents the interface from being monitored.public void release(NetworkInterface iface) throws ServiceMonitorException
Called by the poller framework when an interface is being removed from the scheduler. Here we free any resources or save any persistent information associated with the interface.
If an exception is thrown during the release the exception will be logged, but the interface will still be discarded for garbage collection.
release
in interface ServiceMonitor
iface
- The network interface that was being monitored.ServiceMonitorException
- Thrown if
an unrecoverable error occurs for the interface.public int poll(NetworkInterface iface, EventProxy eproxy, Properties parameters) throws ServiceMonitorException
Poll the specified address for DNS service availability.
During the poll an DNS address request query packet is generated for hostname 'localhost'. The query is sent via UDP socket to the interface at the specified port (by default UDP port 53). If a response is received, it is parsed and validated. If the DNS lookup was successful the service status is set to SERVICE_AVAILABLE and the method returns.
poll
in interface ServiceMonitor
iface
- The network interface to test the service on.eproxy
- The event proxy object for sending custom events.parameters
- The package parameters (timeout, retry, etc...) to be
used for this poll.private void sendRequest(DNSAddressRequest request, DatagramSocket socket, InetAddress nameServer, int port) throws IOException
Sends a DNSAddressRequest to the name server.
request
- The address request to send to the name server.socket
- The datagram socket the request is sent on.nameServer
- The nameserver address for the packet destination.port
- The port number to send the address.IOException
- Thrown if an error occurs while
sending the datagram packet.private void getResponse(DNSAddressRequest request, DatagramSocket socket) throws IOException
Receives the data packet and retrieves the address from the packet.
request
- the DNSAddressRequest whose response is to be gotsocket
- the socket on which the response is recievedIOException
- Thrown if response is not decoded
as expected.private static long convertTimeToLong(String valueToConvert) throws NumberFormatException
Converts the passed time string to a time value that is measured in milliseconds. The following extension are considered when converting the string:
Extension | Conversion Value |
---|---|
us | Microseconds |
ms | Milliseconds |
s | Seconds |
m | Minutes |
h | Hours |
d | Days |
A number entered with out any units is considered to be in milliseconds.
valueToConvert
- The string to convert to milliseconds.NumberFormatException
- Thrown if the string is
malformed and a number cannot be extracted from the value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |