之前写过一个文章,也是分析AIX上weblogic占用CPU高的问题,但借助了DBX工具来分析。
其实不用DBX也能分析,而且步骤非常简单:
1、-bash-4.0$ ps -ef|grep java
weblogic 348366 278592 0 21时20分04秒 pts/1 0:00 grep java
weblogic 385168 258214 0 3月15 - 3:30 /usr/java6_64/bin/java -Xms256m -Xmx512m -da -Dplatform.home=/home/weblogic/bea103/wlserver_10.3 -Dwls.home=/home/weblogic/bea103/wlserver_10.3/server -Dweblogic.home=/home/weblogic/bea103/wlserver_10.3/server -Dweblogic.management.discover=true -Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=/home/weblogic/bea103/patch_wls1030/profiles/default/sysext_manifest_classpath:/home/weblogic/bea103/patch_cie660/profiles/default/sysext_manifest_classpath -Dweblogic.Name=AdminServer -Djava.security.policy=/home/weblogic/bea103/wlserver_10.3/server/lib/weblogic.policy weblogic.Server
找到weblogic进程的pid
2、-bash-4.0$ ps -mp 385168 -o THREAD
USER PID PPID TID ST CP PRI SC WCHAN F TT BND COMMAND
weblogic 385168 258214 – A 119 60 34 * 242001 - – /usr/java6_64/bin/java -Xms256m -Xmx512m -da -Dplatform.home=/home/weblogic/bea103/wlserver_10.3 -Dwls.home=/home/w
- - - 418009 S 0 78 1 f100070f10006640 8410400 - – -
- - - 466985 S 0 82 1 113876f00 c10400 - – -
- - - 503839 Z 0 82 1 - c00001 - – -
- - - 553137 Z 0 82 1 - c00001 - – -
- - - 643101 S 0 82 1 f100070f10009d40 8410400 - – -
- - - 745585 S 0 82 1 f100070f1000b640 8410400 - – -
- - - 749707 S 0 66 1 f100020003844a08 400400 - – -
- - - 753811 S 0 82 1 f100070f1000b840 8410400 - – -
- - - 766095 S 0 82 1 f100070f1000bb40 8410400 - – -
- - - 774277 R 119 161 0 - 400000 - – -
- - - 778389 S 0 82 1 f100070f1000be40 8410400 - – -
- - - 790697 S 0 60 1 f100070f1000c140 8410400 - – -
- - - 794769 S 0 82 1 f1000100201a8a30 410400 - – -
- - - 798863 Z 0 82 1 - c00001 - – -
- - - 802961 S 0 82 1 f100070f1000c440 8410400 - – -
- - - 807059 S 0 82 1 f10001001c8ef498 410400 - – -
- - - 819353 Z 0 82 1 - c00001 - – -
- - - 823451 S 0 60 1 f100070f1000c940 8410400 - – -
- - - 827551 S 0 60 1 f100070f1000ca40 8410400 - – -
- - - 831649 S 0 60 1 f1000100186b2f98 410400 - – -
- - - 848037 S 0 82 1 f100070f1000cf40 8410400 - – -
- - - 856235 S 0 82 1 f100070f1000d140 8410400 - – -
- - - 860333 S 0 66 1 f100070f1000d240 8410400 - – -
- - - 868533 S 0 66 1 f100020003849a08 400400 - – -
- - - 909537 S 0 82 1 f100070f1000de40 8410400 - – -
- - - 913607 S 0 82 1 f100070f1000df40 8410400 - – -
- - - 921835 S 0 94 1 f100070f1000e140 8410400 - – -
- - - 925933 S 0 82 1 f100070f1000e240 8410400 - – -
- - - 929999 S 0 82 1 f100070f1000e340 8410400 - – -
- - - 938225 S 0 82 1 f100070f1000e540 8410400 - – -
- - - 954605 S 0 82 1 f100070f1000e940 8410400 - – -
- - - 958687 Z 0 94 1 - c00001 - – -
- - - 966909 S 0 66 1 f100070f1000ec40 8410400 - – -
- - - 974895 S 0 78 1 f100070f1000ee40 8410400 - – -
- - - 987267 Z 0 82 1 - c00001 - – -
-bash-4.0$ kill -3 385168
-bash-4.0$
通过Ps-mp命令找到cp值比较高的线程,并手动的做一次javacore
3、在上一步里,可以看到cp值较高的线程为774277 R 119 161 0 - 400000
将774277这个TID转化为16进制为:BD085
4、在产生的javacore里去寻找native id为BD085的线程
“[ACTIVE] ExecuteThread: ’2′ for queue: ‘weblogic.kernel.Default (self-tuning)’” TID:0x0000000116499A00, j9thread_t:0x000000011527D2A0, state:CW, prio=5
3XMTHREADINFO1 (native thread ID:0xBD085, native priority:0×5, native policy:UNKNOWN)
4XESTACKTRACE at tdy218/alg/DeadLoop.service(DeadLoop.java:17)
4XESTACKTRACE at javax/servlet/http/HttpServlet.service(HttpServlet.java:820)
4XESTACKTRACE at weblogic/servlet/internal/StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227(Compiled Code))
4XESTACKTRACE at weblogic/servlet/internal/StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125(Compiled Code))
4XESTACKTRACE at weblogic/servlet/internal/ServletStubImpl.execute(ServletStubImpl.java:292(Compiled Code))
4XESTACKTRACE at weblogic/servlet/internal/ServletStubImpl.execute(ServletStubImpl.java:175(Compiled Code))
4XESTACKTRACE at weblogic/servlet/internal/WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
4XESTACKTRACE at weblogic/security/acl/internal/AuthenticatedSubject.doAs(AuthenticatedSubject.java:321(Compiled Code))
4XESTACKTRACE at weblogic/security/service/SecurityManager.runAs(Bytecode PC:18(Compiled Code))
4XESTACKTRACE at weblogic/servlet/internal/WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
4XESTACKTRACE at weblogic/servlet/internal/WebAppServletContext.execute(WebAppServletContext.java:2086)
4XESTACKTRACE at weblogic/servlet/internal/ServletRequestImpl.run(ServletRequestImpl.java:1406)
4XESTACKTRACE at weblogic/work/ExecuteThread.execute(ExecuteThread.java:201(Compiled Code))
4XESTACKTRACE at weblogic/work/ExecuteThread.run(ExecuteThread.java:173)
at tdy218/alg/DeadLoop.service(DeadLoop.java:17)
此代码既是造成CPU高的代码