deadlock-detector.sh 541 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. while true
  3. do
  4. sleep 60
  5. file="/tmp/deadlock-detector-$(date +"%Y-%m-%d-%H-%M-%S").txt"
  6. for pid in $(jps | grep -v Jps | awk '{ print $1 }')
  7. do
  8. jcmd "$pid" VM.command_line >> "$file"
  9. jcmd "$pid" Thread.print >> "$file"
  10. if jcmd "$pid" Thread.print | grep -q SimpleLogger
  11. then
  12. # check once more to eliminate most of the sporadic finds
  13. if jcmd "$pid" Thread.print | grep -q SimpleLogger
  14. then
  15. jcmd "$pid" GC.heap_dump "/tmp/deadlock-detector-$pid.hprof"
  16. fi
  17. fi
  18. done
  19. done &