HttpMonitor

The HTTP monitor tests the response of an HTTP server on a specific HTTP GET command. During the poll, the monitor attempts to connect on the specified port(s). The monitor can test web servers on multiple ports. By default, it makes the test against ports 80, 8080, and 8888. If the connection is successful, an HTTP GET request is sent to the interface. The response is parsed and a return code extracted and verified.

Monitor facts

Class Name

org.opennms.netmgt.poller.monitors.HttpMonitor

Configuration and use

Table 1. Optional monitor-specific parameters for the HttpMonitor
Parameter Description Default

basic-authentication {}

Authentication credentials to perform basic authentication.
Credentials should comply to RFC1945, section 11.1, without the Base64 encoding part, and be a string made of the concatenation of:
1- the user ID;
2- a colon;
3- the password.
basic-authentication takes precedence over the user and password parameters.

n/a

header[0-9]+

Additional headers to send with the request.
Example of valid parameter names are
header0, header1, and header180. `header`is not a valid parameter name.

n/a

host-name

Specify the host header value to include in the request.

n/a

nodelabel-host-name

If the host-name parameter isn’t set and the resolve-ip parameter is set to false, then Meridian uses the node’s label to set the host header value if this parameter is set to true. Otherwise, Meridian falls back using the node interface’s IP address as host header value.

false

password {}

Specifies the password to use. Use this parameter with the user parameter to perform basic authentication. The user and password parameters are ignored when the basic-authentication parameter is defined.

empty string

port

A list of TCP ports to try to connect to.

80,8080,8888

retry

Number of attempts to get a valid HTTP response/response-text.

0

resolve-ip

If the host-name parameter is not set and this parameter is set to true, Meridian uses DNS to resolve the node interface’s IP address, and uses the result to set the Host header’s value. When set to false and the host-name parameter is not set, Meridian tries to use the nodelabel-host-name parameter to set the Host header’s value.

false

response

A comma-separated list of acceptable HTTP response code ranges. Example: 200-202,299

If the url parameter is set to /, the default value for this parameter is 100-499; otherwise, it is 100-399.

response-text

Text to look for in the response body. This will be matched against every line, and it will be considered a success at the first match. If there is a ~ at the beginning of the parameter, the rest of the string is used as a regular expression pattern match; otherwise, the match will be a substring match. The regular expression match is anchored at the beginning and end of the line, so you will likely need to put a .* on both sides of your pattern unless you are going to match on the entire line.

n/a

url {}

URL to retrieve via the HTTP GET command.

/

user {}

Specifies the user ID to use. Use this parameter with the password parameter to perform basic authentication. The user and password parameters are ignored when the basic-authentication parameter is defined.

n/a

user-agent {}

Specifies the user-agent HTTP header. (Also see RFC2616, section 14.43.)

OpenNMS HttpMonitor

verbose

When set to true, full communication between client and the webserver will be logged (with a log level of DEBUG).

n/a

{} indicates the parameter supports placeholder substitution.

This monitor implements the Common Configuration Parameters.

Examples

<!-- Test HTTP service on port 80 only -->
<service name="HTTP" interval="300000" user-defined="false" status="on">
  <parameter key="retry" value="2"/>
  <parameter key="timeout" value="3000"/>
  <parameter key="port" value="80"/>
  <parameter key="url" value="/"/>
</service>

<!-- Test for virtual host opennms.com -->
<service name="OpenNMSdotCom" interval="300000" user-defined="false" status="on">
  <parameter key="retry" value="1"/>
  <parameter key="timeout" value="3000"/>
  <parameter key="port" value="80"/>
  <parameter key="host-name" value="opennms.com"/>
  <parameter key="url" value="/solutions"/>
  <parameter key="response" value="200-202,299"/>
  <parameter key="response-text" value="~.*[Cc]onsulting.*"/>
</service>

<!-- Test for instance of OpenNMS running -->
<service name="OpenNMS-129" interval="300000" user-defined="false" status="on">
  <parameter key="retry" value="1"/>
  <parameter key="timeout" value="3000"/>
  <parameter key="port" value="8080"/>
  <parameter key="url" value="/opennms/event/list"/>
  <parameter key="basic-authentication" value="admin:admin"/>
  <parameter key="response" value="200"/>
</service>

<!-- Test for instance of OpenNMS with parameter substitution in basic-authentication parameter -->
<service name="OpenNMS-22" interval="300000" user-defined="false" status="on">
  <parameter key="retry" value="1"/>
  <parameter key="timeout" value="3000"/>
  <parameter key="port" value="8080"/>
  <parameter key="url" value="/opennms/event/list"/>
  <parameter key="basic-authentication" value="{username}:{password}"/>
  <parameter key="response" value="200"/>
</service>
<monitor service="HTTP" class-name="org.opennms.netmgt.poller.monitors.HttpMonitor" />
<monitor service="OpenNMSdotCom" class-name="org.opennms.netmgt.poller.monitors.HttpMonitor" />
<monitor service="OpenNMS-129" class-name="org.opennms.netmgt.poller.monitors.HttpMonitor" />
<monitor service="OpenNMS-22" class-name="org.opennms.netmgt.poller.monitors.HttpMonitor" />

Test filtering proxies with HttpMonitor

If a filtering proxy server is set up to allow retrieval of some URLs but deny others, the HttpMonitor can verify this behavior.

As an example, a proxy server runs on TCP port 3128 and serves http://www.opennms.org/ but never http://www.tiktok.com/. To test this behavior, configure the HttpMonitor as follows:

<service name="HTTP-Allow-opennms.org" interval="300000" user-defined="false" status="on">
  <parameter key="retry" value="1"/>
  <parameter key="timeout" value="3000"/>
  <parameter key="port" value="3128"/>
  <parameter key="url" value="http://www.opennms.org/"/>
  <parameter key="response" value="200-399"/>
</service>

<service name="HTTP-Block-tiktok.com" interval="300000" user-defined="false" status="on">
  <parameter key="retry" value="1"/>
  <parameter key="timeout" value="3000"/>
  <parameter key="port" value="3128"/>
  <parameter key="url" value="http://www.tiktok.com/"/>
  <parameter key="response" value="400-599"/>
</service>

<monitor service="HTTP-Allow-opennms.org" class-name="org.opennms.netmgt.poller.monitors.HttpMonitor"/>
<monitor service="HTTP-Block-tiktok.com" class-name="org.opennms.netmgt.poller.monitors.HttpMonitor"/>