人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

Linux mpstat命令的方法(實(shí)時(shí)系統(tǒng)監(jiān)控工具)

發(fā)布日期:2021-12-24 00:29 | 文章來源:CSDN

簡介

mpstat是Multiprocessor Statistics的縮寫,是實(shí)時(shí)系統(tǒng)監(jiān)控工具。其報(bào)告與CPU的一些統(tǒng)計(jì)信息,這些信息存放在/proc/stat文件中。在多CPUs系統(tǒng)里,其不但能查看所有CPU的平均狀況信息,而且能夠查看特定CPU的信息。mpstat最大的特點(diǎn)是:可以查看多核心cpu中每個(gè)計(jì)算核心的統(tǒng)計(jì)數(shù)據(jù);而類似工具vmstat只能查看系統(tǒng)整體cpu情況。

mpstat命令指令主要用于多CPU環(huán)境下,它顯示各個(gè)可用CPU的狀態(tài)系你想。這些信息存放在/proc/stat文件中。在多CPUs系統(tǒng)里,其不但能查看所有CPU的平均狀況信息,而且能夠查看特定CPU的信息。

語法

mpstat(選項(xiàng))(參數(shù))

mpstat [-P {|ALL}] [internal [count]]
參數(shù) 解釋
-P {|ALL} 表示監(jiān)控哪個(gè)CPU, cpu在[0,cpu個(gè)數(shù)-1]中取值
internal 相鄰的兩次采樣的間隔時(shí)間、
count 采樣的次數(shù),count只能和delay一起使用
當(dāng)沒有參數(shù)時(shí),mpstat則顯示系統(tǒng)啟動(dòng)以后所有信息的平均值。有interval時(shí),第一行的信息自系統(tǒng)啟動(dòng)以來的平均信息。從第二行開始,輸出為前一個(gè)interval時(shí)間段的平均信息。

選項(xiàng)

-P:指定CPU編號。

參數(shù)

間隔時(shí)間:每次報(bào)告的間隔時(shí)間(秒);

次數(shù):顯示報(bào)告的次數(shù)。

實(shí)例

當(dāng)mpstat不帶參數(shù)時(shí),輸出為從系統(tǒng)啟動(dòng)以來的平均值。

mpstat
Linux 2.6.9-5.31AXsmp (builder.redflag-linux.com) 12/16/2005
09:38:46 AM CPU %user %nice %system %iowait %irq %soft %idle intr/s
09:38:48 AM all 23.28 0.00 1.75  0.50 0.00 0.00 74.47 1018.59

每2秒產(chǎn)生了2個(gè)處理器的統(tǒng)計(jì)數(shù)據(jù)報(bào)告:

下面的命令可以每2秒產(chǎn)生了2個(gè)處理器的統(tǒng)計(jì)數(shù)據(jù)報(bào)告,一共產(chǎn)生三個(gè)interval 的信息,然后再給出這三個(gè)interval的平均信息。默認(rèn)時(shí),輸出是按照CPU 號排序。第一個(gè)行給出了從系統(tǒng)引導(dǎo)以來的所有活躍數(shù)據(jù)。接下來每行對應(yīng)一個(gè)處理器的活躍狀態(tài)。

mpstat -P ALL 2 3
Linux 2.6.18-164.el5 (server.sys.com) 01/04/2010
09:34:20 PM CPU%user%nice %sys %iowait %irq%soft %steal%idle intr/s
09:34:22 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.001001.49
09:34:22 PM 0 0.00 0.00 0.50 0.00 0.00 0.00 0.0099.501001.00
09:34:22 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.000.00

比較帶參數(shù)和不帶參數(shù)的mpstat的結(jié)果:

在后臺(tái)開一個(gè)2G的文件

cat 1.img &

然后在另一個(gè)終端運(yùn)行mpstat命令

mpstat
Linux 2.6.18-164.el5 (server.sys.com) 01/04/2010
10:17:31 PM CPU%user%nice %sys %iowait %irq%soft %steal%idle intr/s
10:17:31 PM all 0.07 0.02 0.25 0.21 0.01 0.04 0.0099.401004.57

mpstat
Linux 2.6.18-164.el5 (server.sys.com) 01/04/2010
10:17:35 PM CPU%user%nice %sys %iowait %irq%soft %steal%idle intr/s
10:17:35 PM all 0.07 0.02 0.25 0.21 0.01 0.04 0.0099.391004.73

mpstat 3 10
Linux 2.6.18-164.el5 (server.sys.com) 01/04/2010
10:17:55 PM CPU%user%nice %sys %iowait %irq%soft %steal%idle intr/s
10:17:58 PM all13.12 0.0020.93 0.00 1.83 9.80 0.0054.322488.08
10:18:01 PM all10.82 0.0019.30 0.83 1.83 9.32 0.0057.902449.83
10:18:04 PM all10.95 0.0020.40 0.17 1.99 8.62 0.0057.882384.05
10:18:07 PM all10.47 0.0018.11 0.00 1.50 8.47 0.0061.462416.00
10:18:10 PM all11.81 0.0022.63 0.00 1.8311.98 0.0051.752210.60
10:18:13 PM all 6.31 0.0010.80 0.00 1.00 5.32 0.0076.581795.33
10:18:19 PM all 1.75 0.00 3.16 0.75 0.25 1.25 0.0092.851245.18
10:18:22 PM all11.94 0.0019.07 0.00 1.99 8.29 0.0058.712630.46
10:18:25 PM all11.65 0.0019.30 0.50 2.00 9.15 0.0057.402673.91
10:18:28 PM all11.44 0.0021.06 0.33 1.9910.61 0.0054.562369.87
Average:  all 9.27 0.0016.18 0.30 1.50 7.64 0.0065.112173.54

上兩表顯示出當(dāng)要正確反映系統(tǒng)的情況,需要正確使用命令的參數(shù)。vmstat 和iostat 也需要注意這一問題。

查看多核CPU核心的當(dāng)前運(yùn)行狀況信息, 每2秒更新一次

mpstat  219:45:12 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
19:45:14 all 0.04 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.96
19:45:16 all 0.00 0.00 0.00 0.03 0.00 0.00 0.00 0.00 99.97
19:45:18 all 0.00 0.07 0.07 0.00 0.00 0.00 0.00 0.00 99.87

如果要看每個(gè)cpu核心的詳細(xì)當(dāng)前運(yùn)行狀況信息,輸出如下:

mpstat  -P ALL 2
 
19:43:58  CPU %usr%nice %sys %iowait %irq%soft  %steal  %guest%idle
19:43:59  all 0.00 0.00 0.04 0.00 0.00 0.00 0.00 0.0099.96
19:43:59 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00  100.00
19:43:59 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00  100.00
.......
19:43:5913 0.99 0.00 0.00 0.00 0.00 0.00 0.00 0.0099.01
19:43:5914 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00  100.00
19:43:5915 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00  100.00

字段的含義如下

%user在internal時(shí)間段里,用戶態(tài)的CPU時(shí)間(%),不包含nice值為負(fù)進(jìn)程  (usr/total)*100
%nice在internal時(shí)間段里,nice值為負(fù)進(jìn)程的CPU時(shí)間(%)(nice/total)*100
%sys 在internal時(shí)間段里,內(nèi)核時(shí)間(%) (system/total)*100
%iowait 在internal時(shí)間段里,硬盤IO等待時(shí)間(%) (iowait/total)*100
%irq 在internal時(shí)間段里,硬中斷時(shí)間(%)  (irq/total)*100
%soft在internal時(shí)間段里,軟中斷時(shí)間(%)  (softirq/total)*100
%idle在internal時(shí)間段里,CPU除去等待磁盤IO操作外的因?yàn)槿魏卧蚨臻e的時(shí)間閑置時(shí)間(%) (idle/total)*100

計(jì)算公式如下

total_cur=user+system+nice+idle+iowait+irq+softirq
total_pre=pre_user+ pre_system+ pre_nice+ pre_idle+ pre_iowait+ pre_irq+ pre_softirq
user=user_cur – user_pre
total=total_cur-total_pre
其中_cur 表示當(dāng)前值,_pre表示interval時(shí)間前的值。上表中的所有值可取到兩位小數(shù)點(diǎn)。

好了,這篇文章就介紹到這了,希望大家以后多多支持本站。

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部