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

linux的top命令分析问题 博客分类: linux  

程序员文章站 2024-03-24 13:38:04
...

今天发生数据库查询返回一半的json数据,之前以为设置c3p0的maxIdleTime为大值会解决问题,没想到问题依旧存在。

用top命令分析一下java内存:

 

[101@G3_101 bin]$ top

top - 15:58:38 up 66 days,  6:07,  2 users,  load average: 0.00, 0.00, 0.00

Tasks: 119 total,   1 running, 118 sleeping,   0 stopped,   0 zombie

Cpu(s):  0.3%us,  0.2%sy,  0.0%ni, 99.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:   3924684k total,  1378960k used,  2545724k free,   169944k buffers

Swap:  4194296k total,    23792k used,  4170504k free,   343196k cached

PID    USER    PR  NI  VIRT   RES   SHR S %cpu %mem TIME+  COMMAND

 1661 mysql     20   0 1178m 117m 3456 S  0.3    3.1     70:42.33   mysqld

24483 101       20   0 2237m 534m  12m S  0.3    13.9    1:00.40      java

24531 101       20   0 15028  1324  1004   R   0.3       0.0       0:01.20      top

    1     root      20   0 19232  1348   1192    S    0.0        0.0        0:01.12      init

 

 

从分析得出,系统内存足够多,java进程VIRT 2237m虚拟内存,VIRT=SWAP+RES , 闲置虚拟内存还有534m 。

SHR表示共享内存大小,12m。从这些判断java虚拟机不存在,内存使用率占13.9%,不存在内存不够的情况。

分析mysql 虚拟内存总大小为1178m,闲置虚拟内存117.共共享内存3456。内存使用率占3.1%,不存在内存不够的情况。

 

还爆出如下异常:

[org.springframework.web.servlet.DispatcherServlet]DispatcherServlet with name 'springMvc' processing GET request for [/nstatsback/101admin/teaching/teaching.do]
[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapping [/101admin/teaching/teaching.do] to HandlerExecutionChain with handler [com.chinaedu.nstats.controller.NStatsController@47217048] and 1 interceptor
[org.springframework.web.servlet.DispatcherServlet]Last-Modified value for [/nstatsback/101admin/teaching/teaching.do] is: -1
[org.springframework.web.bind.annotation.support.HandlerMethodInvoker]Invoking request handler method: public void com.chinaedu.nstats.controller.NStatsController.teaching(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException
java.lang.NullPointerException
[org.springframework.jdbc.datasource.DataSourceUtils]Fetching JDBC Connection from DataSource
[com.mchange.v2.resourcepool.BasicResourcePool]trace com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7 [managed: 8, unused: 7, excluded: 0] (e.g. com.mchan                                                                                                 ge.v2.c3p0.impl.NewPooledConnection@3c7173bf)
[org.springframework.jdbc.datasource.DataSourceUtils]Returning JDBC Connection to DataSource
[com.mchange.v2.resourcepool.BasicResourcePool]trace com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7 [managed: 8, unused: 7, excluded: 0] (e.g. com.mchan.v2.c3p0.impl.NewPooledConnection@3c7173bf)
[org.springframework.jdbc.datasource.DataSourceUtils]Fetching JDBC Connection from DataSource
[com.mchange.v2.resourcepool.BasicResourcePool]trace com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7 [managed: 8, unused: 7, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@3c7173bf)
[org.springframework.jdbc.datasource.DataSourceUtils]Returning JDBC Connection to DataSource
[com.mchange.v2.resourcepool.BasicResourcePool]trace com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7 [managed: 8, unused: 7, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@3c7173bf)
[com.mchange.v2.c3p0.impl.NewProxyConnection]com.mchange.v2.c3p0.impl.NewProxyConnection@456e5122: close() called more than once.
[org.springframework.web.servlet.DispatcherServlet]Null ModelAndView returned toDispatcherServlet with name 'springMvc': assuming HandlerAdapter completed request handling
[org.springframework.web.servlet.DispatcherServlet]Successfully completed request
[com.mchange.v2.resourcepool.BasicResourcePool]Refurbishing idle resources - Mon May 04 16:16:30 CST 2015 [com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7]
[com.mchange.v2.resourcepool.BasicResourcePool]trace com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7 [managed: 8, unused: 8, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@3c7173bf)
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@3b27e6c4] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@704f8e8e] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@38a2aba4] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@704f8e8e] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@498538c1] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@3b27e6c4] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@1295eede] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@38a2aba4] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@34e920c8] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@498538c1] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@5848ddac] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@1295eede] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@403d1c18] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@34e920c8] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@5848ddac] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@403d1c18] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.resourcepool.BasicResourcePool]Refurbishing idle resources - Mon May 04 16:17:30 CST 2015 [com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7]
[com.mchange.v2.resourcepool.BasicResourcePool]trace com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7 [managed: 8, unused: 8, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@3c7173bf)
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@3b27e6c4] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@38a2aba4] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@704f8e8e] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@38a2aba4] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@704f8e8e] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@498538c1] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@3b27e6c4] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@34e920c8] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@1295eede] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@498538c1] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@5848ddac] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@34e920c8] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@403d1c18] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@5848ddac] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@1295eede] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@403d1c18] on IDLE CHECK has SUCCEEDED.
loginFilter end
update gm_login_log  SET user_id =?,  u_num =?,  ip =?,  class_id =?,  semester_code =?,  login_time =?,  school_id =?,  create_time =?,  create_user =?,  modify_time =?,  modify_user =?,  delete_flag =?,  school_code =?,   check_time =?,  stay_time =?, role_code =?  where id=?
[com.mchange.v2.resourcepool.BasicResourcePool]Checking for expired resources - Mon May 04 16:18:00 CST 2015 [com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7]
[com.mchange.v2.resourcepool.BasicResourcePool]BEGIN check for expired resources.  [com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7]
[com.mchange.v2.resourcepool.BasicResourcePool]FINISHED check for expired resources.  [com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7]
[com.mchange.v2.resourcepool.BasicResourcePool]Refurbishing idle resources - Mon May 04 16:18:30 CST 2015 [com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7]
[com.mchange.v2.resourcepool.BasicResourcePool]trace com.mchange.v2.resourcepool.BasicResourcePool@75b67ac7 [managed: 8, unused: 8, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@3c7173bf)
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@3b27e6c4] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@38a2aba4] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@704f8e8e] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@704f8e8e] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@498538c1] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@3b27e6c4] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@1295eede] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@38a2aba4] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@34e920c8] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@498538c1] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@5848ddac] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@1295eede] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@403d1c18] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@5848ddac] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@34e920c8] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@403d1c18] on IDLE CHECK has SUCCEEDED.

更多linux top命令参考文章http://www.jb51.net/LINUXjishu/34604.html

 

 

Linux系统的物理cpu数、核数、逻辑cpu个数查看

 

# 总核数 = 物理CPU个数 X 每颗物理CPU的核数 
# 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数

# 查看物理CPU个数
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep "cpu cores"| uniq

# 查看逻辑CPU的个数
cat /proc/cpuinfo| grep "processor"| wc -l

# 查看CPU信息(型号)
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c