Liran Zelkha 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"
Done
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}" ]
Done
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"'
Done
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'
Done
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"
Done
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} ..."
Operation might be long (for big heaps) - so messages will probably help... 
I'll add to the second command too.
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}"
Done
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}"
Done
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:
Done


-- 
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 <juan.hernan...@redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com>
Gerrit-Reviewer: Liran Zelkha <liran.zel...@gmail.com>
Gerrit-Reviewer: Sandro Bonazzola <sbona...@redhat.com>
Gerrit-Reviewer: Yair Zaslavsky <yzasl...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to