HttpPostMonitor

If you need to HTTP POST any arbitrary content to a remote URI (for example, HTTP POST to a web API endpoint), use the HttpPostMonitor.

Monitor facts

Class Name

org.opennms.netmgt.poller.monitors.HttpPostMonitor

Configuration and use

Table 1. Monitor-specific parameters for the HttpPostMonitor
Parameter Description Default

Required

payload

The body of the POST; for example, properly escaped XML or JSON.

n/a

Optional

auth-password {}

The password to use for HTTP BASIC auth.

n/a

auth-username {}

The username to use for HTTP BASIC auth.

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

banner {}

A string that is matched against the response of the HTTP POST. If the output contains the banner, the service is determined as up. Specify a regex by starting with ~.

n/a

charset

Set the character set for the POST.

UTF-8

mimetype

Set the mimetype for the POST.

text/xml

port

The port for the web server to send the POST.

80

scheme

The connection scheme to use.

http

usesslfilter

Enables or disables the SSL certificate validation. Valid options: true or false

false

uri {}

The uri to use during the POST.

n/a

use-system-proxy

Specifies if the system-wide proxy settings be used. The system proxy settings can be configured in <<system-properties/introduction.adoc#system-properties[system properties]

false

{} indicates the parameter supports placeholder substitution.

This monitor implements the Common Configuration Parameters.

Examples

The following example creates a POST that contains the payload World.

<service name="MyServlet" interval="300000" user-defined="false" status="on">
  <parameter key="banner" value="Hello"/>
  <parameter key="port" value="8080"/>
  <parameter key="uri" value="/MyServlet">
  <parameter key="payload" value="World"/>
  <parameter key="retry" value="1"/>
  <parameter key="timeout" value="30000"/>
</service>
<monitor service="MyServlet" class-name="org.opennms.netmgt.poller.monitors.HttpPostMonitor"/>

The resulting POST looks like this:

POST /MyServlet HTTP/1.1
Content-Type: text/xml; charset=utf-8
Host: <ip_addr_of_interface>:8080
Connection: Keep-Alive

World