How to run out-of-the-box AEM CPU profiler as a cron job in Linux OS

Steps

  1. Create profiler.sh on your AEM server:

    HOSTPORT=$1
    SLEEPTIME=${2:-20}
    OUTPUTFILE=${3:-"output.html"}

    echo "Starting profiler..."
    curl "http://$HOSTPORT/system/console/profiler" -u admin:admin -o /dev/null -s --data 'interval=5&depth=160&ignoreThreadList=java.lang.Object.wait%2C%0D%0Ajava.lang.Thread.dumpThreads%2C%0D%0Ajava.lang.Thread.getThreads%2C%0D%0Ajava.lang.Thread.sleep%2C%0D%0Ajava.lang.UNIXProcess.waitForProcessExit%2C%0D%0Ajava.net.PlainSocketImpl.accept%2C%0D%0Ajava.net.PlainSocketImpl.socketAccept%2C%0D%0Ajava.net.SocketInputStream.socketRead%2C%0D%0Ajava.net.SocketOutputStream.socketWrite%2C%0D%0Asun.awt.windows.WToolkit.eventLoop%2C%0D%0Asun.misc.Unsafe.park%2C%0D%0AEDU.oswego%2C%0D%0Ajava.lang.Object.%24%24YJP%24%24wait%2C%0D%0Ajava.lang.Thread.%24%24YJP%24%24sleep%2C%0D%0Asun.misc.Unsafe.%24%24YJP%24%24park%2C%0D%0Ajava.net.PlainSocketImpl.%24%24YJP%24%24socketAccept%2C%0D%0Ajava.net.SocketInputStream.%24%24YJP%24%24socketRead%2C%0D%0Ajava.net.PlainSocketImpl.%24%24YJP%24%24accept%2C%0D%0Ajava.lang.Thread.%24%24YJP%24%24dumpThreads%2C%0D%0A&ignoreList=org.apache.commons%2C%0D%0Aorg.apache.tika.parser.txt.Charset%2C%0D%0AEDU.oswego%2C%0D%0A&ignorePackageList=java%2C%0D%0Asun%2C%0D%0Acom.sun.%2C%0D%0AEDU%2C%0D%0Aorg.apache.jsp.%2C%0D%0Aorg.apache.commons.%2C%0D%0Aorg.eclipse.jdt%2C%0D%0Aorg.json.%2C%0D%0Aorg.kxml2.%2C%0D%0Acom.apple.%2C%0D%0A&action=start' &
    echo "Sleeping for $SLEEPTIME seconds"
    while true;do echo -n .;sleep 1;done &
    sleep $SLEEPTIME
    kill $!; trap 'kill $!' SIGTERM
    echo "Stopping profiler"
    curl "http://$HOSTPORT/system/console/profiler" -u admin:admin --data 'action=stop' > $OUTPUTFILE
    echo "Done running profiler - check $OUTPUTFILE"

  2. Update username and password in the script.

  3. Run the script: bash profiler.sh <host:port><time-in-seconds><output-file-path>

    Example:
    bash profiler localhost:4502 240 /tmp/profiler.html

 Adobe

Krijg sneller en gemakkelijker hulp

Nieuwe gebruiker?