Skip to content

Instantly share code, notes, and snippets.

@thomashartm
Created August 3, 2016 15:01
Show Gist options
  • Save thomashartm/3ced1c075f113e730ad7d968d38688f7 to your computer and use it in GitHub Desktop.
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
#!/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