手册页部分 1M: 系统管理命令

退出打印视图

更新时间: 2014 年 7 月
 
 

pgstat(1M)

名称

pgstat - 报告处理器组的利用率统计信息

用法概要

pgstat [-A] [-B core|chip|sys] [-C] [-l] [-p] [-s key | -S key]
	  [-t number] [-T u | d] [-v] [-r string] [-R string]
      [-P pg ...] [-c processor_id... ] [interval [count]]
pgstat -h

描述

pgstat 显示处理器组 (Processor Group, PG) 的利用率统计信息。PG 是一组按共同特征分组到一起的 CPU。

操作系统使用 PG 来表示某些 CPU,这些 CPU 共享与性能相关的硬件,如执行流水线、高速缓存等。这些 PG 组织到一个分层结构中,后者构成了计算机的处理器拓扑模型。在此分层结构中,每个 CPU(导线束)具有一个叶 PG,该 PG 表示与其共享大多数硬件的 CPU。叶 PG 的每个连续父项与该 CPU 共享的硬件逐渐减少,直至到达根 PG。根 PG 包含系统中的所有 CPU,并表示彼此之间共享最少硬件的 CPU 组。(有关 PG 分层结构的示例,请参见下文的“示例”部分。)

如果计算机没有任何性能相关硬件的共享关系,pgstat 将只显示包含系统中所有 CPU 的根 PG。

缺省情况下,pgstat 执行以下操作:

  • 每隔一秒钟测量一次 PG 分层结构中所有 PG 的硬件和软件利用率。

  • 按深度优先顺序显示 PG 的利用率,并使用缩排帮助显示 PG 如何彼此关联。

  • 在每个间隔结束时显示每个 PG 的 ID、共享关系、硬件负载、软件负载和联机 CPU。

间隔和计数可作为参数提供,以指定抽样间隔中的秒数以及测量和显示指定 PG 利用率的次数。

您可以指定选项以进一步调整输出,以特定方式组织输出,以及指定感兴趣的 PG(有关详细信息,请参见下文的“选项”部分)。

不支持给定 PG 的利用率时,将显示连字符 ("-"),利用率不可用时将显示问号 (?)。对于需要使用 CPU 硬件性能计数器测量硬件利用率的系统,可能无法获得硬件利用率,因为 cpc(3CPC) 使用者(如 attributes(5)cputrack(1)dtrace(1M))或者使用 libcpc(3LIB) 的另一个应用程序会使用这些计数器。

选项

支持以下选项:

–A

pgstat 跨越多个间隔运行时显示利用率数据的汇总。

–B core

按核心 ID 划分和显示利用率数据。此选项与 –P 选项不兼容。

–B chip

按芯片 ID 划分和显示利用率数据。此选项与 –P 选项不兼容。

–B sys

按整个系划分和显示利用率数据。此选项与 –P 选项不兼容。

–c processor_id...

显示包含指定 CPU 的 PG 的利用率。可以通过逗号分隔的 CPU ID 列表的形式指定 CPU。使用连字符 ("-") 可以指定连续的 CPU ID 范围(例如,0-3)。

–C

显示每个 PG 中每个 CPU 的利用率。

–h

显示简短帮助消息,并以退出状态 0 退出。

–p

显示与 PG 对应的物理关系。如果某个 PG 具有与整个系统、某个处理器核心或某个芯片相同的 CPU,则会在 PG 共享关系之后的方括号 ("[]") 中显示 systemcorechip

–P pg,...

显示指定 PG 的利用率。可以通过逗号分隔的 PG ID 列表的形式指定多个 PG。使用连字符 ("-") 可以指定连续的 PG ID 范围(例如,0-3)。

–r string1, string2,...

仅显示其共享关系名称与任何指定字符串匹配的 PG 的利用率。字符串可以是完整的关系名称,也可以是一个或多个关系名称的一部分。字符串的匹配不区分大小写。

您可以输入多个 –r 选项,这样可以匹配关系名称与任何指定字符串匹配的所有 PG。

–R string1, string2,...

仅显示其共享关系名称与指定名称不同的 PG 的相关信息。

字符串匹配与上述 –r 选项相同。可以输入多个 –R 选项。

–s key

按指定关键字降序排序输出行。指定关键字可以是以下各项之一:

pg

按 PG ID 排序。

hwload

按硬件利用率排序。

swload

按软件利用率排序。

user

按用户时间排序。

sys

按系统时间排序。

idle

按空闲时间排序。

depth

按 PG 树从根到叶降序排序,深度优先(缺省)。

breadth

按 PG 树从根到叶降序排序,广度优先。

–S key

按指定关键字升序排序输出行。可能的关键字值与 –s 选项相同。

–t number

显示指定整数的最大 PG 数。

–T u | d

采用 Unix 时间(请参见 time(2))或 date(1) 使用的标准日期格式显示每个抽样间隔的时间戳。

–v

显示每个 PG 的附加信息,包括硬件利用率和容量以及软件用户、系统和空闲时间。

输出标题

输出标题

pgstat 会显示列标题,下面列出了这些标题及其含义。

PG

处理器组 ID。

RELATIONSHIP

PG 的共享关系。

HW

硬件负载百分比(针对间隔按 UTIL/CAP 计算)。

UTIL

在间隔内 PG 共享硬件组件的硬件利用率。该数字会很大,因此使用 KMBT 分别表示千、百万、十亿和万亿。

CAP

在间隔内 PG 共享硬件组件的大约最大可能利用率。该数字会很大,因此使用 KMBT 分别表示千、百万、十亿和万亿。

SW

软件负载百分比(按 (USR + SYS) / (USR + SYS + IDLE) 计算)。

USR

间隔时间内软件线程在 PG 的 CPU 中以用户模式运行的时间百分比。

SYS

间隔时间内软件线程在 PG 的 CPU 中以系统模式运行的时间百分比。

IDLE

间隔时间内无任何软件线程在 PG 的 CPU 中运行的时间百分比。

CPUS

PG 中 CPU 的 CPU ID。

示例

在下面的示例中,系统包含一个具有 8 个核心和 32 个导线束的 UltraSPARC T1 处理器芯片。

示例 1 显示指定时间段内的利用率

以下命令显示最后两秒内所有 PG 的利用率。

$ pgstat 1 2
PG  RELATIONSHIP            HW    SW  CPUS
 0  System                   -  0.4%  0-31
 3   Data_Pipe_to_memory     -  0.4%  0-31
 2    Floating_Point_Unit   0%  0.4%  0-31
 1     Integer_Pipeline     0%    0%  0-3
 4     Integer_Pipeline     0%    0%  4-7
 5     Integer_Pipeline     0%    0%  8-11
 6     Integer_Pipeline     0%  0.2%  12-15
 7     Integer_Pipeline     0%    0%  16-19
 8     Integer_Pipeline   2.8%  2.7%  20-23
 9     Integer_Pipeline   0.1%  0.2%  24-27
10     Integer_Pipeline     0%    0%  28-31
PG  RELATIONSHIP            HW    SW  CPUS
 0  System                   -  0.4%  0-31
 3   Data_Pipe_to_memory     -  0.4%  0-31
 2    Floating_Point_Unit   0%  0.4%  0-31
 1     Integer_Pipeline     0%  0.2%  0-3
 4     Integer_Pipeline     0%    0%  4-7
 5     Integer_Pipeline     0%    0%  8-11
 6     Integer_Pipeline     0%    0%  12-15
 7     Integer_Pipeline     0%    0%  16-19
 8     Integer_Pipeline   3.1%  2.5%  20-23
 9     Integer_Pipeline     0%    0%  24-27
10     Integer_Pipeline     0%  0.2%  28-31
示例 2 显示有关整数流水线的信息

以下命令显示最后两秒内利用率最高的两条整数流水线的详细信息。

$ pgstat -v -t 2 -r 'Integer_Pipeline' 1 2
PG  RELATIONSHIP         HW UTIL  CAP     SW    USR    SYS   IDLE CPUS
 1  Integer_Pipeline   0.2% 2.2M 1.4B   0.2%   0.0%   0.2%  99.8% 0-3
 4  Integer_Pipeline  13.1% 181M 1.4B  14.9%   0.0%  14.9%  85.1% 4-7
PG  RELATIONSHIP         HW UTIL  CAP     SW    USR    SYS   IDLE CPUS
 1  Integer_Pipeline   0.2% 1.9M 1.2B   0.2%   0.0%   0.2%  99.8% 0-3
 4  Integer_Pipeline  13.1% 163M 1.2B  14.9%   0.0%  14.9%  85.1% 4-7
示例 3 显示指定时间段内的核心利用率

以下命令显示最后两分钟内核心利用率的信息。

$ pgstat -A 60 2
PG  RELATIONSHIP              HW      SW  CPUS
 0  System                     -   56.9%  0-31
 3   Data_Pipe_to_memory       -   56.9%  0-31
 2    Floating_Point_Unit   0.0%   56.9%  0-31
 1     Integer_Pipeline    36.7%   58.7%  0-3
 4     Integer_Pipeline    41.9%   58.3%  4-7
 5     Integer_Pipeline    31.0%   58.0%  8-11
 6     Integer_Pipeline    30.7%   57.9%  12-15
 7     Integer_Pipeline    30.1%   55.8%  16-19
 8     Integer_Pipeline    40.2%   54.8%  20-23
 9     Integer_Pipeline    35.0%   56.0%  24-27
10     Integer_Pipeline    40.3%   55.8%  28-31
PG  RELATIONSHIP              HW      SW  CPUS
 0  System                     -   10.7%  0-31
 3   Data_Pipe_to_memory       -   10.7%  0-31
 2    Floating_Point_Unit   0.0%   10.7%  0-31
 1     Integer_Pipeline     9.0%   10.7%  0-3
 4     Integer_Pipeline     9.6%   10.8%  4-7
 5     Integer_Pipeline     8.6%    9.9%  8-11
 6     Integer_Pipeline    10.5%   11.9%  12-15
 7     Integer_Pipeline     9.1%   10.4%  16-19
 8     Integer_Pipeline     9.6%   10.9%  20-23
 9     Integer_Pipeline     8.9%   10.0%  24-27
10     Integer_Pipeline     9.5%   10.7%  28-31

       SUMMARY: UTILIZATION OVER 120 SECONDS

                             ------HARDWARE------ ------SOFTWARE------
PG  RELATIONSHIP             MIN    AVG    MAX    MIN    AVG    MAX CPUS
 0  System                     -      -      -  10.7%  10.7%  56.9% 0-31
 3   Data_Pipe_to_memory       -      -      -  10.7%  10.7%  56.9% 0-31
 2    Floating_Point_Unit   0.0%   0.0%   0.0%  10.7%  10.7%  56.9% 0-31
 1     Integer_Pipeline     9.0%   8.5%  36.7%  10.7%  10.7%  58.7% 0-3
 4     Integer_Pipeline     9.6%   9.1%  41.9%  10.8%  10.8%  58.3% 4-7
 5     Integer_Pipeline     8.6%   8.1%  31.0%   9.9%   9.9%  58.0% 8-11
 6     Integer_Pipeline    10.5%  10.0%  30.7%  11.9%  11.9%  57.9% 12-15
 7     Integer_Pipeline     9.1%   8.6%  30.1%  10.4%  10.4%  55.8% 16-19
 8     Integer_Pipeline     9.6%   9.1%  40.2%  10.9%  10.9%  54.8% 20-23
 9     Integer_Pipeline     8.9%   8.4%  35.0%  10.0%  10.0%  56.0% 24-27
10     Integer_Pipeline     9.5%   8.9%  40.3%  10.7%  10.7%  55.8% 28-31
示例 4 按芯片划分硬件和软件利用率

以下命令首先输出时间戳,然后输出按插槽(芯片)聚合的利用率。本示例中的计算机为 SPARC-T5,具有 128 个核心和 1024 个导线束。

# pgstat -T d -B chip
       July 11, 2013 02:53:11 PM PDT
       ID      RELATIONSHIP                            HW      SW  CPUS
           16  Chip (Software)                          -    0.2%  0-127
           16  Chip (Data_Pipe_to_memory)            0.1%       -  0-127
           16  Chip (Floating_Point_Unit)            0.0%       -  0-127
           16  Chip (Integer_Pipeline)               0.1%       -  0-127

        65552  Chip (Software)                          -    0.0%  128-255
        65552  Chip (Data_Pipe_to_memory)            0.0%       -  128-255
        65552  Chip (Floating_Point_Unit)            0.0%       -  128-255
        65552  Chip (Integer_Pipeline)               0.0%       -  128-255

       131088  Chip (Software)                          -    0.0%  256-383
       131088  Chip (Data_Pipe_to_memory)            0.0%       -  256-383
       131088  Chip (Floating_Point_Unit)            0.0%       -  256-383
       131088  Chip (Integer_Pipeline)               0.0%       -  256-383

       196624  Chip (Software)                          -    0.0%  384-511
       196624  Chip (Data_Pipe_to_memory)            0.0%       -  384-511
       196624  Chip (Floating_Point_Unit)            0.0%       -  384-511
       196624  Chip (Integer_Pipeline)               0.0%       -  384-511

       262160  Chip (Software)                          -    0.0%  512-639
       262160  Chip (Data_Pipe_to_memory)            0.0%       -  512-639
       262160  Chip (Floating_Point_Unit)            0.0%       -  512-639
       262160  Chip (Integer_Pipeline)               0.0%       -  512-639

       327696  Chip (Software)                          -    0.8%  640-767
       327696  Chip (Data_Pipe_to_memory)            0.9%       -  640-767
       327696  Chip (Floating_Point_Unit)            0.0%       -  640-767
       327696  Chip (Integer_Pipeline)               2.1%       -  640-767

       393232  Chip (Software)                          -    0.0%  768-895
       393232  Chip (Data_Pipe_to_memory)            0.0%       -  768-895
       393232  Chip (Floating_Point_Unit)            0.0%       -  768-895
       393232  Chip (Integer_Pipeline)               0.0%       -  768-895

       458768  Chip (Software)                          -    0.0%  896-1023
       458768  Chip (Data_Pipe_to_memory)            0.0%       -  896-1023
       458768  Chip (Floating_Point_Unit)            0.0%       -  896-1023
       458768  Chip (Integer_Pipeline)               0.0%       -  896-1023   
  

退出状态

将返回以下退出值:

0

成功完成。

1

无法从系统获取 PG 信息。

2

指定的间隔、计数或所有 CPU、 PG 和共享关系无效。

3

语法无效。

属性

有关下列属性的说明,请参见 attributes(5)

属性类型
属性值
可用性
system/core-os
接口稳定性
Uncommitted(未确定)

命令行选项和输出为 Uncommitted(未确定)。

另请参见

cputrack(1)attributes(5)dtrace(1M)pginfo(1M)cpc(3CPC)libcpc(3LIB)attributes(5)