欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

如何监控java进程 Java.netJBossSocketIE 

程序员文章站 2022-07-14 19:43:30
...
  • ps -aux | grep java 查看所有java进程,加粗地方找到对应jvm位置

[chongguo.jzw@v037176.sqa.cm4 ~]$ ps -aux | grep java
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
admin     8492  0.0 30.0 1203804 551208 ?      Sl   Mar10   4:05 [b]/opt/taobao/java1/bin/java[/b] -Dprogram.name=run.sh -server -Xms768m -Xmx768m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=96m -XX:MaxPermSize=96m -Djava.awt.headless=true -Dsun.net.client.defaultConnectTimeout=5000 -Dsun.net.client.defaultReadTimeout=5000 -XX:ErrorFile=/home/admin/et/logs/java_error_%p.log -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=/opt/taobao/jboss1/lib/endorsed -classpath /opt/taobao/jboss1/bin/run.jar:/opt/taobao/java1/lib/tools.jar org.jboss.Main -b 0.0.0.0 -Djboss.server.home.dir=/home/admin/ie/.default -Djboss.server.home.url=file:/home/admin/ie/.default

  • sudo -u admin -H /opt/taobao/java1/bin/jps -lv
  • jps查找到对应的jvm进程号。jps 它的作用是显示当前系统的java进程情况,及其id号
  • jstack 得到该进程对应的堆栈信息
  • sudo -u admin -H /opt/taobao/java1/bin/jstack 8492
  • top 然后Shift+h,切到以线程方式显示top,找到最上面的线程id号
  • 将线程id号转成十六进制:echo 'obase=16;要转换的十进制数' | bc 
  • sudo -u admin -H /opt/taobao/java1/bin/jstack 8492 | sudo -u admin -H grep -A 20 -B 10 "十六进制数",查看堆栈即可看到当前正在执行的方法栈

[chongguo.jzw@v037176.sqa.cm4 ~]$ sudo -u admin -H /opt/taobao/java1/bin/jstack 8492 | grep -A 20 -B 10 "2320"
"AcceptorThread#0:3873" prio=10 tid=0xbd63dc00 nid=0x214f runnable [0xbd1e1000..0xbd1e20b0]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
        - locked <0xc4d69700> (a java.net.SocksSocketImpl)
        at java.net.ServerSocket.implAccept(ServerSocket.java:453)
        at java.net.ServerSocket.accept(ServerSocket.java:421)
        at org.jboss.remoting.transport.socket.SocketServerInvoker.run(SocketServerInvoker.java:520)
        at java.lang.Thread.run(Thread.java:619)

"ServerSocketRefresh" daemon prio=10 tid=0x08e5cc00 nid=0x214e in Object.wait() [0xbd232000..0xbd233130]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0xc4ae0dc0> (a java.lang.Object)
        at java.lang.Object.wait(Object.java:485)
        at org.jboss.remoting.transport.socket.SocketServerInvoker$ServerSocketRefresh.run(SocketServerInvoker.java:704)
        - locked <0xc4ae0dc0> (a java.lang.Object)

"AcceptorThread#0:4446" prio=10 tid=0xbd638800 nid=0x214d runnable [0xbd283000..0xbd283db0]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
        - locked <0xc51ad370> (a java.net.SocksSocketImpl)
        at java.net.ServerSocket.implAccept(ServerSocket.java:453)
        at java.net.ServerSocket.accept(ServerSocket.java:421)
        at org.jboss.remoting.transport.socket.SocketServerInvoker.run(SocketServerInvoker.java:520)
        at java.lang.Thread.run(Thread.java:619)

"PooledInvokerAcceptor#0-4445" prio=10 tid=0xbd637c00 nid=0x214c runnable [0xbd2d4000..0xbd2d4e30]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainSocketImpl.socketAccept(Native Method)