Skip to content

Commit 89de284

Browse files
committed
Improve README
1 parent 83ec212 commit 89de284

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

README.md

+47-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This plugin for the [Cloud Foundry Command Line](https://github.com/cloudfoundry
77
Currently, it allows to:
88
* Trigger and retrieve a heap dump and a thread dump from an instance of a Cloud Foundry Java application
99
* To run jcmd remotely on your application
10-
* To start, stop and retrieve JFR and async-profiler profiles from your application
10+
* To start, stop and retrieve JFR and [async-profiler](https://github.com/jvm-profiling-tools/async-profiler) ([SapMachine](https://sapmachine.io) only) profiles from your application
1111

1212
## Installation
1313

@@ -84,7 +84,12 @@ applications:
8484
buildpack: https://github.com/cloudfoundry/java-buildpack
8585
env:
8686
JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { repository_root: "https://java-buildpack.cloudfoundry.org/openjdk-jdk/bionic/x86_64", version: 11.+ } }'
87+
JAVA_OPTS: '+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints'
8788
```
89+
90+
`JAVA_OPTS: '+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints'` is used to improve
91+
profiling accurary and has no known negative performance impacts.
92+
8893
Please note that this requires the use of an online buildpack (configured in the `buildpack` property). When system buildpacks are used, staging will fail with cache issues, because the system buildpacks don’t have the JDK chached.
8994
Please also note that this is not to be considered a recommendation to use a full JDK. It's just one option to get the tools required for the use of this plugin when you need it, e.g., for troubleshooting.
9095
The `version` property is optional and can be used to request a specific Java version.
@@ -102,7 +107,48 @@ If `cf java` is having issues connecting to your app, chances are the problem is
102107
To verify, run your `cf java` command in "dry-run" mode by adding the `-n` flag and try to execute the command line that `cf java` gives you back.
103108
If it fails, the issue is not in `cf java`, but in whatever makes `cf ssh` fail.
104109

110+
### Examples
111+
112+
Getting a heap-dump:
113+
114+
```sh
115+
> cf java heap-dump $APP_NAME
116+
-> ./$APP_NAME-heapdump-$RANDOM.hprof
117+
```
118+
119+
Getting a thread-dump:
120+
121+
```sh
122+
> cf java thread-dump $APP_NAME
123+
...
124+
Full thread dump OpenJDK 64-Bit Server VM ...
125+
...
126+
```
127+
128+
Creating a CPU-time profile via async-profiler:
129+
130+
```sh
131+
> cf java asprof-start-cpu $APP_NAME
132+
Profiling started
133+
# wait some time to gather data
134+
> cf java asprof-stop-cpu $APP_NAME
135+
-> ./$APP_NAME-asprof-$RANDOM.jfr
136+
```
137+
138+
Running arbitrary JCMD commands, like `VM.uptime`:
139+
140+
```sh
141+
> cf java jcmd $APP_NAME -a VM.uptime
142+
Connected to remote JVM
143+
JVM response code = 0
144+
$TIME s
145+
```
146+
105147
### Commands
148+
149+
The following is a list of all available commands (some of the SapMachine specific),
150+
generated via `cf java --help`:
151+
106152
<pre>
107153
NAME:
108154
java - Obtain a heap-dump, thread-dump or profile from a running, SSH-enabled Java application.

0 commit comments

Comments
 (0)