Alon Bar-Lev has posted comments on this change.
Change subject: tools: Add script to dump heap
......................................................................
Patch Set 2: (9 inline comments)
....................................................
File packaging/bin/engine-heap-dump.sh
Line 1: #!/bin/sh
Line 2:
Line 3: if [ "$(id -u)" = 0 ]; then
Line 4: exec su - "${ENGINE_USER}" -s $@ || die "cannot su to engine user"
I think: $@ -> "$@"
Line 5: fi
Line 6:
Line 7: # Load the prolog:
Line 8: . "$(dirname "$(readlink -f "$0")")"/engine-prolog.sh
Line 8: . "$(dirname "$(readlink -f "$0")")"/engine-prolog.sh
Line 9:
Line 10: # First check if the engine is running:
Line 11: PID='pidof ovirt-engine'
Line 12: if [ -z "${PID}" ]
should be:
if xxx; then
but please use:
[ -n "${PID}" ] || die ...
Line 13: then
Line 14: die "The engine is not running."
Line 15: fi
Line 16:
Line 15: fi
Line 16:
Line 17: # Check tha the jmap tools is available and correct version (it won't
usually
Line 18: # be available, as it is part of the JDK and we only require the JRE):
Line 19: JMAP='/bin/sh -c "which jmap 2> /dev/null"'
why do we need sh -c here?
Line 20: if [ -z "${JMAP}" ]
Line 21: then
Line 22: die "The jmap tool is not available. Please install a JDK (inplace
of a JRE)"
Line 23: fi
Line 22: die "The jmap tool is not available. Please install a JDK (inplace
of a JRE)"
Line 23: fi
Line 24:
Line 25: # Compute the locations of the histogram and heap dump files:
Line 26: DATE='date +%Y%m%d_%H%M%S'
can you please drop the '_', there is no standard date format with _ as
separator.
Line 27: HISTO="${ENGINE_LOG}/histo.${DATE}_${PID}.txt"
Line 28: DUMP="${ENGINE_LOG}/dump.${DATE}_${PID}.bin"
Line 29:
Line 30: # Write the histogram:
Line 23: fi
Line 24:
Line 25: # Compute the locations of the histogram and heap dump files:
Line 26: DATE='date +%Y%m%d_%H%M%S'
Line 27: HISTO="${ENGINE_LOG}/histo.${DATE}_${PID}.txt"
please use '-' as separator. please have the ${DATE} as prefix so we have all
data sorted using timeline and all data at same place.
Line 28: DUMP="${ENGINE_LOG}/dump.${DATE}_${PID}.bin"
Line 29:
Line 30: # Write the histogram:
Line 31: echo "Writing histogram to ${HISTO} ..."
Line 27: HISTO="${ENGINE_LOG}/histo.${DATE}_${PID}.txt"
Line 28: DUMP="${ENGINE_LOG}/dump.${DATE}_${PID}.bin"
Line 29:
Line 30: # Write the histogram:
Line 31: echo "Writing histogram to ${HISTO} ..."
not sure why we need these messages... but if we do, we need these for both
commands. I suggest drop the messages.
Line 32: su - "${ENGINE_USER}" -s /bin/sh -c "${JMAP} -histo ${PID} > ${HISTO}"
Line 33: echo "Histogram file created"
Line 34:
Line 35: # Dump the heap:
Line 28: DUMP="${ENGINE_LOG}/dump.${DATE}_${PID}.bin"
Line 29:
Line 30: # Write the histogram:
Line 31: echo "Writing histogram to ${HISTO} ..."
Line 32: su - "${ENGINE_USER}" -s /bin/sh -c "${JMAP} -histo ${PID} > ${HISTO}"
su not required.
Line 33: echo "Histogram file created"
Line 34:
Line 35: # Dump the heap:
Line 36: su - "${ENGINE_USER}" -s /bin/sh -c "${JMAP} -heap
-dump:format=b,file=${DUMP} ${PID}"
Line 32: su - "${ENGINE_USER}" -s /bin/sh -c "${JMAP} -histo ${PID} > ${HISTO}"
Line 33: echo "Histogram file created"
Line 34:
Line 35: # Dump the heap:
Line 36: su - "${ENGINE_USER}" -s /bin/sh -c "${JMAP} -heap
-dump:format=b,file=${DUMP} ${PID}"
su not required.
Line 37:
Line 38: # Bye:
Line 34:
Line 35: # Dump the heap:
Line 36: su - "${ENGINE_USER}" -s /bin/sh -c "${JMAP} -heap
-dump:format=b,file=${DUMP} ${PID}"
Line 37:
Line 38: # Bye:
drop useless comments.
--
To view, visit http://gerrit.ovirt.org/15359
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I5ea3355eafbb07d2b6c9594abcc282c139d2f31f
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Liran Zelkha <[email protected]>
Gerrit-Reviewer: Sandro Bonazzola <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches