From c46767b2c256a35f09170415865178c66bcfe1ce Mon Sep 17 00:00:00 2001 From: Johannes Scheerer <30600170+ScheererJ@users.noreply.github.com> Date: Fri, 13 Apr 2018 10:13:16 +0200 Subject: [PATCH 1/3] Remove heap dump addon files as well SAP JVM creates an addon file next to the heap dump file. The addon file includes among other things the command line parameters of the process and the stack traces of the last out of memory errors as well as a class and meta space statistic. --- cleanup/cleanup.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cleanup/cleanup.go b/cleanup/cleanup.go index 8de4ff7..d026b2a 100644 --- a/cleanup/cleanup.go +++ b/cleanup/cleanup.go @@ -106,6 +106,17 @@ func CleanUp(fs afero.Fs, cfg Config) ([]string, error) { } deletedFiles = append(deletedFiles, path) + + // SAP JVM also creates .addon files that should be removed as well + addonPath := path[0:len(path)-len(".hprof")] + ".addon" + addonFile, err := fs.Stat(addonPath) + if !os.IsNotExist(err) && addonFile.Mode().isRegular() { + var err = fs.Remove(addonPath) + if err != nil { + return nil, fmt.Errorf("Cannot delete heap dump addon file '"+addonPath+"': %v", err) + } + deletedFiles = append(deletedFiles, addonPath) + } } return deletedFiles, nil From bfe57f72514609205ff25a717e888c34b712356e Mon Sep 17 00:00:00 2001 From: Johannes Scheerer <30600170+ScheererJ@users.noreply.github.com> Date: Fri, 13 Apr 2018 10:53:53 +0200 Subject: [PATCH 2/3] Fixed extenstion of the addon file --- cleanup/cleanup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanup/cleanup.go b/cleanup/cleanup.go index d026b2a..140055f 100644 --- a/cleanup/cleanup.go +++ b/cleanup/cleanup.go @@ -108,7 +108,7 @@ func CleanUp(fs afero.Fs, cfg Config) ([]string, error) { deletedFiles = append(deletedFiles, path) // SAP JVM also creates .addon files that should be removed as well - addonPath := path[0:len(path)-len(".hprof")] + ".addon" + addonPath := path[0:len(path)-len(".hprof")] + ".addons" addonFile, err := fs.Stat(addonPath) if !os.IsNotExist(err) && addonFile.Mode().isRegular() { var err = fs.Remove(addonPath) From 86c48cd73b6b79ea00abe494c459a6264a6ffc89 Mon Sep 17 00:00:00 2001 From: Johannes Scheerer <30600170+ScheererJ@users.noreply.github.com> Date: Fri, 13 Apr 2018 10:54:38 +0200 Subject: [PATCH 3/3] Fixed the comment as well to include the correct extension --- cleanup/cleanup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanup/cleanup.go b/cleanup/cleanup.go index 140055f..2c6bb6d 100644 --- a/cleanup/cleanup.go +++ b/cleanup/cleanup.go @@ -107,7 +107,7 @@ func CleanUp(fs afero.Fs, cfg Config) ([]string, error) { deletedFiles = append(deletedFiles, path) - // SAP JVM also creates .addon files that should be removed as well + // SAP JVM also creates .addons files that should be removed as well addonPath := path[0:len(path)-len(".hprof")] + ".addons" addonFile, err := fs.Stat(addonPath) if !os.IsNotExist(err) && addonFile.Mode().isRegular() {