
= JolokiaBeanMonitor
:description: Learn about the JolokiaBeanMonitor in OpenNMS {page-component-title} that lets you run a method or poll an attribute via JMX using the Jolokia framework.

The JolokiaBeanMonitor is a JMX monitor specialized for the use with the link:http://www.jolokia.org[Jolokia framework].
Use the JolokiaBeanMonitor when you need to run a method via JMX or poll an attribute via JMX.
This monitor requires a fully installed and configured Jolokia agent deployed in the JVM container.
If required, you can provide attribute names, paths, and method parameters as additional arguments to the call.

To determine the status of the service, the JolokiaBeanMonitor relies on the output to be matched against a banner.
If the banner is part of the output, the status is interpreted as up; otherwise, it is considered down.
Banner matching supports regular expression and substring match.

== Monitor facts

[cols="1,7"]
|===
| Class Name
| `org.opennms.netmgt.poller.monitors.JolokiaBeanMonitor`
|===

== Configuration and use

.Monitor-specific parameters for the JolokiaBeanMonitor
[options="header"]
[cols="1,3,2"]
|===
| Parameter
| Description
| Default value

3+|*Required*

| beanname
| The bean name to query against.
| n/a

3+|*Optional*

| attrname
| The name of the JMX attribute to scrape.
| n/a

| attrpath
| The attribute path.
| n/a

| auth-username kbd:[{}]
| The username to use for HTTP BASIC auth.
| n/a

| auth-password kbd:[{}]
| The password to use for HTTP BASIC auth.
| n/a

| banner kbd:[{}]
| A string that is matched against the output of the system-call. If the output contains the banner, the service is determined as up. Start with `~` to specify a regex.
| n/a

| input1 kbd:[{}]
| Method input
| n/a

| input2 kbd:[{}]
| Method input
| n/a

| methodname kbd:[{}]
| The name of the bean method to execute.
Output will be compared to banner.
| n/a

| port
| The port of the Jolokia agent.
| 8080

| url kbd:[{}]
| The Jolokia agent URL.
| http://<ipaddr>:<port>/jolokia
|===

kbd:[{}] _indicates the parameter supports <<reference:service-assurance/introduction.adoc#ref-service-assurance-monitors-placeholder-substitution-parameters, placeholder substitution>>._

NOTE: The attrname and methodname parameters are optional but one of them must be set.

This monitor implements the <<reference:service-assurance/introduction.adoc#ref-service-assurance-monitors-common-parameters, Common Configuration Parameters>>.

.Variables that can be used in the configuration
[options="header"]
[cols="1,3"]
|===
| Variable
| Description

| $\{ipaddr}
| IP-address of the interface the service is bound to.

| $\{port}
| Port the service it bound to.
|===

== Examples

Some example configuration on how to configure the monitor in `poller-configuration.xml`.
[source, xml]
----
<parameter key="url" value="http://$\{ipaddr}:$\{port}/jolokia"/>
<parameter key="url" value="https://$\{ipaddr}:$\{port}/jolokia"/>
----

== AttrName versus MethodName

The JolokiaBeanMonitor has two modes of operation.
It can either scrape an attribute from a bean or run a method and compare output to a banner.
The method run is useful when your application has its own test methods that you would like to trigger via {page-component-title}.

Arguments to run a test method called "superTest" that take in a string as input:
[source, xml]
----
<parameter key="beanname" value="MyBean" />
<parameter key="methodname" value="superTest" />
<parameter key="input1" value="someString"/>
----

Arguments to scrape an attribute from the same bean:
[source, xml]
----
<parameter key="beanname" value="MyBean" />
<parameter key="attrname" value="upTime" />
----
