Skip to content

Commit 798ee0b

Browse files
committed
Add jstall support
1 parent f207349 commit 798ee0b

13 files changed

Lines changed: 1070 additions & 107 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
echo "No version changes detected"
106106
else
107107
echo "Committing version update"
108-
git add cf_cli_java_plugin.go README.md
108+
git add cf_cli_java_plugin.go CHANGELOG.md
109109
git commit -m "Set version to v$VERSION"
110110
git push
111111
fi

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Bundle [jstall](https://github.com/parttimenerd/jstall) (jstall-minimal.jar) for one-shot JVM inspection
12+
via `cf java jstall APP_NAME`. Requires Java 17+ locally. Supports all jstall subcommands via `jstall APP --args`.
13+
14+
## [4.0.2]
15+
16+
### Fixed
17+
- Fix rare ssh connection issue
18+
19+
## [4.0.1]
20+
21+
### Fixed
22+
- Fix thread-dump command
23+
24+
## [4.0.0]
25+
26+
### Added
27+
- Create a proper test suite
28+
- Profiling and JCMD related features
29+
30+
### Fixed
31+
- Fix many bugs discovered during testing

Makefile

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
11
JAVA_PLUGIN_INSTALLED = $(cf plugins | grep -q)
2+
JSTALL_JAR = dist/jstall-minimal.jar
3+
# Set JSTALL_DEV=1 to pull the latest GitHub Actions build instead of the latest release
4+
JSTALL_DEV ?=
25

36
all: install
47

5-
compile: cf_cli_java_plugin.go
6-
go build -o build/cf-cli-java-plugin cf_cli_java_plugin.go
8+
$(JSTALL_JAR):
9+
mkdir -p dist
10+
ifdef JSTALL_DEV
11+
ifeq ($(JSTALL_DEV),1)
12+
gh run download -R parttimenerd/jstall -n jstall-minimal-jar --dir dist
13+
else
14+
gh run download $(JSTALL_DEV) -R parttimenerd/jstall -n jstall-minimal-jar --dir dist
15+
endif
16+
else
17+
curl -sL -o $@ https://github.com/parttimenerd/jstall/releases/latest/download/jstall-minimal.jar
18+
endif
19+
20+
download-jstall: $(JSTALL_JAR)
21+
22+
update-jstall:
23+
rm -f $(JSTALL_JAR)
24+
$(MAKE) download-jstall
25+
26+
.PHONY: update-jstall download-jstall
27+
28+
# When JSTALL_DEV=1, always re-download the jar (skip file existence check)
29+
ifdef JSTALL_DEV
30+
JSTALL_DEP = update-jstall
31+
else
32+
JSTALL_DEP = $(JSTALL_JAR)
33+
endif
34+
35+
compile: $(JSTALL_DEP)
36+
go build -o build/cf-cli-java-plugin .
737

8-
compile-all: cf_cli_java_plugin.go
9-
GOOS=linux GOARCH=386 go build -o build/cf-cli-java-plugin-linux32 cf_cli_java_plugin.go
10-
GOOS=linux GOARCH=amd64 go build -o build/cf-cli-java-plugin-linux64 cf_cli_java_plugin.go
11-
GOOS=darwin GOARCH=amd64 go build -o build/cf-cli-java-plugin-osx cf_cli_java_plugin.go
12-
GOOS=windows GOARCH=386 go build -o build/cf-cli-java-plugin-win32.exe cf_cli_java_plugin.go
13-
GOOS=windows GOARCH=amd64 go build -o build/cf-cli-java-plugin-win64.exe cf_cli_java_plugin.go
38+
compile-all: $(JSTALL_DEP)
39+
GOOS=linux GOARCH=amd64 go build -o build/cf-cli-java-plugin-linux64 .
40+
GOOS=linux GOARCH=arm64 go build -o build/cf-cli-java-plugin-linux-arm64 .
41+
GOOS=darwin GOARCH=amd64 go build -o build/cf-cli-java-plugin-osx .
42+
GOOS=darwin GOARCH=arm64 go build -o build/cf-cli-java-plugin-osx-arm64 .
43+
GOOS=windows GOARCH=amd64 go build -o build/cf-cli-java-plugin-win64.exe .
1444

1545
clean:
1646
rm -r build

README.md

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Currently, it allows you to:
1313
- To run jcmd remotely on your application
1414
- To start, stop and retrieve JFR and [async-profiler](https://github.com/jvm-profiling-tools/async-profiler)
1515
([SapMachine](https://sapmachine.io) only) profiles from your application
16+
- To run [jstall](https://github.com/parttimenerd/jstall) for one-shot JVM inspection (deadlock detection, hot threads,
17+
dependency graphs, and more) — bundled directly in the plugin, requires Java 17+ locally
1618

1719
## Installation
1820

@@ -150,6 +152,35 @@ JVM response code = 0
150152
$TIME s
151153
```
152154

155+
Running [JStall](https://github.com/parttimenerd/jstall) for quick JVM inspection (requires Java 17+ locally):
156+
157+
```sh
158+
# Default: run status analysis with deadlock detection, hot threads, etc.
159+
> cf java jstall $APP_NAME
160+
161+
# Run a specific jstall subcommand
162+
> cf java jstall $APP_NAME --args 'deadlock'
163+
> cf java jstall $APP_NAME --args 'most-work --dumps 3'
164+
> cf java jstall $APP_NAME --args 'flame'
165+
```
166+
167+
Recording JVM diagnostic data for later analysis or sharing:
168+
169+
```sh
170+
# Record all JVM diagnostic data into a zip file (default: APP_NAME-status.zip)
171+
> cf java record-status $APP_NAME
172+
173+
# Record to a specific output file
174+
> cf java record-status $APP_NAME diagnostics.zip
175+
176+
# Record with full data (including expensive jcmd commands, flame graph, and JFR)
177+
> cf java record-status $APP_NAME --args '--full'
178+
179+
# Replay the recording locally with jstall
180+
> jstall -f diagnostics.zip status all
181+
> jstall -f diagnostics.zip threads all
182+
```
183+
153184
#### Variable Replacements for JCMD and Asprof Commands
154185

155186
When using `jcmd` and `asprof` commands with the `--args` parameter, the following variables are automatically replaced
@@ -181,7 +212,6 @@ directory and downloads any files created there to your local directory (unless
181212
The following is a list of all available commands (some of the SapMachine specific), generated via `cf java --help`:
182213

183214
<pre>
184-
185215
NAME:
186216
java - Obtain a heap-dump, thread-dump or profile from a running, SSH-enabled Java application.
187217

@@ -274,24 +304,43 @@ USAGE:
274304
asprof-status (recent SapMachine only)
275305
Get the status of async-profiler on a running Java application
276306

307+
status (requires Java 17+ locally, supports --args)
308+
Quick status check of the remote JVM: deadlock detection, hot threads,
309+
dependency graph, and more. Requires Java 17+ locally. Pass additional
310+
options via --args (e.g., '--dumps 3', '--full'). See
311+
https://github.com/parttimenerd/jstall
312+
313+
jstall (requires Java 17+ locally, supports --args)
314+
Inspect the remote JVM via JStall (runs on your machine, connects via cf
315+
ssh). Requires Java 17+ locally. Pass jstall subcommands and options via
316+
--args (default: 'status all'). See
317+
https://github.com/parttimenerd/jstall
318+
319+
record-status (requires Java 17+ locally, supports --args)
320+
Record diagnostic data from the remote JVM via JStall and save to a
321+
local zip file. Requires Java 17+ locally. Output file can be specified
322+
as a trailing argument (default: APP_NAME-status.zip). Use --args to
323+
pass additional jstall record options like '--full'. See
324+
https://github.com/parttimenerd/jstall
325+
277326
OPTIONS:
278-
-app-instance-index -i [index], select to which instance of the app to connect
279-
-args -a, Miscellaneous arguments to pass to the command (if supported) in the
327+
--app-instance-index -i [index], select to which instance of the app to connect
328+
--args -a, Miscellaneous arguments to pass to the command (if supported) in the
280329
container, be aware to end it with a space if it is a simple option. For
281330
commands that create arbitrary files (jcmd, asprof), the environment
282331
variables @FSPATH, @ARGS, @APP_NAME, @FILE_NAME, and @STATIC_FILE_NAME are
283332
available in --args to reference the working directory path, arguments,
284333
application name, and generated file name respectively.
285-
-container-dir -cd, the directory path in the container that the heap dump/JFR/... file will be
334+
--container-dir -cd, the directory path in the container that the heap dump/JFR/... file will be
286335
saved to
287-
-dry-run -n, just output to command line what would be executed
288-
-keep -k, keep the heap dump in the container; by default the heap dump/JFR/... will
336+
--dry-run -n, just output to command line what would be executed
337+
--keep -k, keep the heap dump in the container; by default the heap dump/JFR/... will
289338
be deleted from the container's filesystem after being downloaded
290-
-local-dir -ld, the local directory path that the dump/JFR/... file will be saved to,
339+
--local-dir -ld, the local directory path that the dump/JFR/... file will be saved to,
291340
defaults to the current directory
292-
-no-download -nd, don't download the heap dump/JFR/... file to local, only keep it in the
341+
--no-download -nd, don't download the heap dump/JFR/... file to local, only keep it in the
293342
container, implies '--keep'
294-
-verbose -v, enable verbose output for the plugin
343+
--verbose -v, enable verbose output for the plugin
295344

296345
</pre>
297346

@@ -379,6 +428,17 @@ make build
379428
./scripts/lint-all.sh fix
380429
```
381430

431+
### Build Configuration
432+
433+
**JStall Version**: By default, the build downloads the latest stable JStall release. To test with the latest
434+
development build from GitHub Actions instead, use:
435+
436+
```bash
437+
JSTALL_DEV=1 make build
438+
```
439+
440+
This pulls the latest JStall build directly from the GitHub Actions artifacts instead of the released version.
441+
382442
### Testing
383443

384444
**Python Tests**: Modern pytest-based test suite.
@@ -429,24 +489,7 @@ create GitHub issues for security-related doubts or problems.
429489

430490
## Changelog
431491

432-
## Snapshot
433-
434-
435-
## 4.0.2
436-
437-
### 4.0.2
438-
439-
- Fix rare ssh connection issue
440-
441-
### 4.0.1
442-
443-
- Fix thread-dump command
444-
445-
### 4.0.0
446-
447-
- Create a proper test suite
448-
- Fix many bugs discovered during testing
449-
- Profiling and JCMD related features
492+
See [CHANGELOG.md](CHANGELOG.md) for a detailed list of changes.
450493

451494
## License
452495

0 commit comments

Comments
 (0)