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

linux的top命令分析问题

程序员文章站 2022-06-20 09:04:59
...

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

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

 

[[email protected]_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 [[email protected]] 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 [email protected] [managed: 8, unused: 7, excluded: 0] (e.g. com.mchan                                                                                                 [email protected])
[org.springframework.jdbc.datasource.DataSourceUtils]Returning JDBC Connection to DataSource
[com.mchange.v2.resourcepool.BasicResourcePool]trace [email protected] [managed: 8, unused: 7, excluded: 0] (e.g. [email protected])
[org.springframework.jdbc.datasource.DataSourceUtils]Fetching JDBC Connection from DataSource
[com.mchange.v2.resourcepool.BasicResourcePool]trace [email protected] [managed: 8, unused: 7, excluded: 0] (e.g. [email protected])
[org.springframework.jdbc.datasource.DataSourceUtils]Returning JDBC Connection to DataSource
[com.mchange.v2.resourcepool.BasicResourcePool]trace [email protected] [managed: 8, unused: 7, excluded: 0] (e.g. [email protected])
[com.mchange.v2.c3p0.impl.NewProxyConnection][email protected]: 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 [[email protected]]
[com.mchange.v2.resourcepool.BasicResourcePool]trace [email protected] [managed: 8, unused: 8, excluded: 0] (e.g. [email protected])
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.resourcepool.BasicResourcePool]Refurbishing idle resources - Mon May 04 16:17:30 CST 2015 [[email protected]]
[com.mchange.v2.resourcepool.BasicResourcePool]trace [email protected] [managed: 8, unused: 8, excluded: 0] (e.g. [email protected])
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] 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 [[email protected]]
[com.mchange.v2.resourcepool.BasicResourcePool]BEGIN check for expired resources.  [[email protected]]
[com.mchange.v2.resourcepool.BasicResourcePool]FINISHED check for expired resources.  [[email protected]]
[com.mchange.v2.resourcepool.BasicResourcePool]Refurbishing idle resources - Mon May 04 16:18:30 CST 2015 [[email protected]]
[com.mchange.v2.resourcepool.BasicResourcePool]trace [email protected] [managed: 8, unused: 8, excluded: 0] (e.g. [email protected])
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Testing PooledConnection [[email protected]] on IDLE CHECK.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] on IDLE CHECK has SUCCEEDED.
[com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool]Test of PooledConnection [[email protected]] 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