Skip to content

Commit 33f912a

Browse files
committed
Add no-download flag
1 parent 69147fe commit 33f912a

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ USAGE:
120120
Print information about the Java Virtual Machine running a Java application
121121

122122
jcmd (supports --args)
123-
Run a JCMD command on a running Java application via --args
123+
Run a JCMD command on a running Java application via --args, downloads and deletes all files that are created in the current folder, use '--no-download' to prevent this
124124

125125
jfr-start
126126
Start a Java Flight Recorder default recording on a running Java application
@@ -150,7 +150,7 @@ USAGE:
150150
Print vital statistics about the Java Virtual Machine running a Java application
151151

152152
asprof (recent SapMachine only, supports --args)
153-
Run async-profiler commands passed to asprof via --args
153+
Run async-profiler commands passed to asprof via --args, copies files in the current folder. Don't use in combination with asprof-* commands. Downloads and deletes all files that are created in the current folder, use '--no-download' to prevent this
154154

155155
asprof-start-cpu (recent SapMachine only)
156156
Start an async-profiler CPU-time profile recording on a running Java application
@@ -167,23 +167,17 @@ USAGE:
167167
asprof-stop (recent SapMachine only)
168168
Stop an async-profiler profile recording on a running Java application
169169

170-
asprof-dump (recent SapMachine only)
171-
Dump an async-profiler profile recording without stopping it
172-
173170
asprof-status (recent SapMachine only)
174171
Get the status of async-profiler on a running Java application
175172

176173
OPTIONS:
177-
--app-instance-index -i [index], select to which instance of the app to connect
178-
--args -a, Miscellaneous arguments to pass to the command (if supported)
179-
in the container, be aware to end it with a space if it is a simple option
180-
--container-dir -cd, the directory path in the container that the heap dump/JFR/... file
181-
will be saved to
182-
--dry-run -n, just output to command line what would be executed
183-
--keep -k, keep the heap dump in the container; by default the heap dump/JFR/...
184-
will be deleted from the container's filesystem after been downloaded
185-
--local-dir -ld, the local directory path that the dump/JFR/... file will be saved to
186-
defaults to the current directory
174+
-dry-run -n, just output to command line what would be executed
175+
-keep -k, keep the heap dump in the container; by default the heap dump/JFR/... will be deleted from the container's filesystem after been downloaded
176+
-local-dir -ld, the local directory path that the dump/JFR/... file will be saved to, defaults to the current directory
177+
-no-download -nd, don't download the heap dump/JFR/... file to local, only keep it in the container, implies '--keep'
178+
-app-instance-index -i [index], select to which instance of the app to connect
179+
-args -a, Miscellaneous arguments to pass to the command (if supported) in the container, be aware to end it with a space if it is a simple option
180+
-container-dir -cd, the directory path in the container that the heap dump/JFR/... file will be saved to
187181
</pre>
188182

189183
The heap dumps and profiles will be copied to a local file if `-local-dir` is specified as a full folder path. Without providing `-local-dir` the heap dump will only be created in the container and not transferred.

cf_cli_java_plugin.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fi`,
181181
},
182182
{
183183
Name: "jcmd",
184-
Description: "Run a JCMD command on a running Java application via --args",
184+
Description: "Run a JCMD command on a running Java application via --args, downloads and deletes all files that are created in the current folder, use '--no-download' to prevent this",
185185
RequiredTools: []string{"jcmd"},
186186
GenerateFiles: false,
187187
SshCommand: `$JCMD_COMMAND $(pidof java) $$ARGS`,
@@ -259,13 +259,13 @@ fi`,
259259
},
260260
{
261261
Name: "asprof",
262-
Description: "Run async-profiler commands passed to asprof via --args",
262+
Description: "Run async-profiler commands passed to asprof via --args, copies files in the current folder. Don't use in combination with asprof-* commands. Downloads and deletes all files that are created in the current folder, use '--no-download' to prevent this",
263263
OnlyOnRecentSapMachine: true,
264264
RequiredTools: []string{"asprof"},
265265
GenerateFiles: false,
266266
GenerateArbitraryFiles: true,
267267
GenerateArbitraryFilesFolderName: "asprof",
268-
SshCommand: `$ASPROF_COMMAND $(pidof java) $$ARGS`,
268+
SshCommand: `$ASPROF_COMMAND $(pidof java) $$ARGS || true`,
269269
},
270270
{
271271
Name: "asprof-start-cpu",
@@ -365,6 +365,7 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator
365365

366366
commandFlags.NewIntFlagWithDefault("app-instance-index", "i", "application `instance` to connect to", -1)
367367
commandFlags.NewBoolFlag("keep", "k", "whether to `keep` the heap-dump/JFR/... files on the container of the application instance after having downloaded it locally")
368+
commandFlags.NewBoolFlag("no-download", "nd", "do not download the heap-dump/JFR/... file to the local machine")
368369
commandFlags.NewBoolFlag("dry-run", "n", "triggers the `dry-run` mode to show only the cf-ssh command that would have been executed")
369370
commandFlags.NewStringFlag("container-dir", "cd", "specify the folder path where the dump/JFR/... file should be stored in the container")
370371
commandFlags.NewStringFlag("local-dir", "ld", "specify the folder where the dump/JFR/... file will be downloaded to, dump file wil not be copied to local if this parameter was not set")
@@ -383,7 +384,8 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator
383384
}
384385

385386
applicationInstance := commandFlags.Int("app-instance-index")
386-
keepAfterDownload := commandFlags.IsSet("keep")
387+
noDownload := commandFlags.IsSet("no-download")
388+
keepAfterDownload := commandFlags.IsSet("keep") || noDownload
387389

388390
remoteDir := commandFlags.String("container-dir")
389391
localDir := commandFlags.String("local-dir")
@@ -505,7 +507,7 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator
505507

506508
output, err := commandExecutor.Execute(fullCommand)
507509

508-
if command.GenerateFiles {
510+
if command.GenerateFiles && !noDownload{
509511

510512
finalFile := ""
511513
var err error
@@ -541,7 +543,7 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator
541543
fmt.Println(toSentenceCase(command.FileLabel) + " file deleted in application container")
542544
}
543545
}
544-
if command.GenerateArbitraryFiles {
546+
if command.GenerateArbitraryFiles && !noDownload {
545547
// download all files in the generic folder
546548
files, err := util.ListFiles(cfSSHArguments, fspath)
547549
if err != nil {
@@ -626,6 +628,7 @@ func (c *JavaPlugin) GetMetadata() plugin.PluginMetadata {
626628
Usage: usageText,
627629
Options: map[string]string{
628630
"app-instance-index": "-i [index], select to which instance of the app to connect",
631+
"no-download": "-nd, don't download the heap dump/JFR/... file to local, only keep it in the container, implies '--keep'",
629632
"keep": "-k, keep the heap dump in the container; by default the heap dump/JFR/... will be deleted from the container's filesystem after been downloaded",
630633
"dry-run": "-n, just output to command line what would be executed",
631634
"container-dir": "-cd, the directory path in the container that the heap dump/JFR/... file will be saved to",

0 commit comments

Comments
 (0)