以下是一些JVM性能调优监控工具
1
jps、jstack、jmap、jhat、jstat、hprof....
对于java程序,有时可能会碰到以下问题
  • OutOfMemoryError,内存不足
  • 内存泄露
  • 线程死锁
  • 锁争用(Lock Contention)
  • Java进程消耗CPU过高
  • ….

简单的脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
# vim:set et ts=4 sw=4:
#set -x

app_list='inner core scene outer'
current_unix=$(date +"%s")
while true
do
current_date=$(date -d @$current_unix +"%H%M%S")
# 举例core的pid
/home/app/jdk/bin/jmap -heap PID | gzip > /home/changyou/jmap-heap/core-heap-${current_date}.log.gz
/home/app/jdk/bin/jmap -histo PID | gzip > /home/changyou/jmap-histo/core-histo-${current_date}.log.gz

sleep 10
current_unix=$(date +"%s")
done

通过一些监控工具去对java程序进行调优以及监控,在发生问题时使用工具去进行定位问题为后续的排障、修复问题起到了很好的辅助作用。