如何监控java进程

  • ps -aux | grep java 查看所有java进程,加粗地方找到对应jvm位置

[[email protected] ~]$ 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 "十六进制数",查看堆栈即可看到当前正在执行的方法栈

[[email protected] ~]$ 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)

你可能感兴趣的:(java,.net,socket,jboss,IE)