| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!-- |
| 3 |
~ Copyright 2009-2013 Roland Huss |
| 4 |
~ |
| 5 |
~ Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
~ you may not use this file except in compliance with the License. |
| 7 |
~ You may obtain a copy of the License at |
| 8 |
~ |
| 9 |
~ http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
~ |
| 11 |
~ Unless required by applicable law or agreed to in writing, software |
| 12 |
~ distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
~ See the License for the specific language governing permissions and |
| 15 |
~ limitations under the License. |
| 16 |
--> |
| 17 |
|
| 18 |
<chapter id="mbeans"> |
| 19 |
<title>Jolokia MBeans</title> |
| 20 |
<para> |
| 21 |
Besides bridging JMX to the HTTP/JSON world, the Jolokia agents |
| 22 |
also install their own MBeans which provide the extra services |
| 23 |
described in this chapter. |
| 24 |
</para> |
| 25 |
<section id="mbean-config"> |
| 26 |
<title>Configuration MBean</title> |
| 27 |
<para> |
| 28 |
This MBean, which is registered under the name <emphasis |
| 29 |
role="bold">jolokia:type=Config</emphasis>, allows changing |
| 30 |
configuration parameters. Changes are non-persistent and get |
| 31 |
lost after a restart of the hosting application |
| 32 |
server. Debugging mode and the history store can be configured with |
| 33 |
this MBean. |
| 34 |
</para> |
| 35 |
<section id="mbean-debugging"> |
| 36 |
<title>Debugging</title> |
| 37 |
<para> |
| 38 |
Debugging can be switched on by setting the attribute |
| 39 |
<literal>Debug</literal>. When debugging is switched on, the |
| 40 |
Jolokia agent will store debug information in a ring buffer in |
| 41 |
memory, whose size can be tuned with the attribute |
| 42 |
<literal>MaxDebugEntries</literal>. The debug information can |
| 43 |
be fetched by the operation <literal>debugInfo</literal>. This |
| 44 |
debugging output will contain the JSON responses (which in |
| 45 |
turn contain their requests) sent to the client. Finally, the |
| 46 |
operation <literal>resetDebugInfo</literal> clears the debug |
| 47 |
history. |
| 48 |
</para> |
| 49 |
</section> |
| 50 |
<section id="mbean-history"> |
| 51 |
<title>History store</title> |
| 52 |
<para> |
| 53 |
The <emphasis>history store</emphasis> can be used to remember |
| 54 |
attribute and return values within the agent's memory. The |
| 55 |
Nagios check <command>check_jmx4perl</command>, for instance, |
| 56 |
uses this feature for its delta check, which measures |
| 57 |
changes in attribute values. In order to |
| 58 |
switch on history tracking, two operations are provided: |
| 59 |
</para> |
| 60 |
<variablelist> |
| 61 |
<varlistentry> |
| 62 |
<term><emphasis role="bold">setHistoryLimitForOperation</emphasis></term> |
| 63 |
<listitem> |
| 64 |
JMX operation for switching on tracking of the execution of |
| 65 |
JMX operations. It takes five arguments: The MBean and |
| 66 |
operation name, an optional target URL when the agent |
| 67 |
is used in proxy mode and as limit the number of maximal |
| 68 |
entries to track and a duration in seconds. |
| 69 |
If the target URL is given, then |
| 70 |
request for this specific target are tracked, |
| 71 |
otherwise, if the URL is null, requests to this |
| 72 |
operation on the local agent are tracked. The return |
| 73 |
value of calling this operations is stored in a |
| 74 |
buffer with the specified length, where the oldest |
| 75 |
elements will be shifted out in case of an overflow. |
| 76 |
</listitem> |
| 77 |
</varlistentry> |
| 78 |
<varlistentry> |
| 79 |
<term><emphasis role="bold">setHistoryLimitForAttribute</emphasis></term> |
| 80 |
<listitem> |
| 81 |
JMX operation for switching on tracking of an JMX |
| 82 |
attribute's value. It takes six arguments: The MBean and |
| 83 |
attribute name, an optional path and target URL and as |
| 84 |
limit the maximal number of entries to remember and/or an |
| 85 |
maximum duration for the elements to keep in the |
| 86 |
history. As above, the target URL is only used for proxy |
| 87 |
requests. The path can be used to store only read requests |
| 88 |
with the given path. |
| 89 |
</listitem> |
| 90 |
</varlistentry> |
| 91 |
</variablelist> |
| 92 |
<para> |
| 93 |
There are two kinds of limits which can be applied: Either by a |
| 94 |
maximum number of historical values to remember or a maximum |
| 95 |
duration for the values to keep. If both limits are given in a |
| 96 |
configuration call on the MBean above, both limits are |
| 97 |
applied. In any case, there are never more values remembered |
| 98 |
than the global limit which can be set and retrieved with |
| 99 |
attribute <constant>HistoryMaxEntries</constant>. |
| 100 |
</para> |
| 101 |
<para> |
| 102 |
The History store can be emptied with a call to the operation |
| 103 |
<methodname>resetHistoryEntries</methodname>. This also |
| 104 |
switches off all history tracking. |
| 105 |
</para> |
| 106 |
<para> |
| 107 |
If for a request history tracking is switched on, the JSON |
| 108 |
response will contain an extra field |
| 109 |
<constant>history</constant> which contains a list with |
| 110 |
historical values along with the timestamp when it was |
| 111 |
recorded. This format is described in detail in <xref |
| 112 |
linkend="history"/>. |
| 113 |
</para> |
| 114 |
</section> |
| 115 |
</section> |
| 116 |
<section id="mbean-serverhandler"> |
| 117 |
<title>Server Handler</title> |
| 118 |
<para> |
| 119 |
The MBean <emphasis |
| 120 |
role="bold">jolokia:type=ServerHandler</emphasis> has a single |
| 121 |
operation <methodname>mBeanServersInfo</methodname> with no |
| 122 |
arguments. This operation can be used to dump out the name of |
| 123 |
all registered MBeans on all found MBeanServers. It is helpful to |
| 124 |
get a quick and condensed overview of the available JMX |
| 125 |
information. |
| 126 |
</para> |
| 127 |
</section> |
| 128 |
<section id="mbean-discovery"> |
| 129 |
<title>Discovery MBean</title> |
| 130 |
<para> |
| 131 |
The MBean <emphasis role="bold">jolokia:type=Discovery</emphasis> can be used to detect other MBeans by |
| 132 |
sending multicast discovery UDP requests. Every agent which has discovery enabled will respond with information |
| 133 |
about the agent itself and the access URL. The MBean itself ha two operations: <methodname>lookupAgents</methodname> |
| 134 |
and <methodname>lookupAgentsWithTimeout</methodname> which either use a default timeout of one second for waiting |
| 135 |
for response packet or with a user provided timeout given as argument to this operation. Both methods return an |
| 136 |
JSON array which contains JSON objects, one for each agent discovered. |
| 137 |
</para> |
| 138 |
<para> |
| 139 |
A return value of these operation could look like: |
| 140 |
</para> |
| 141 |
<programlisting><![CDATA[ |
| 142 |
[ |
| 143 |
{ |
| 144 |
"agent_id" : "10.9.11.25-58613-81b087d-servlet", |
| 145 |
"url": "http://10.9.11.25:8778/jolokia", |
| 146 |
"secured": false, |
| 147 |
"server_vendor" : "Apache", |
| 148 |
"server_product" : "Tomcat", |
| 149 |
"server_version" : "7.0.35" |
| 150 |
}, |
| 151 |
{ |
| 152 |
"agent_id" : "10.9.11.87-23455-9184ef-osgi", |
| 153 |
"agent_description": "My OSGi container", |
| 154 |
"url": "http://10.9.11.87:8080/jolokia", |
| 155 |
"secured": true, |
| 156 |
"server_vendor" : "Apache", |
| 157 |
"server_product" : "Felix", |
| 158 |
"server_version" : "4.2.1" |
| 159 |
} |
| 160 |
]]]></programlisting> |
| 161 |
<table id="discovery-mbean-response"> |
| 162 |
<title>Response properties</title> |
| 163 |
<thead> |
| 164 |
<tr> |
| 165 |
<td>Property</td> |
| 166 |
<td>Description</td> |
| 167 |
<td>Example</td> |
| 168 |
</tr> |
| 169 |
</thead> |
| 170 |
<tr> |
| 171 |
<td><constant>agent_id</constant></td> |
| 172 |
<td> |
| 173 |
Each agent has a unique id which can be either provided |
| 174 |
during startup of the agent in form of a configuration |
| 175 |
parameter or being autodetected. If autodected, the id has |
| 176 |
several parts: The IP, the process id, hashcode of the agent |
| 177 |
and its type. This field will be always provided. |
| 178 |
</td> |
| 179 |
<td> |
| 180 |
10.9.11.87-23455-9184ef-osgi |
| 181 |
</td> |
| 182 |
</tr> |
| 183 |
<tr> |
| 184 |
<td><constant>agent_description</constant></td> |
| 185 |
<td> |
| 186 |
An optional description which can be used as a UI label if |
| 187 |
given. |
| 188 |
</td> |
| 189 |
<td> |
| 190 |
ServiceMix ESB |
| 191 |
</td> |
| 192 |
</tr> |
| 193 |
<tr> |
| 194 |
<td><constant>url</constant></td> |
| 195 |
<td> |
| 196 |
The URL how this agent can be contacted. This URL is |
| 197 |
typically autodetected. For the JVM agent it should be |
| 198 |
highly accurate. For the servlet based agents, it |
| 199 |
depends. If configured via an initialisation parameter this |
| 200 |
URL is used. If autodetected it is taken from the first HTTP |
| 201 |
request processed by the servlet. Hence no URL is available |
| 202 |
until this first request was processed. This property might |
| 203 |
be empty. |
| 204 |
</td> |
| 205 |
<td> |
| 206 |
http://10.9.11.87:8080/jolokia |
| 207 |
</td> |
| 208 |
</tr> |
| 209 |
<tr> |
| 210 |
<td><constant>secured</constant></td> |
| 211 |
<td> |
| 212 |
Whether the agent was configured for authentication or not. |
| 213 |
</td> |
| 214 |
<td> |
| 215 |
false |
| 216 |
</td> |
| 217 |
</tr> |
| 218 |
<tr> |
| 219 |
<td><constant>server_vendor</constant></td> |
| 220 |
<td> |
| 221 |
The vendor of the container the agent is running in. This |
| 222 |
field is included if it could be automatically detected. |
| 223 |
</td> |
| 224 |
<td> |
| 225 |
Apache |
| 226 |
</td> |
| 227 |
</tr> |
| 228 |
<tr> |
| 229 |
<td><constant>server_product</constant></td> |
| 230 |
<td> |
| 231 |
The container product if detected |
| 232 |
</td> |
| 233 |
<td> |
| 234 |
tomcat |
| 235 |
</td> |
| 236 |
</tr> |
| 237 |
<tr> |
| 238 |
<td><constant>server_version</constant></td> |
| 239 |
<td> |
| 240 |
The container's version (if detected) |
| 241 |
</td> |
| 242 |
<td> |
| 243 |
7.0.50 |
| 244 |
</td> |
| 245 |
</tr> |
| 246 |
|
| 247 |
|
| 248 |
</table> |
| 249 |
</section> |
| 250 |
</chapter> |