Created
August 3, 2016 15:01
-
-
Save thomashartm/3ced1c075f113e730ad7d968d38688f7 to your computer and use it in GitHub Desktop.
Creates a heampdump for a particular pid or shows all pids for running aem instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage instructions | |
# Make the script executable: | |
# chmod u+x heapdump.sh | |
# | |
# Show all running aem instances and their pids | |
# ./heapdumps.sh | |
# Create a heampdump for a running aem instance | |
# ./heapdumps.sh <pid> | |
function showPIDs(){ | |
jps -lv | grep aem | |
} | |
function createDump(){ | |
local pid=$1 | |
echo "Creating heapdump for process: $pid" | |
jmap -dump:format=b,file=heap.bin $pid | |
} | |
numberRegex='^[0-9]+$' | |
if [[ $1 =~ $numberRegex ]]; then | |
createDump $1 | |
else | |
echo "Showing all running AEM instances." | |
echo "PID Name" | |
showPIDs | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment