Linux常用效能分析命令
效能分析
vmstat
虛擬記憶體統計
用法
Usage:
vmstat [options] [delay [count]]
Options:
-a, --active active/inactive memory
-f, --forks number of forks since boot
-m, --slabs slabinfo
-n, --one-header do not redisplay header
-s, --stats event counter statistics
-d, --disk disk statistics
-D, --disk-sum summarize disk statistics
-p, --partition <dev> partition specific statistics
-S, --unit <char> define display unit
-w, --wide wide output
-t, --timestamp show timestamp
-h, --help display this help and exit
-V, --version output version information and exit
示例
[[email protected] ~]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 71256 92720 0 565120 0 0 1 115 22 36 1 0 99 0 0
其中
- r : 執行和等待 CPU 時間片的程序數。若該值大於系統 CPU 個數,則說明 CPU 不足
- b : 表示等待資源的程序數
- swpd : 切換到記憶體交換區的記憶體大小(單位 KB)
- free: 空閒的實體記憶體的大小,我的機器記憶體總共2G,剩餘92M。
- buff: Linux/Unix系統是用來儲存,目錄裡面有什麼內容,許可權等的快取
- cache:直接用來記憶我們開啟的檔案,給檔案做緩衝,把空閒的實體記憶體的一部分拿來做檔案和目錄的快取,是為了提高 程式執行的效能,當程式使用記憶體時,buffer/cached會很快地被使用
- si:每秒從磁碟讀入虛擬記憶體的大小,如果這個值大於0,表示實體記憶體不夠用或者記憶體洩露了,要查詢耗記憶體程序解決掉。
- so:每秒虛擬記憶體寫入磁碟的大小,如果這個值大於0,同上。
- bi:塊裝置每秒接收的塊數量(讀磁碟)(kb/s)
- bo:塊裝置每秒傳送的塊數量(寫磁碟)(kb/s)
- in:每秒CPU的中斷次數,包括時間中斷
- cs:每秒上下文切換次數。
- us:使用者程序消耗 CPU 時間百分比
- sy:核心程序消耗 CPU 時間百分比,sy 的值較高時,則說明核心消耗的 CPU 資源很多
- id:空閒 CPU 時間百分比
- wt:IO 等待 CPU 時間百分比
free
記憶體使用狀況
[[email protected] ~]# free
total used free shared buff/cache available
Mem: 1849336 1193336 90344 1752 565656 460000
Swap: 2097148 71248 2025900
[[email protected] ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 1.1G 88M 1.7M 552M 449M
Swap: 2.0G 69M 1.9G
[[email protected] ~]# free -m
total used free shared buff/cache available
Mem: 1805 1165 88 1 552 449
Swap: 2047 69 1978
[[email protected] ~]# free -h 2
total used free shared buff/cache available
Mem: 1.8G 1.1G 88M 1.7M 552M 449M
Swap: 2.0G 69M 1.9G
[[email protected] ~]# free -h -s 2
total used free shared buff/cache available
Mem: 1.8G 1.1G 88M 1.7M 552M 449M
Swap: 2.0G 69M 1.9G
total used free shared buff/cache available
Mem: 1.8G 1.1G 88M 1.7M 552M 449M
Swap: 2.0G 69M 1.9G
total used free shared buff/cache available
Mem: 1.8G 1.1G 88M 1.7M 552M 449M
Swap: 2.0G 69M 1.9G
uptime
統計當前系統的執行情況
[[email protected] ~]# uptime
09:59:55 up 2 days, 7 min, 1 user, load average: 0.00, 0.01, 0.05
load average: 系統 1分鐘,5分鐘,15分鐘的平均負荷
netstat
當前網路資訊
用法
usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}
netstat [-vWnNcaeol] [<Socket> ...]
netstat { [-vWeenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay]
-r, --route display routing table
-I, --interfaces=<Iface> display interface table for <Iface>
-i, --interfaces display interface table
-g, --groups display multicast group memberships
-s, --statistics display networking statistics (like SNMP)
-M, --masquerade display masqueraded connections
-v, --verbose be verbose
-W, --wide don't truncate IP addresses
-n, --numeric don't resolve names
--numeric-hosts don't resolve host names
--numeric-ports don't resolve port names
--numeric-users don't resolve user names
-N, --symbolic resolve hardware names
-e, --extend display other/more information
-p, --programs display PID/Program name for sockets
-o, --timers display timers
-c, --continuous continuous listing
-l, --listening display listening server sockets
-a, --all display all sockets (default: connected)
-F, --fib display Forwarding Information Base (default)
-C, --cache display routing cache instead of FIB
-Z, --context display SELinux security context for sockets
<Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-w|--raw} {-x|--unix}
--ax25 --ipx --netrom
<AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet
List of possible address families (which support routing):
inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)
netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)
x25 (CCITT X.25)
其中
- -a (all)顯示所有選項,預設不顯示LISTEN相關
- -t (tcp)僅顯示tcp相關選項
- -u (udp)僅顯示udp相關選項
- -n 拒絕顯示別名,能顯示數字的全部轉化成數字
- -l 僅列出有在 Listen (監聽) 的服務狀態
- -p 顯示建立相關連結的程式名
- -r 顯示路由資訊,路由表
- -e 顯示擴充套件資訊,例如uid等
- -s 按各個協議進行統計
- -c 每隔一個固定時間,執行該netstat命令。
提示:LISTEN和LISTENING的狀態只有用-a或者-l才能看到
top
[[email protected] java_demos]# top
top - 14:36:14 up 2 days, 4:43, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 110 total, 2 running, 108 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.2 sy, 0.0 ni, 99.3 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1849336 total, 963348 free, 542372 used, 343616 buff/cache
KiB Swap: 2097148 total, 2011496 free, 85652 used. 1126908 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1858 mysql 20 0 1465504 200800 6212 S 1.0 10.9 34:56.46 mysqld
1 root 20 0 56636 4308 2808 S 0.0 0.2 0:02.05 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.04 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:01.53 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root rt 0 0 0 0 S 0.0 0.0 0:00.07 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/0
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/1
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/2
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/3
13 root 20 0 0 0 0 S 0.0 0.0 0:14.63 rcu_sched
14 root 20 0 0 0 0 S 0.0 0.0 0:10.43 rcuos/0
15 root 20 0 0 0 0 S 0.0 0.0 0:04.67 rcuos/1
其中
第一行:
- 14:36:14 當前系統時間
- days, 4:43 系統已經運行了2天4小時43分鐘(在這期間沒有重啟過)
- 1 users 當前有1個使用者登入系統
- load average: 0.00, 0.01, 0.05 ,後面的三個數分別是1分鐘、5分鐘、15分鐘的負載情況。load average資料是每隔5秒鐘檢查一次活躍的程序數,然後按特定演算法計算出的數值。如果這個數除以邏輯CPU的數量,結果高於5的時候就表明系統在超負荷運轉了。
第二行:Tasks 任務(程序),
- 系統現在共有10個程序,其中處於執行中的有2個,108個在休眠(sleep),stoped狀態的有0個,zombie狀態(殭屍)的有0個。
第三行:cpu狀態
- us 使用者空間佔用CPU的百分比
- sy 核心空間佔用CPU的百分比
- ni 改變過優先順序的程序佔用CPU的百分比
- id 空閒CPU百分比
- wa IO等待佔用CPU的百分比
- hi 硬中斷(Hardware IRQ)佔用CPU的百分比
- si 軟中斷(Software Interrupts)佔用CPU的百分比
第四行:記憶體狀態
- total 實體記憶體總量
- free 空閒記憶體總量
- used 使用中的記憶體總量
- buff/cache 快取的記憶體量
第五行:swap交換分割槽
- total 交換區總量
- free 空閒交換區總量
- used 使用的交換區總量
- avail Mem 緩衝的交換區總量
第六行:各程序(任務)的狀態監控
- PID 程序id
- USER 程序所有者
- PR 程序優先順序
- NI nice值。負值表示高優先順序,正值表示低優先順序
- VIRT 程序使用的虛擬記憶體總量,單位kb。VIRT=SWAP+RES
- RES 程序使用的、未被換出的實體記憶體大小,單位kb。RES=CODE+DATA
- SHR 共享記憶體大小,單位kb
- S 程序狀態。D=不可中斷的睡眠狀態 R=執行 S=睡眠 T=跟蹤/停止 Z=殭屍程序
- %CPU 上次更新到現在的CPU時間佔用百分比
- %MEM 程序使用的實體記憶體百分比
- TIME+ 程序使用的CPU時間總計,單位1/100秒
- COMMAND 程序名稱(命令名/命令列)
監控java執行緒數:
ps -eLf grep java wc -l
監控網路客戶連線數:
netstat -n grep tcp grep 偵聽埠 wc -l
相關推薦
Linux常用效能分析命令
效能分析 vmstat 虛擬記憶體統計 用法 Usage: vmstat [options] [delay [count]] Options: -a, --active active/inactive memory -f, --forks
Linux網路效能分析命令
本節介紹的工具列於下表中。 Linux Solaris 描述 netstat netstat 多種網路棧和介面統計資訊 sar - 統計資訊歷史 ifconfig ifconfig 介面配置 ip
常用的Linux伺服器效能檢視命令
命令名稱 說明 top 程序監控命令,用來監控系統的整體效能。 可以顯示系統負載,程序,cpu,記憶體,分頁等資訊,常用shift+m和shift+p來按memory和cpu使用對程序進行排序。 vmstat 系統監控
Linux常用網絡命令總結
linuxLinux常用網絡命令總結一、手動/自動配置IP參數與氣動/關閉網絡接口:ifcofig、ifup、ifdown1、ifconfig 手動啟動、查看與修改網絡接口的相關參數,可以修改的參數有很多,包括ip參數以及MTU等。 語法:1) ifconfig interface {up|dow
bash命令快捷鍵,linux常用到的命令行
alias命令 文件中 引用 bashrc 實現 ctrl+ history ctr string bash命令行的一些快捷鍵: ctrl +a:跳到命令行首 ctrl+e:跳到命令行尾 ctrl+d:刪除鍵 ctrl+u:刪除光標至命令行首 ctrl +k:刪除光標至命令
Linux 常用操作及命令
linux 命令 1. 什麽是linux服務器load average?Load是用來度量服務器工作量的大小,即計算機cpu任務執行隊列的長度,值越大,表明包括正在運行和待運行的進程數越多。參考資料:http://en.wikipedia.org/wiki/Load_average2. 如何查看lin
Linux 常用 150 個命令
空間 輸入 chattr rac dig lsof 2tb direct 基礎 命令 功能說明 線上查詢及幫助命令 (2 個) man 查看命令幫助,命令的詞典,更復雜的還有 info,但不常用。 help 查看 Linux 內置
簡單的介紹下linux 常用的操作命令
linux 簡單操作 # 首先給大家介紹一下 vim文本編輯器 # 它主要的是創建文件,文檔,對文檔,文件進行編輯,例如:windows中的,txt文件,doc文件等等,//可以給文件寫入內容 # 舉個簡單的例子: vim a
Linux常用查找命令
whereis min 特殊文件 顯示 小寫 二進制 pos test 原因 find find使用基本格式如下 find <指定目錄> <指定條件> <指定動作> 以下是幾個示例,搜索範圍包括指定目錄和子目錄 // 在根目錄下查找文件名
Linux常用網絡命令
term create 創建 關於 連續 管道 接口 點擊 -s 網絡和監控命令類似於這些: hostname, ping, ifconfig, iwconfig, netstat, nslookup, traceroute, finger, telnet, ethtool
Linux常用20條命令
執行時間 chown命令 信息 判斷 連接 差異 ati 現在 出了 玩過Linux的人都會知道,Linux中的命令的確是非常多,但是玩過Linux的人也從來不會因為Linux的命令如此之多而煩惱,因為我們只需要掌握我們最常用的命令就可以了。當然你也可以在使用時去找一下ma
Linux 常用的壓縮命令有 gzip 和 zip
mil 文件解壓 font 不同 .gz 如果 當前 不但 壓縮命令 Linux 常用的壓縮命令有 gzip 和 zip,兩種壓縮包的結尾不同:zip 壓縮的後文件是 *.zip ,而 gzip 壓縮後的文件 *.gz 相應的解壓縮命令則是 gunzip 和 unzip
0x01 RHEL linux 常用的工作命令
提前 shell 進程pid 默認 多進程 處理器 nbsp tao 常見 1.echo命令 echo命令用於在終端輸出字符串或者變量提取後的值。 格式:echo [字符串|變量] 示例:#echo pantao #echo #SHELL 2.dat
0x01-1 RHEL linux 常用的工作命令
linux 常用的工作命令 1.echo命令 echo命令用於在終端輸出字串或者變數提取後的值。 格式:echo [字串|變數] 示例:#echo pantao &n
0x01-3 RHEL linux 常用目錄切換命令
工作目錄指的是使用者當前在系統中所處的位置。由於工作目錄會牽涉系統儲存結構相關的知識。 1.pwd命令 pwd命令用於顯示使用者當前所處的工作目錄,格式為“pwd [選項]”。 2.cd命令 cd命令用於切換工作路徑,格式為“cd [目錄名稱]”。
linux 常用到的命令 刪除 移動 複製 查詢埠 殺死程序 查詢程序
1. 刪除檔案 刪除一個檔案 rm -f 檔案路徑 刪除多個檔案 rm -f 檔案路徑 檔案路徑 ... 刪除資料夾以及資料夾中的檔案 rm -rf 資料夾路徑 刪除多個資料夾以及資料夾中的檔案 rm -rf 資料夾路徑 資料夾路徑 ...
Linux常用檔案管理命令
Linux檔案管理常用命令 常用命令:ls,cd,pwd,mkdir,rmdir,cp,rm,mv,touch,cat,more,less,head,tail,install,stat ls命令 描述:list directory contents 語法:ls [OPTION] ...
## 本篇文章對linux常用的一些命令做一下總結,如有需要補充以及不懂得地方,請在下方留言 適合於linux初學者,以及對命令掌握不牢的用來備忘
本篇文章對linux常用的一些命令做一下總結,如有需要補充以及不懂得地方,請在下方留言 適合於linux初學者,以及對命令掌握不牢的用來備忘一,磁碟管理1.顯示當前目錄位置 pwd2.切換目錄 cd 目錄名3.列出當前目錄下目錄和檔案詳細內容ll只顯示檔名ls二,檔案管理1.建立資料夾 mkdir 資料夾名2
Linux常用打包壓縮命令
簡介 Linux 上常用的壓縮/解壓工具,介紹了zip、rar、tar的使用。 檔案打包和壓縮 Linux 上的壓縮包檔案格式,除了 Windows 最常見的*.zip、*.rar、.7z 字尾的壓縮檔案,還有 .gz、.xz、.bz2、.tar、.tar.gz
linux 常用到的命令 刪除 移動 複製 查詢埠 殺死程序
1. 刪除檔案 刪除一個檔案 rm -f 檔案路徑 刪除多個檔案 rm -f 檔案路徑 檔案路徑 ... 刪除資料夾以及資料夾中的檔案 rm -rf 資料夾路徑