Debian Codegraph @

src/docbkx/agents/jvm.xml

raw
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 <section id="agents-jvm">
19 <title>JVM Agent</title>
20
21 <para>
22 The JVM agent is right agent when it comes to instrument an
23 arbitrary Java application which is not covered by the other
24 agents. This agent can be started by any Java program by
25 providing certain startup options to the JVM. Or it can be
26 dynamically attached (and detached) to an already running Java
27 process. This universal agent uses the <ulink
28 url="http://download.oracle.com/javase/6/docs/technotes/guides/jvmti/index.html">JVM
29 agent API</ulink> and is available for every Sun/Oracle JVM 1.6
30 and later.
31 </para>
32
33 <section id="jvm-agent">
34 <title>Jolokia as JVM Agent</title>
35 <para>
36 The JVM agent uses the <ulink
37 url="http://download.oracle.com/javase/6/docs/technotes/guides/jvmti/index.html">JVM
38 Agent interface</ulink> for linking into any JVM. Under the
39 hood it uses an HTTP-Server, which is available on every
40 Oracle/Sun JVM from version 1.6 upwards.
41 </para>
42 <sidebar>
43 The JDK embedded HTTP-Server is not the fastest one (it is used
44 e.g. for the JAXWS reference implementation), but for our
45 monitoring needs the performance is sufficient. There are
46 several configuration options for tuning the HTTP server's
47 performance. See below for details.
48 </sidebar>
49 <section id="jvm-agent-installation">
50 <title>Installation</title>
51 <para>
52 This agent gets installed by providing a single startup option
53 <literal>-javaagent</literal> when starting the Java process.
54 </para>
55 <programlisting language="xml"><![CDATA[
56 java -javaagent:agent.jar=port=7777,host=localhost]]></programlisting>
57 <para>
58 <filename>agent.jar</filename> is the filename of the Jolokia
59 JVM agent. The agent can be downloaded like the others from the <ulink url="https://jolokia.org/download.html">download page</ulink>.
60 When downloading from a Maven repository you need to check for the classifier <literal>agent</literal> (i.e. the
61 jar to download looks like <filename>jolokia-jvm-1.3.1-agent.jar</filename>, not <filename>jolokia-jvm-1.1.5.jar</filename>).
62 Options can be appended as a comma separated
63 list. The available options are the same as described in <xref
64 linkend="agent-war-init-params"/> plus the one described in
65 table <xref linkend="agent-jvm-config"/>. If an options
66 contains a comma, an equal sign or a backslash, it must be
67 escaped with a backslash.
68 </para>
69 <table id="agent-jvm-config">
70 <title>JVM agent configuration options</title>
71 <thead>
72 <tr>
73 <td>Parameter</td>
74 <td>Description</td>
75 <td>Example</td>
76 </tr>
77 </thead>
78 <tr>
79 <td><constant>agentContext</constant></td>
80 <td>
81 Context under which the agent is deployed. The full URL
82 will be <literal>protocol://host:port/agentContext</literal>. The default context is
83 <constant>/jolokia</constant>.
84 </td>
85 <td>
86 <constant>/j4p</constant>
87 </td>
88 </tr>
89 <tr>
90 <td><constant>agentId</constant></td>
91 <td>
92 A unique ID for this agent. By default a unique id is
93 calculated. If provided it should be ensured that this id is
94 unique among all agent reachable via multicast requests used
95 by the discovery mechanism. It is recommended not to set
96 this value. Within the <literal>agentId</literal> specification you
97 can use the same placeholders as in <literal>discoveryAgentUrl</literal>.
98 </td>
99 <td>
100 <constant>my-unique-agent-id</constant>
101 </td>
102 </tr>
103 <tr>
104 <td><constant>agentDescription</constant></td>
105 <td>
106 An optional description which can be used for clients to
107 present a human readable label for this agent.
108 </td>
109 <td>
110 <constant>Intranet Timebooking Server</constant>
111 </td>
112 </tr>
113 <tr>
114 <td><constant>host</constant></td>
115 <td>
116 Hostaddress to which the HTTP server should bind to. If "*" or "0.0.0.0" is
117 given, the servers binds to every network interface.
118 </td>
119 <td>
120 <constant>localhost</constant>
121 </td>
122 </tr>
123 <tr>
124 <td><constant>port</constant></td>
125 <td>
126 Port the HTTP server should listen to. If set to 0, then an arbitrary free port
127 will be selected.
128 </td>
129 <td>
130 <constant>8778</constant>
131 </td>
132 </tr>
133 <tr>
134 <td><constant>user</constant></td>
135 <td>
136 User to be used for authentication (along with a <constant>password</constant>)
137 </td>
138 <td>
139 </td>
140 </tr>
141 <tr>
142 <td><constant>password</constant></td>
143 <td>
144 Password used for authentication (<constant>user</constant> is then required, too)
145 </td>
146 <td>
147 </td>
148 </tr>
149 <tr>
150 <td><constant>realm</constant></td>
151 <td>
152 Sets the security realm to use. If the <constant>authMode</constant> is set to
153 <literal>jaas</literal> this is also used as value for the security domain.
154 E.g. for Karaf 3 and later, this realm should be <literal>karaf</literal> since
155 all JMX MBeans are guarded by this security domain.
156 </td>
157 <td>
158 jolokia
159 </td>
160 </tr>
161 <tr>
162 <td><constant>authMode</constant></td>
163 <td>
164 Can be either <constant>basic</constant> (the default), <constant>jaas</constant> or <constant>delegate</constant>. If
165 <constant>jaas</constant> is used, the user and password given in the <constant>Authorization:</constant>
166 header are used for login in via JAAS and, if successful, the return subject is used for all Jolokia operation.
167 This has only an effect, if user is set. For authentication mode <constant>delegate</constant>, the authentication
168 decision is delegated to a service specified by <constant>authUrl</constant> (see below for details).
169 </td>
170 <td>
171 basic
172 </td>
173 </tr>
174 <tr>
175 <td><constant>authMatch</constant></td>
176 <td>
177 If MultiAuthenticator is used, this config item explains how to combine multiple authenticators.
178 Supported values: <constant>any</constant> at least one authenticator must match, <constant>all</constant>
179 all authenticators must match.
180 </td>
181 <td>
182 any
183 </td>
184 </tr>
185 <tr>
186 <td><constant>authClass</constant></td>
187 <td>
188 Fully qualified name of an authenticator class. Class must be on classpath and must extend
189 <constant>com.sun.net.httpserver.Authenticator</constant>. Class can declare a constructor
190 that takes one argument of a type <constant>org.jolokia.config.Configuration</constant> in which case
191 Jolokia runtime configuration will be passed (useful in cases where authenticator requires additional
192 configuration). If no such constructor is found, default (no-arg) constructor will be use to create an
193 instance.
194 </td>
195 <td>
196 </td>
197 </tr>
198 <tr>
199 <td><constant>authUrl</constant></td>
200 <td>
201 URL of a service used for checking the authentication. This configuration option is only effective if
202 <constant>authMode</constant> is set to <constant>delegate</constant>. This URL can have a HTTP or HTTPS scheme.
203 The initially provided <constant>Authorization:</constant> header is copied over to the request against this
204 URL.
205 </td>
206 <td>
207 </td>
208 </tr>
209 <tr>
210 <td><constant>authPrincipalSpec</constant></td>
211 <td>
212 Expression used for extracting a principal name from the response of a delegate authentication service. This
213 parameter is only in use when the <constant>authMode</constant> is set to <constant>delegate</constant>. The
214 following expressions are supported:
215 <variablelist>
216 <varlistentry>
217 <term><literal>json:path</literal></term>
218 <listitem>
219 <para>
220 a path into a JSON response which points to the principal.
221 E.g. a principal spec <literal>jason:metadata/name</literal> will select the "name" property within the JSON
222 object specified by the "metadata" property. For navigate into arrays, numeric indexes can be used.
223 </para>
224 </listitem>
225 </varlistentry>
226 <varlistentry>
227 <term><literal>empty:</literal></term>
228 <listitem>
229 <para>
230 Always extracts an empty ("") principal.
231 </para>
232 </listitem>
233 </varlistentry>
234 </variablelist>
235 If this option is not specified, not principal is extracted.
236 </td>
237 <td>
238 </td>
239 </tr>
240 <tr>
241 <td><constant>authIgnoreCerts</constant></td>
242 <td>
243 If given, the <constant>authMode</constant> is set to <constant>delegate</constant> and the delegate URL is
244 as HTTPS-URL then the server certificate as well as the server's DNS name will not be verified. This useful
245 in order to avoid (or introduce) complex keymanagement issues, but is of course less secure. By default
246 certs a verified with the local keystore.
247 </td>
248 <td>
249 </td>
250 </tr>
251 <tr>
252 <td><constant>protocol</constant></td>
253 <td>
254 HTTP protocol to use. Should be either <literal>http</literal>
255 or <literal>https</literal>. For the SSL stack there are various
256 additional configuration options.
257 </td>
258 <td>
259 <constant>http</constant>
260 </td>
261 </tr>
262 <tr>
263 <td><constant>backlog</constant></td>
264 <td>
265 Size of request backlog before requests get discarded.
266 </td>
267 <td>
268 <constant>10</constant>
269 </td>
270 </tr>
271 <tr>
272 <td><constant>executor</constant></td>
273 <td>
274 Threading model of the HTTP server:
275 <variablelist>
276 <varlistentry>
277 <term><literal>fixed</literal></term>
278 <listitem>
279 <para>
280 Thread pool with a fixed
281 number of threads (see also
282 <constant>threadNr</constant>)
283 </para>
284 </listitem>
285 </varlistentry>
286 <varlistentry>
287 <term><literal>cached</literal></term>
288 <listitem>
289 <para>
290 Cached thread pool which
291 creates threads on demand
292 </para>
293 </listitem>
294 </varlistentry>
295 <varlistentry>
296 <term><literal>single</literal></term>
297 <listitem>
298 <para>
299 A single thread only
300 </para>
301 </listitem>
302 </varlistentry>
303 </variablelist>
304 </td>
305 <td>
306 <constant>single</constant>
307 </td>
308 </tr>
309 <tr>
310 <td><constant>threadNamePrefix</constant></td>
311 <td>
312 Thread name prefix that executor will use while creating new thread(s).
313 </td>
314 <td>
315 <constant>jolokia-</constant>
316 </td>
317 </tr>
318 <tr>
319 <td><constant>threadNr</constant></td>
320 <td>
321 Number of threads to be used when the
322 <constant>fixed</constant> execution model is chosen.
323 </td>
324 <td>
325 <constant>5</constant>
326 </td>
327 </tr>
328 <tr>
329 <td><constant>keystore</constant></td>
330 <td>
331 Path to the SSL keystore to use (https only)
332 </td>
333 <td>
334 </td>
335 </tr>
336 <tr>
337 <td><constant>keystorePassword</constant></td>
338 <td>
339 Keystore password (https only). If the password is given embedded in brackets <constant>[[...]]</constant>,
340 then it is treated as an encrypted password which was encrypted with <code>java -jar jvm-agent.jar
341 encrypt</code>. See below for details.
342 </td>
343 <td>
344 </td>
345 </tr>
346 <tr>
347 <td><constant>useSslClientAuthentication</constant></td>
348 <td>
349 Whether client certificates should be used for
350 authentication. The presented certificate is validated that it is signed by
351 a known CA which must be in the keystore (https only). (<constant>true</constant> or
352 <constant>false</constant>).
353 </td>
354 <td>
355 <constant>false</constant>
356 </td>
357 </tr>
358 <tr>
359 <td><constant>secureSocketProtocol</constant></td>
360 <td>Secure protocol that will be used for establishing HTTPS connection (https only)</td>
361 <td><constant>TLS</constant></td>
362 </tr>
363 <tr>
364 <td><constant>keyStoreType</constant></td>
365 <td>SSL keystore type to use (https only)</td>
366 <td><constant>JKS</constant></td>
367 </tr>
368 <tr>
369 <td><constant>keyManagerAlgorithm</constant></td>
370 <td>Key manager algorithm (https only)</td>
371 <td><constant>SunX509</constant></td>
372 </tr>
373 <tr>
374 <td><constant>trustManagerAlgorithm</constant></td>
375 <td>Trust manager algorithm (https only)</td>
376 <td><constant>SunX509</constant></td>
377 </tr>
378 <tr>
379 <td><constant>caCert</constant></td>
380 <td>
381 If HTTPs is to be used and no <constant>keystore</constant> is given, then <constant>caCert</constant>
382 can be used to point to a PEM encoded CA certification file. This is use to verify
383 client certificates when <constant>useSslClientAuthentication</constant> is switched on (https only)
384 </td>
385 <td></td>
386 </tr>
387 <tr>
388 <td><constant>serverCert</constant></td>
389 <td>
390 For SSL (and when no <constant>keyStore</constant> is used) then this path must point to server
391 certificate which is presented to clients (https only)
392 </td>
393 <td></td>
394 </tr>
395 <tr>
396 <td><constant>serverKey</constant></td>
397 <td>Path to the PEM encoded key file for signing the server cert during TLS handshake. This is only
398 used when no <constant>keyStore</constant> is used. For decrypting the key the password given with
399 <constant>keystorePassword</constant> is used (https only).</td>
400 <td></td>
401 </tr>
402 <tr>
403 <td><constant>serverKeyAlgorithm</constant></td>
404 <td>Encryption algorithm to use for decrypting the key given with <constant>serverKey</constant>
405 (https only)</td>
406 <td><constant>RSA</constant></td>
407 </tr>
408 <tr>
409 <td><constant>clientPrincipal</constant></td>
410 <td>
411 The principal which must be given in a client certificate to allow access to the agent. This can be one or
412 or more relative distinguished names (RDN), separated by commas. The subject of a given client certificate
413 must match on all configured RDNs. For example, when the configuration is "O=jolokia.org,OU=Dev" then a
414 client certificate's subject must contain "O=jolokia.org" and "OU=Dev" to allow the request. Multiple alternative
415 principals can be configured by using additional options with consecutive index suffix like in
416 <code>clientPrincipal.1</code>, <code>clientPrincipal.2</code>, ... Please remember that a <code>,</code>
417 separating RDNs must be escaped with a backslash (<code>\,</code>) when used on the commandline as agent arguments.
418 (https and useSslAuthentication only)
419 </td>
420 <td></td>
421 </tr>
422 <tr>
423 <td><constant>extraClientCheck</constant></td>
424 <td>
425 If switched on the agent performs an extra check for client authentication that the presented client
426 cert contains a client flag in the extended key usage section which must be present.
427 (https and useSslAuthentication only)
428 </td>
429 <td></td>
430 </tr>
431 <tr>
432 <td><constant>bootAmx</constant></td>
433 <td>
434 If set to <constant>true</constant> and if the agent is
435 attached to a Glassfish server, then during startup the
436 AMX subsystem is booted so that Glassfish specific MBeans
437 are available. Otherwise, if set to
438 <constant>false</constant> the AMX system is not booted.
439 </td>
440 <td>
441 <constant>true</constant>
442 </td>
443 </tr>
444 <tr>
445 <td><constant>config</constant></td>
446 <td>
447 Path to a properties file from where the configuration
448 options should be read. Such a property file can contain
449 the configuration options as described here as key value
450 pairs (except for the <constant>config</constant> property
451 of course :)
452 </td>
453 <td></td>
454 </tr>
455 <tr>
456 <td><constant>discoveryEnabled</constant></td>
457 <td>
458 Is set to <literal>false</literal> then this agent will
459 not listen for multicast request (multicast-group 239.192.48.84,
460 port 24884 by default, but can configured individually).
461 By default this option is enabled. This option can also be switched on with an
462 environment variable
463 <literal>JOLOKIA_DISCOVERY</literal> or the system
464 property <literal>jolokia.discoveryEnabled</literal> set to
465 <literal>true</literal>.
466 </td>
467 <td>
468 Default: <constant>true</constant>
469 </td>
470 </tr>
471 <tr>
472 <td><constant>discoveryAgentUrl</constant></td>
473 <td>
474 Sets the URL to respond for multicast discovery requests. If
475 given, <constant>discoveryEnabled</constant> is set
476 implicitly to true. This URL can also be provided by an
477 environment variable
478 <literal>JOLOKIA_DISCOVERY_AGENT_URL</literal> or the system
479 property <literal>jolokia.discoveryUrl</literal>. Within the value you can use the
480 placeholders <literal>${host}</literal> and <literal>${ip}</literal> which gets replaced
481 by the autodetected local host name/address. Also with <literal>${env:ENV_VAR}</literal> and
482 <literal>${sys:property}</literal> environment and system properties can be referenced, respectively.
483 </td>
484 <td>
485 <constant>http://10.9.11.87:8778/jolokia</constant>
486 </td>
487 </tr>
488 <tr>
489 <td><constant>multicastGroup</constant></td>
490 <td>The multicast group IPv4 address. This group IP can be also given as an environment variable <literal>JOLOKIA_MULTICAST_GROUP</literal> or a system property <literal>jolokia.multicastGroup</literal></td>
491 <td><constant>239.192.48.84</constant></td>
492 </tr>
493 <tr>
494 <td><constant>multicastPort</constant></td>
495 <td>The multicast port. This port can be also given as an environment variable <literal>JOLOKIA_MULTICAST_PORT</literal> or a system property <literal>jolokia.multicastPort</literal></td>
496 <td><constant>24884</constant></td>
497 </tr>
498 <tr>
499 <td><constant>sslProtocol</constant></td>
500 <td>
501 The list of SSL / TLS protocols enabled. Valid options are available in the documentation
502 on SunJSSEProvider for your JDK version. Using only <constant>TLSv1.1</constant> and
503 <constant>TLSv1.2</constant> is recommended in Java 1.7 and Java 1.8. Using only
504 <constant>TLSv1</constant> is recommended in Java 1.6. Multiple protocols can be configured
505 by using additional options with consecutive index suffixes like in
506 <code>sslProtocol.1</code>, <code>sslProtocol.2</code>, ...
507 </td>
508 <td><code>TLSv1.2</code></td>
509 </tr>
510 <tr>
511 <td><constant>sslCipherSuite</constant></td>
512 <td>
513 The list of SSL / TLS cipher suites to enable. The table of available cipher suites is
514 available under the "Default Enabled Cipher Suites" at the SunJSSEProvider documentation
515 <ulink url="http://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJSSEProvider">here</ulink>.
516 Multiple cipher suites can be configured by using additional options with consecutive index
517 suffixes like in <code>sslCipherSuite.1</code>, <code>sslCipherSuite.2</code>, ...
518 </td>
519 <td></td>
520 </tr>
521 <tr>
522 <td><constant>policyLocation</constant></td>
523 <td>
524 Path to the XML policy file
525 </td>
526 <td></td>
527 </tr>
528 </table>
529 <para>
530 Upon successful startup the agent will print out a success
531 message with the full URL which can be used by clients for
532 contacting the agent.
533 </para>
534 </section>
535 </section>
536 <section id="jvm-attach">
537 <title>Attaching a Jolokia agent on the fly</title>
538 <para>
539 A Jolokia agent can be attached to any running Java process as
540 long as the user has sufficient access privileges for
541 accessing the process. This agent uses the <ulink
542 url="http://download.oracle.com/javase/6/docs/jdk/api/attach/spec/com/sun/tools/attach/VirtualMachine.html">Java
543 attach API</ulink> for dynamically attaching and detaching to
544 and from the process. It works similar to JConsole connecting
545 to a local process. The Jolokia advantage is, that after the
546 start of the agent, it can be reached over the network.
547 </para>
548 <para>
549 The JAR containing the JVM agent also contains a client
550 application which can be reached via the
551 <literal>-jar</literal> option. Call it with
552 <literal>--help</literal> to get a short usage information:
553 </para>
554 <programlisting><![CDATA[
555 $ java -jar jolokia-jvm-1.3.4-agent.jar --help
556
557 Jolokia Agent Launcher
558 ======================
559
560 Usage: java -jar jolokia-jvm-1.3.4-agent.jar [options] <command> <pid/regexp>
561
562 where <command> is one of
563 start -- Start a Jolokia agent for the process specified
564 stop -- Stop a Jolokia agent for the process specified
565 status -- Show status of an (potentially) attached agent
566 toggle -- Toggle between start/stop (default when no command is given)
567 list -- List all attachable Java processes (default when no argument is given at all)
568 encrypt -- Encrypt a password which is given as argument or read from standard input
569
570 [options] are used for providing runtime information for attaching the agent:
571
572 --host <host> Hostname or IP address to which to bind on
573 (default: InetAddress.getLocalHost())
574 --port <port> Port to listen on (default: 8778)
575 --agentContext <context> HTTP Context under which the agent is reachable (default: /jolokia)
576 --agentId <agent-id> VM unique identifier used by this agent (default: autogenerated)
577 --agentDescription <desc> Agent description
578 --authMode <mode> Authentication mode: 'basic' (default), 'jaas' or 'delegate'
579 --authClass <class> Classname of an custom Authenticator which must be loadable from
580 the classpath
581 --authUrl <url> URL used for a dispatcher authentication (authMode == delegate)
582 --authPrincipalSpec <spec> Extractor specification for getting the principal
583 (authMode == delegate)
584 --authIgnoreCerts Whether to ignore CERTS when doing a dispatching authentication
585 (authMode == delegate)
586 --user <user> User used for Basic-Authentication
587 --password <password> Password used for Basic-Authentication
588 --quiet No output. "status" will exit with code 0 if the agent is running,
589 1 otherwise
590 --verbose Verbose output
591 --executor <executor> Executor policy for HTTP Threads to use (default: single)
592 "fixed" -- Thread pool with a fixed number of threads (default: 5)
593 "cached" -- Cached Thread Pool, creates threads on demand
594 "single" -- Single Thread
595 --threadNr <nr threads> Number of fixed threads if "fixed" is used as executor
596 --backlog <backlog> How many request to keep in the backlog (default: 10)
597 --protocol <http|https> Protocol which must be either "http" or "https" (default: http)
598 --keystore <keystore> Path to keystore (https only)
599 --keystorePassword <pwd> Password to the keystore (https only)
600 --useSslClientAuthentication Use client certificate authentication (https only)
601 --secureSocketProtocol <name> Secure protocol (https only, default: TLS)
602 --keyStoreType <name> Keystore type (https only, default: JKS)
603 --keyManagerAlgorithm <name> Key manager algorithm (https only, default: SunX509)
604 --trustManagerAlgorithm <name> Trust manager algorithm (https only, default: SunX509)
605 --caCert <path> Path to a PEM encoded CA cert file (https & sslClientAuth only)
606 --serverCert <path> Path to a PEM encoded server cert file (https only)
607 --serverKey <path> Path to a PEM encoded server key file (https only)
608 --serverKeyAlgorithm <algo> Algorithm to use for decrypting the server key (https only, default: RSA)
609 --clientPrincipal <principal> Allow only this principal in the client cert (https & sslClientAuth only)
610 If supplied multiple times, any one of the clientPrincipals must match
611 --extendedClientCheck <t|f> Additional validation of client certs for the proper key usage
612 (https & sslClientAuth only)
613 --discoveryEnabled <t|f> Enable/Disable discovery multicast responses (default: true)
614 --discoveryAgentUrl <url> The URL to use for answering discovery requests. Will be autodetected
615 if not given.
616 --sslProtocol <protocol> SSL / TLS protocol to enable, can be provided multiple times
617 --sslCipherSuite <suite> SSL / TLS cipher suite to enable, can be provided multiple times
618 --debug Switch on agent debugging
619 --debugMaxEntries <nr> Number of debug entries to keep in memory which can be fetched from the
620 Jolokia MBean
621 --maxDepth <depth> Maximum number of levels for serialization of beans
622 --maxCollectionSize <size> Maximum number of element in collections to keep when serializing the
623 response
624 --maxObjects <nr> Maximum number of objects to consider for serialization
625 --restrictorClass <class> Classname of an custom restrictor which must be loadable from the classpath
626 --policyLocation <url> Location of a Jolokia policy file
627 --mbeanQualifier <qualifier> Qualifier to use when registering Jolokia internal MBeans
628 --canonicalNaming <t|f> whether to use canonicalName for ObjectNames in 'list' or 'search'
629 (default: true)
630 --includeStackTrace <t|f> whether to include StackTraces for error messages (default: true)
631 --serializeException <t|f> whether to add a serialized version of the exception in the Jolokia
632 response (default: false)
633 --config <configfile> Path to a property file from where to read the configuration
634 --help This help documentation
635 --version Version of this agent (it's 1.3.4 btw :)
636
637 <pid/regexp> can be either a numeric process id or a regular expression. A regular expression is matched
638 against the processes' names (ignoring case) and must be specific enough to select exactly one process.
639
640 If no <command> is given but only a <pid> the state of the Agent will be toggled
641 between "start" and "stop"
642
643 If neither <command> nor <pid> is given, a list of Java processes along with their IDs
644 is printed
645
646 There are several possible reasons, why attaching to a process can fail:
647 * The UID of this launcher must be the very *same* as the process to attach too. It not sufficient
648 to be root.
649 * The JVM must have HotSpot enabled and be a JVM 1.6 or larger.
650 * It must be a Java process ;-)
651
652 For more documentation please visit www.jolokia.org
653 ]]></programlisting>
654 <para>
655 Every option described in <xref linkend="agent-jvm-config"/>
656 is reflected by a command line option for the
657 launcher. Additionally, the option <literal>--quiet</literal>
658 can be used to keep the launcher silent and
659 <literal>--verbose</literal> for adding some extra logging.
660 </para>
661 <para>
662 The launcher knows various operational modes, which needs to
663 be provided as a non-option argument and possibly require an
664 extra argument.
665 </para>
666 <variablelist>
667 <varlistentry>
668 <term><literal>start</literal></term>
669 <listitem>
670 <para>
671 Use this to attach an agent to an already running, local
672 Java process. The additional argument is either the
673 <emphasis>process id</emphasis> of the Java process to
674 attach to or a <emphasis>regular expression</emphasis>
675 which is matched against the Java processes names. In the
676 later case, exactly one process must match, otherwise an
677 exception is raised. The command will return with an
678 return code of 0 if an agent has been started. If the
679 agent is already running, nothing happens and the launcher
680 returns with 1. The URL of the Agent will be printed to
681 standard out on an extra line except when the
682 <literal>--quiet</literal> option is used.
683 </para>
684 </listitem>
685 </varlistentry>
686 <varlistentry>
687 <term><literal>stop</literal></term>
688 <listitem>
689 <para>
690 Command for stopping an running and dynamically attached
691 agent. The required argument is the Java process id or
692 an regular expression as described for the
693 <literal>start</literal> command. If the agent could be
694 stopped, the launcher exits with 0, it exits with 1 if
695 there was no agent running.
696 </para>
697 </listitem>
698 </varlistentry>
699 <varlistentry>
700 <term><literal>toggle</literal></term>
701 <listitem>
702 <para>
703 Starts or stops an dynamically attached agent,
704 depending on its current state. The Java process ID is
705 required as an additional argument. If an agent is
706 running, <literal>toggle</literal> will stop it (and
707 vice versa). The launcher returns with an exit code of 0
708 except when the operation fails. When the agent is
709 started, the full agent's URL is printed to standard
710 out. <literal>toggle</literal> is the default command
711 when only a numeric process id is given as argument or a
712 regular expression which <emphasis>not</emphasis> the same
713 as a known command.
714 </para>
715 </listitem>
716 </varlistentry>
717 <varlistentry>
718 <term><literal>status</literal></term>
719 <listitem>
720 <para>
721 Command for showing the current agent status for a given
722 process. The process id or a regular expression is
723 required. The launcher will return with 0 when the agent is
724 running, otherwise with 1.
725 </para>
726 </listitem>
727 </varlistentry>
728 <varlistentry>
729 <term><literal>list</literal></term>
730 <listitem>
731 <para>
732 List all local Java processes in a table with the
733 process id and the description as columns. This is the
734 default command if no non-option argument is given at
735 all. <literal>list</literal> returns with 0 upon normal
736 operation and with 1 otherwise.
737 </para>
738 </listitem>
739 </varlistentry>
740 <varlistentry>
741 <term><literal>encrypt</literal></term>
742 <listitem>
743 <para>
744 Encrypt the keystore password. You can add the password to encrypt
745 as an additional argument or, if not given, it is read from standard input.
746 The output of this command is the encrypted password in the format <code>[[....]]</code>,
747 which should be used literally (excluding the final newline) for the keystore password
748 when using the option <constant>keystorePassword</constant> in the agent configuration.
749 </para>
750 </listitem>
751 </varlistentry>
752 </variablelist>
753 <para>
754 The launcher is especially suited for
755 <emphasis>one-shot</emphasis>, <emphasis>local</emphasis>
756 queries. For example, a simple shell script for printing out
757 the memory usage of a local Java process, including
758 (temporarily) attaching an Jolokia agent looks simply like in
759 the following example. With a complete client library like <ulink
760 url="http://www.jmxp4perl.org">Jmx4Perl</ulink> even more one
761 shot scripts are possible<footnote id="rest-comment">
762 <para>And in fact, some support for launching this dynamic
763 agent is planned for a forthcoming release of jmx4perl.</para>
764 </footnote>.
765 </para>
766 <programlisting><![CDATA[
767 #!/bin/sh
768
769 url=`java -jar agent.jar start $1 | tail -1`
770
771 memory_url="${url}read/java.lang:type=Memory/HeapMemoryUsage"
772 used=`wget -q -O - "${memory_url}/used" | sed 's/^.*"value":\([0-9]*\).*$/\1/'`
773 max=`wget -q -O - "${memory_url}/max" | sed 's/^.*"value":\([0-9]*\).*$/\1/'`
774 usage=$((${used}*100/${max}))
775 echo "Memory Usage: $usage %"
776
777 java -jar agent.jar --quiet stop $1]]></programlisting>
778 </section>
779 </section>