Java 系统性能分析 命令

1. cpu分析
top , pidstat(sysstat)
pid -p PID -t 1 10
vmstat 1 CPU上下文切换、运行队列、利用率
ps Hh -eo tid
pcpu 查看具体线程的CPU消耗
sar 来查看一定世界范围内以及历史的cpu消耗情况信息

查看java线程信息
jstack pid | grep 'nid=0x9999'

2. cs sy消耗比较高
上下文切换性能偏高, jstack -l pid, 查看on object monitor

3. io消耗
pidstat -d -t -p pid 1 100
iostat

4. 网络io消耗
cat /proc/interruptes
sar -n FULL 1 2
tcpdump

http://www.cnblogs.com/lidabo/p/4738113.html

近期java应用,CPU使用率一直很高,经常达到100%,通过以下步骤完美解决,分享一下。

方法一:

转载:http://www.linuxhot.com/java-cpu-used-high.html

1.jps 获取Java进程的PID。
2.jstack pid >> java.txt 导出CPU占用高进程的线程栈。
3.top -H -p PID 查看对应进程的哪个线程占用CPU过高。
4.echo “obase=16; PID” | bc 将线程的PID转换为16进制,大写转换为小写。
5.在第二步导出的Java.txt中查找转换成为16进制的线程PID。找到对应的线程栈。
6.分析负载高的线程栈都是什么业务操作。优化程序并处理问题。

方法二:

1.使用top 定位到占用CPU高的进程PID
top
通过ps aux | grep PID命令

2.获取线程信息,并找到占用CPU高的线程
ps -mp pid -o THREAD,tid,time | sort -rn
譬如:

ps -mp  -o THREAD,tid,time | sort -rn

3.将需要的线程ID转换为16进制格式
printf "%x\n" tid

4.打印线程的堆栈信息
jstack pid |grep tid -A 30

http://www.cnblogs.com/pangguoping/p/5715848.html

一、统计sleep状态的进程.

c233 plugins # ps -elf|head -1
F S UID     PID   PPID C PRI   NI       ADDR   SZ    WCHAN    STIME TTY TIME     CMD
root 28149  4204    0 80     0             -       16283    poll_s       Jul05 ? 00:00:00   sshd: root

c233 plugins # ps -efl|awk '$2~/S/{print $0}'|wc -l                     //-l              long format. 
73
解释===>
(1)F列.

PROCESS FLAGS
The sum of these values is displayed in the "F" column, which is provided by the flags output specifier.
1 forked but didn't exec
4 used super-user privileges

(1)S列.

D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.

(3)C列.C     pcpu         cpu utilization

(4)

command    COMMAND  see args. (alias args, cmd).

sz                    SZ       size in physical pages of the core image of the process. This
includes text, data, and stack space. Device mappings are currently
excluded; this is subject to change. See vsz and rss.

(5)WCHAN列.

wchan           WCHAN     name of the kernel function in which the process is sleeping,
a "-" if the process is running, or a "*" if the process is
multi-threaded and ps is not displaying threads.

二、统计当前运行的线程总数."-L"

c233 plugins # ps -eLf|grep -v $$|wc -l                                  //-L              Show threads, possibly with LWP and NLWP columns

646

c233 plugins # ps -eLf|grep -v $$|tail

UID        PID    PPID    LWP    C   NLWP   STIME TTY   TIME     CMD

root   23678    1    688    0    36      Jul01 ? 00:00:06   /usr/sbin/nscd
root   23678    1    689    0    36      Jul01 ? 00:00:06   /usr/sbin/nscd
root   23678    1    690    0    36      Jul01 ? 00:00:06   /usr/sbin/nscd
root   23678    1    691    0    36      Jul01 ? 00:00:06     /usr/sbin/nscd
root   23678    1    692    0    36      Jul01 ? 00:00:06     /usr/sbin/nscd
root   23678    1    693    0    36      Jul01 ? 00:00:06     /usr/sbin/nscd
root   23678    1    694    0    36      Jul01 ? 00:00:06     /usr/sbin/nscd
root   23678    1    695    0    36      Jul01 ? 00:00:06     /usr/sbin/nscd
root   23678    1    696    0    36    Jul01 ? 00:00:06     /usr/sbin/nscd
root   28149    4204 28149   0    1        Jul05 ? 00:00:00     sshd: root

NLWP (number of threads)

LWP (thread ID)

c233 plugins # ps -ef|grep nscd
root 23678 1 0 Jun30 ? 00:15:32 /usr/sbin/nscd

三、Linux下查看某个进程的线程数量.

1.根据进程号进行查询:

# pstree -p 进程号      //-p pid

# top -Hp 进程号        //-H : Threads toggle

2.根据进程名字进行查询:

# pstree -p `ps -e | grep sshd | awk '{print $1}'`

# pstree -p `ps -e | grep sshd | awk '{print $1}'` | wc -l

http://www.cnblogs.com/itcomputer/p/4652140.html

003_监测域名证书过期时间
由于因为线上证书过期,出过比较大的事故,所以就有了如下的监测证书过期的脚本

#!/bin/sh
### SSL Certificate Expire Day Check Script ###
if [ "$1" = '' ];then
echo "Need URL."
exit
;fi
TARGET_URL=$
EXP_DAY=`openssl s_client -connect ${TARGET_URL}: < /dev/null > /dev/null | openssl x509 -text > /dev/null | grep "Not After" | sed -e 's/^ *//g' | cut -d " " -f ,,,,`
NOW_TIME=`date +%s`
EXP_TIME=`date +%s -d "${EXP_DAY}"`
if [ "${EXP_DAY}" != '' -a ${NOW_TIME} -lt ${EXP_TIME} ]; then
echo $(((EXP_TIME-NOW_TIME)/(**)))
else
echo "ERROR"
exit ;
fi

http://www.cnblogs.com/itcomputer/p/7192734.html

Linux通过PID查看进程完整信息

说明
通过ps及top命令查看进程信息时,只能查到相对路径,查不到的进程的详细信息,如绝对路径等。

先通过top查看进程PID

这时,我们需要通过以下的方法来查看进程的详细信息:

Linux在启动一个进程时,系统会在/proc下创建一个以PID命名的文件夹,在该文件夹下会有我们的进程的信息,其中包括一个名为exe的文件即记录了绝对路径,通过ll或ls –l命令即可查看。

ll /proc/PID

解释
cwd符号链接的是进程运行目录;

exe符号连接就是执行程序的绝对路径;

cmdline就是程序运行时输入的命令行命令;

environ记录了进程运行时的环境变量;

fd目录下是进程打开或使用的文件的符号连接。

https://www.jianshu.com/p/383b998b77d0

Linux下如何查看高CPU占用率线程 专题的更多相关文章

  1. Linux下如何查看高CPU占用率线程

    转于:http://www.cnblogs.com/lidabo/p/4738113.html 目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidst ...

  2. Linux下如何查看高CPU占用率线程 LINUX CPU利用率计算

    目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidstat文件 procpidtasktidstat文件 系统中有关进程cpu使用率的常用命令 ps ...

  3. (笔记)Linux下如何查看高CPU占用率线程

    在 Linux 下 top 工具可以显示 cpu 的平均利用率(user,nice,system,idle,iowait,irq,softirq,etc.),可以显示每个 cpu 的利用率.但是无法显 ...

  4. Linux下如何查看高CPU占用率线程 LINUX CPU利用率计算(转)

    Java 系统性能分析 命令 1. cpu分析 top , pidstat(sysstat) pid -p PID -t 1 10 vmstat 1 CPU上下文切换.运行队列.利用率 ps Hh - ...

  5. Linux下分析某个进程CPU占用率高的原因

      Linux下分析某个进程CPU占用率高的原因 通过top命令找出消耗资源高的线程id,利用strace命令查看该线程所有系统调用  1.top 查到占用cpu高的进程pid 2.查看该pid的线程 ...

  6. linux top命令中各cpu占用率含义

    linux top命令中各cpu占用率含义 [尊重原创文章摘自:http://www.iteye.com/topic/1137848]0.3% us 用户空间占用CPU百分比 1.0% sy 内核空间 ...

  7. (转)linux top命令中各cpu占用率含义及案例分析

    原文:https://blog.csdn.net/ydyang1126/article/details/72820349 linux top命令中各cpu占用率含义 0 性能监控介绍 1 确定应用类型 ...

  8. Visual Studio 2013 Ultimate因为CodeLens功能导致Microsoft.Alm.Shared.Remoting.RemoteContainer.dll高CPU占用率的折中解决方案

    1.为什么Microsoft.Alm.Shared.Remoting.RemoteContainer.dll的CPU占用率以及内存使用率会那么高? 在Visual Studio 2013 Ultima ...

  9. [项目机会]citrix 虚拟桌面对于java等高CPU占用率如何解决

    citrix 虚拟桌面对于java等高CPU占用率如何解决 问题1:java等客户端对于虚拟桌面cpu影响较大,但是有些用户的确需要使用java支持的程序,是否可以通过其他途径来解决? 问题2:对于其 ...

随机推荐

  1. 【codeforces 752F】Santa Clauses and a Soccer Championship

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【a601】雇佣计划

    Time Limit: 1 second Memory Limit: 32 MB [问题描述] 一位管理项目的经理想要确定每个月需要的工人,他知道每月所需的最少工人数.当他雇佣或解雇一个工人时,会有一 ...

  3. python2代码转换python3(2018新)

    Python 3自带了一个叫做2to3.py,这个脚本会将你的Python 2程序源文件作为输入,然后自动将其转换到Python 3的形式,可进行to3.py -w 文件夹路径 若文件名2to3-sc ...

  4. 【22.73%】【codeforces 606D】Lazy Student

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【a302】&&【9306】贮油点问题

    Time Limit: 1 second Memory Limit: 2 MB 问题描述 一辆重型卡车欲穿过1000公里的沙漠,卡车耗油为1升/公里,卡车总载油能力为500公升.显然卡车装 一次油是过 ...

  6. JTextpane 加入的行号

    最近项目需求,在需求JTextPane加入行号等信息,网上找了半天才发现JTextArea加入行号信息.copy正在研究在线程序.他发现自己能够做出改变来改变JTextPane显示行号. 代码: pa ...

  7. TstringBuilder Delphi2007版

    2010中的StringBuilder对象用的比较爽快!于是稍作了一些修改(增加了几个函数和属性)然后移植到D2007中来使用了!效果不错,共享一下! unit DxStringBuilder; in ...

  8. Struts2——(5)转发和重定向(跨业务模块)

    一.重定向redirect(默认是转发dispatcher)和转发的区别? 1.重定向浏览器的网址发生变化(相当于请求了两次),转发浏览器的网址不发生变化(只请求了一次). 2.重定向的过程:发送请求 ...

  9. java基础篇---文件上传(组件)

    转载自:http://www.cnblogs.com/oumyye/p/4234969.html 文件上传几乎是所有网站都具有的功能,用户可以将文件上传到服务器的指定文件夹中,也可以保存在数据库中,本 ...

  10. android高仿人人网

    经过几个月的努力,终于基本完成了人人API拥有的所有功能,界面采用仿照人人梦想版5.13制作,其中资源文件也采用人人的APK文件资源,完成的功能及知识点如下: 1.通过三种动画仿照出人人引导页的放大切 ...