@@ -153,8 +153,9 @@ var commands = []Command{
153153 Description : "Generate a heap dump from a running Java application" ,
154154 GenerateFiles : true ,
155155 FileExtension : ".hprof" ,
156+ RequiredTools : []string {"jmap" , "jvmmon" },
156157 /*
157- If there is not enough space on the filesystem to write the dump, jmap will create a file
158+ If there is not enough space on the filesystem to write the dump, jmap will create a file
158159 with size 0, output something about not enough space left on the device, and exit with status code 0.
159160 Because YOLO.
160161
@@ -180,17 +181,16 @@ SIZE=-1; OLD_SIZE=$(stat -c '%s' "${HEAP_DUMP_NAME}"); while [ ${SIZE} != ${OLD_
180181if [ ! -s "${HEAP_DUMP_NAME}" ]; then echo >&2 ${OUTPUT}; $$EXIT 1; fi
181182if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi
182183fi` ,
184+ AliasCommand : "$JMAP_COMMAND -dump:format=b,file=$$FILE_NAME $$PIDOF_JAVA_APP" ,
183185 FileLabel : "heap dump" ,
184186 FileNamePart : "heapdump" ,
185- OmitAlias : true ,
186187 },
187188 {
188189 Name : "thread-dump" ,
189190 Description : "Generate a thread dump from a running Java application" ,
190191 RequiredTools : []string {"jstack" , "jvmmon" },
191192 GenerateFiles : false ,
192- SshCommand : "${JSTACK_COMMAND} $$PIDOF_JAVA_APP; ${JVMMON_COMMAND} -pid $$PIDOF_JAVA_APP -c \" print stacktrace\" " ,
193- OmitAlias : true ,
193+ SshCommand : "${JSTACK_COMMAND} $$PIDOF_JAVA_APP; ${JVMMON_COMMAND} -pid $$PIDOF_JAVA_APP -c \" print stacktrace\" 2> /dev/null" ,
194194 },
195195 {
196196 Name : "vm-info" ,
@@ -404,7 +404,7 @@ func toSentenceCase(input string) string {
404404
405405func generateRequiredToolCommand (requiredTool string ) []string {
406406 uppercase := strings .ToUpper (requiredTool )
407- var ret = []string {fmt .Sprintf (`%s_COMMAND=$(which %s 2>/dev/null || command -v %s 2>/dev/null)
407+ var ret = []string {fmt .Sprintf (`%s_COMMAND=$(which %s 2>/dev/null || command -v %s 2>/dev/null || echo '___NOT_FOUND___' )
408408if [ -z "${%s_COMMAND}" ]; then
409409 if [ -n "$JAVA_HOME" ]; then
410410 %s_COMMAND=$(find "$JAVA_HOME/bin" -name %s -type f -executable 2>/dev/null | head -1)
@@ -415,7 +415,8 @@ fi`, uppercase, requiredTool, requiredTool, uppercase, uppercase, requiredTool)}
415415 ret = append (ret , fmt .Sprintf (`ASPROF_COMMAND=$(which asprof 2>/dev/null || command -v asprof 2>/dev/null)
416416if [ -n "${ASPROF_COMMAND}" ]; then
417417 JCMD_COMMAND="${ASPROF_COMMAND} jcmd"
418- fi` ))
418+ fi
419+ ` ))
419420 }
420421 return ret
421422}
0 commit comments