Percona Toolkit使用之pt-summary

版权声明:本文为博主原创文章,转载敬请作出引用声明方便相互交流学习! https://blog.csdn.net/sweeper_freedoman/article/details/80198975

     pt-summary的功能是优雅地汇总系统信息。

     用法如下:

pt-summary

     pt-summary方便地汇总服务器的状态和配置。它并不是一个调优工具或者诊断工具。它生成一个易于diff以及可以不丢失格式粘贴进Email的报告。该工具在很多类型的Unix系统上运行良好。

     pt-summary运行大量命令去检查系统状态和配置,保存输出到临时目录文件,然后在这些结果上执行Unix命令来优雅地格式化。以特权用户执行时它工作得最好,当然也可以在没有特权时运行,不过非root用户可能无法生成某些输出。

     该工具的很多输出都刻意舍入来展示其量级大小而不是具体细节。这称为“fuzzy-rounding”。该设计思想为一个特定的计数是918还是921并没有关系;如此小的差异是微不足道的,只会让输出结果难于同其他服务器作比较。fuzzy-rounding随着输入的增长会舍入更大的增量。它刚开始舍入到最近的5,然后是最近的10,最近的25,然后以10倍大小的因数重复(50,100,250),随着输入的增长,以此类推。

     以下是一个生成自CentOS虚拟机的简单报告,以注释分割成段落。在终端作为手册页查阅该文档时,为了明晰,一些长行被重新格式化。

     该段展示当前日期和时间,以及服务器和操作系统的概览。

# Percona Toolkit System Summary Report ######################
        Date | 2012-03-30 00:58:07 UTC (local TZ: EDT -0400)
    Hostname | localhost.localdomain
      Uptime | 20:58:06 up 1 day, 20 min, 1 user,
               load average: 0.14, 0.18, 0.18
      System | innotek GmbH; VirtualBox; v1.2 ()
 Service Tag | 0
    Platform | Linux
     Release | CentOS release 5.5 (Final)
      Kernel | 2.6.18-194.el5
Architecture | CPU = 32-bit, OS = 32-bit
   Threading | NPTL 2.5
    Compiler | GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-48).
     SELinux | Enforcing
 Virtualized | VirtualBox

     该段提取自/proc/cpuinfo

# Processor ##################################################
  Processors | physical = 1, cores = 0, virtual = 1, hyperthreading = no
      Speeds | 1x2510.626
      Models | 1xIntel(R) Core(TM) i5-2400S CPU @ 2.50GHz
      Caches | 1x6144 KB

     内存信息。生成自free、ps、sysctl以及dmidecode。

# Memory #####################################################
       Total | 503.2M
        Free | 29.0M
        Used | physical = 474.2M, swap allocated = 1.0M,
               swap used = 16.0k, virtual = 474.3M
     Buffers | 33.9M
      Caches | 262.6M
       Dirty | 396 kB
     UsedRSS | 201.9M
  Swappiness | 60
 DirtyPolicy | 40, 10
 Locator  Size  Speed    Form Factor  Type    Type Detail
 =======  ====  =====    ===========  ====    ===========

     挂载文件系统。生成自mount和df。

# Mounted Filesystems ########################################
  Filesystem                       Size Used Type  Opts Mountpoint
  /dev/mapper/VolGroup00-LogVol00   15G  17% ext3  rw   /
  /dev/sda1                         99M  13% ext3  rw   /boot
  tmpfs                            252M   0% tmpfs rw   /dev/shm

     磁盘调度信息。提取自/sys。

# Disk Schedulers And Queue Size #############################
        dm-0 | UNREADABLE
        dm-1 | UNREADABLE
         hdc | [cfq] 128
         md0 | UNREADABLE
         sda | [cfq] 128

     磁盘分区信息。生成自fdisk -l。

# Disk Partioning ############################################
Device       Type      Start        End               Size
============ ==== ========== ========== ==================
/dev/sda     Disk                              17179869184
/dev/sda1    Part          1         13           98703360
/dev/sda2    Part         14       2088        17059230720

     内核索引节点信息。分别提取自/proc/sys/fs目录下同名文件。

# LVM Volumes ################################################
LV       VG         Attr   LSize   Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 269.00G
LogVol01 VolGroup00 -wi-ao   9.75G

     RAID控制器。生成自lvs。

# RAID Controller ############################################
  Controller | No RAID controller detected

     网络配置。生成自lspci和sysctl。

# Network Config #############################################
  Controller | Intel Corporation 82540EM Gigabit Ethernet Controller
 FIN Timeout | 60
  Port Range | 61000

     网络接口统计。生成自ip -s link。

# Interface Statistics #######################################
interface rx_bytes rx_packets rx_errors tx_bytes tx_packets tx_errors
========= ======== ========== ========= ======== ========== =========
lo        60000000      12500         0 60000000      12500         0
eth0      15000000      80000         0  1500000      10000         0
sit0             0          0         0        0          0         0

     网络连接汇总。生成自netstat。

# Network Connections ########################################
  Connections from remote IP addresses
    127.0.0.1           2
  Connections to local IP addresses
    127.0.0.1           2
  Connections to top 10 local ports
    38346               1
    60875               1
  States of connections
    ESTABLISHED         5
    LISTEN              8

     top前几行。

# Top Processes ##############################################
  PID USER  PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root  15   0  2072  628  540 S  0.0  0.1   0:02.55 init
    2 root  RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0
    3 root  34  19     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/0
    4 root  RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    5 root  10  -5     0    0    0 S  0.0  0.0   0:00.97 events/0
    6 root  10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper
    7 root  10  -5     0    0    0 S  0.0  0.0   0:00.00 kthread
   10 root  10  -5     0    0    0 S  0.0  0.0   0:00.13 kblockd/0
   11 root  20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid
# Notable Processes ##########################################
  PID    OOM    COMMAND
 2028    +0    sshd

     裁剪后的vmstat 1 5。

# Simplified and fuzzy rounded vmstat (wait please) ##########
  procs  ---swap-- -----io---- ---system---- --------cpu--------
   r  b    si   so    bi    bo     ir     cs  us  sy  il  wa  st
   2  0     0    0     3    15     30    125   0   0  99   0   0
   0  0     0    0     0     0   1250    800   6  10  84   0   0
   0  0     0    0     0     0   1000    125   0   0 100   0   0
   0  0     0    0     0     0   1000    125   0   0 100   0   0
   0  0     0    0     0   450   1000    125   0   1  88  11   0
# The End ####################################################

     以下为个人本地环境(Ubuntu virtual machine)的测试数据。出于简洁省略了一些输出。

root@ubuntu:~# pt-summary
# Percona Toolkit System Summary Report ######################
        Date | 2018-05-04 11:55:10 UTC (local TZ: CST +0800)
    Hostname | ubuntu
      Uptime |  2:08,  3 users,  load average: 0.30, 0.32, 0.28
      System | VMware, Inc.; VMware Virtual Platform; vNone (Other)
 Service Tag | VMware-56 4d 7d 7a cd bc ab bd-5d cc e8 c9 6c b5 aa 8c
    Platform | Linux
     Release | Ubuntu 16.04.4 LTS (xenial)
      Kernel | 4.4.0-119-generic
Architecture | CPU = 64-bit, OS = 64-bit
   Threading | NPTL 2.23
     SELinux | No SELinux detected
 Virtualized | VMWare
# Processor ##################################################
  Processors | physical = 2, cores = 2, virtual = 2, hyperthreading = no
      Speeds | 2x2494.280
      Models | 2xIntel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
      Caches | 2x6144 KB
# Memory #####################################################
       Total | 1.9G
        Free | 71.5M
        Used | physical = 1.2G, swap allocated = 4.0G, swap used = 126.1M, virtual = 1.3G
      Shared | 30.6M
     Buffers | 687.3M
      Caches | 524.8M
       Dirty | 428 kB
     UsedRSS | 1.8G
  Swappiness | 60
 DirtyPolicy | 20, 10
 DirtyStatus | 0, 0
  Locator   Size     Speed             Form Factor   Type          Type Detail
  ========= ======== ================= ============= ============= ===========
  RAM slot #0 2048 MB  Unknown           DIMM          DRAM          EDO     
  NVD #0    {EMPTY}  Unknown           DIMM          Other         Unknown 
  
    ……………………………………………………………………………………omitted……………………………………………………………………………………
  
  RAM slot #11 {EMPTY}  Unknown           DIMM          DRAM          Unknown 

    ……………………………………………………………………………………omitted……………………………………………………………………………………
  
# Mounted Filesystems ########################################
  Filesystem  Size Used Type     Opts                                                             Mountpoint
  /dev/sda1    21G  82% ext4     rw,relatime,errors=remount-ro,data=ordered                       /
  tmpfs       199M   0% tmpfs    rw,nosuid,nodev                                                  /run/user/0
  tmpfs       199M   0% tmpfs    rw,nosuid,nodev,noexec,relatime,size=5120k                       /run/user/0
  tmpfs       199M   0% tmpfs    rw,nosuid,noexec,relatime,size=202988k,mode=755                  /run/user/0
  tmpfs       199M   0% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700                   /run/user/0
  tmpfs       199M   0% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700,uid=1000,gid=1000 /run/user/0
  tmpfs       199M   0% tmpfs    ro,nosuid,nodev,noexec,mode=755                                  /run/user/0
  tmpfs       199M   4% tmpfs    rw,nosuid,nodev                                                  /run
  tmpfs       199M   4% tmpfs    rw,nosuid,nodev,noexec,relatime,size=5120k                       /run
  tmpfs       199M   4% tmpfs    rw,nosuid,noexec,relatime,size=202988k,mode=755                  /run
  tmpfs       199M   4% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700                   /run
  tmpfs       199M   4% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700,uid=1000,gid=1000 /run
  tmpfs       199M   4% tmpfs    ro,nosuid,nodev,noexec,mode=755                                  /run
  tmpfs       199M   1% tmpfs    rw,nosuid,nodev                                                  /run/user/1000
  tmpfs       199M   1% tmpfs    rw,nosuid,nodev,noexec,relatime,size=5120k                       /run/user/1000
  tmpfs       199M   1% tmpfs    rw,nosuid,noexec,relatime,size=202988k,mode=755                  /run/user/1000
  tmpfs       199M   1% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700                   /run/user/1000
  tmpfs       199M   1% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700,uid=1000,gid=1000 /run/user/1000
  tmpfs       199M   1% tmpfs    ro,nosuid,nodev,noexec,mode=755                                  /run/user/1000
  tmpfs       5.0M   1% tmpfs    rw,nosuid,nodev                                                  /run/lock
  tmpfs       5.0M   1% tmpfs    rw,nosuid,nodev,noexec,relatime,size=5120k                       /run/lock
  tmpfs       5.0M   1% tmpfs    rw,nosuid,noexec,relatime,size=202988k,mode=755                  /run/lock
  tmpfs       5.0M   1% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700                   /run/lock
  tmpfs       5.0M   1% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700,uid=1000,gid=1000 /run/lock
  tmpfs       5.0M   1% tmpfs    ro,nosuid,nodev,noexec,mode=755                                  /run/lock
  tmpfs       992M   0% tmpfs    rw,nosuid,nodev                                                  /sys/fs/cgroup
  tmpfs       992M   0% tmpfs    rw,nosuid,nodev,noexec,relatime,size=5120k                       /sys/fs/cgroup
  tmpfs       992M   0% tmpfs    rw,nosuid,noexec,relatime,size=202988k,mode=755                  /sys/fs/cgroup
  tmpfs       992M   0% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700                   /sys/fs/cgroup
  tmpfs       992M   0% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700,uid=1000,gid=1000 /sys/fs/cgroup
  tmpfs       992M   0% tmpfs    ro,nosuid,nodev,noexec,mode=755                                  /sys/fs/cgroup
  tmpfs       992M   2% tmpfs    rw,nosuid,nodev                                                  /dev/shm
  tmpfs       992M   2% tmpfs    rw,nosuid,nodev,noexec,relatime,size=5120k                       /dev/shm
  tmpfs       992M   2% tmpfs    rw,nosuid,noexec,relatime,size=202988k,mode=755                  /dev/shm
  tmpfs       992M   2% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700                   /dev/shm
  tmpfs       992M   2% tmpfs    rw,nosuid,nodev,relatime,size=202988k,mode=700,uid=1000,gid=1000 /dev/shm
  tmpfs       992M   2% tmpfs    ro,nosuid,nodev,noexec,mode=755                                  /dev/shm
  udev        971M   0% devtmpfs rw,nosuid,relatime,size=993960k,nr_inodes=248490,mode=755        /dev
# Disk Schedulers And Queue Size #############################
         sda | [deadline] 128
         sr0 | [deadline] 128
# Disk Partioning ############################################
Device       Type      Start        End               Size
============ ==== ========== ========== ==================
/dev/sda     Disk                              26843545600
/dev/sda1    Part       2048   44040191                  0
/dev/sda2    Part   44042238   52426751                  0
/dev/sda5    Part   44042240   52426751                  0
# Kernel Inode State #########################################
dentry-state | 27242	12085	45	0	0	0
     file-nr | 8640	0	197654
    inode-nr | 39867	13627
# LVM Volumes ################################################
Unable to collect information
# LVM Volume Groups ##########################################
Unable to collect information
# RAID Controller ############################################
  Controller | No RAID controller detected
# Network Config #############################################
  Controller | Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
 FIN Timeout | 60
  Port Range | 60999
# Interface Statistics #######################################
  interface  rx_bytes rx_packets  rx_errors   tx_bytes tx_packets  tx_errors
  ========= ========= ========== ========== ========== ========== ==========
  lo           100000       1000          0     100000       1000          0
  ens33     700000000     500000          0   12500000     150000          0
# Network Devices ############################################
  Device    Speed     Duplex
  ========= ========= =========
  ens33      1000Mb/s   Full      
# Network Connections ########################################
  Connections from remote IP addresses

    ……………………………………………………………………………………omitted……………………………………………………………………………………
  
  Connections to local IP addresses
  
    ……………………………………………………………………………………omitted……………………………………………………………………………………
	
  Connections to top 10 local ports
    22                  2
    40952               1
    43808               1
    45808               1
    46468               1
    53362               1
    57576               1
  States of connections
    CLOSE_WAIT          4
    ESTABLISHED         4
    LISTEN             10
# Top Processes ##############################################
   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  3292 root      20   0 2601232 164840  61636 S  12.5  8.1  20:16.60 netease-c+
     1 root      20   0  119836   4736   3260 S   0.0  0.2   0:02.42 systemd
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd
     3 root      20   0       0      0      0 S   0.0  0.0   0:00.24 ksoftirqd+
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0+
     7 root      20   0       0      0      0 S   0.0  0.0   0:06.58 rcu_sched
     8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh
     9 root      rt   0       0      0      0 S   0.0  0.0   0:00.03 migration+
    10 root      rt   0       0      0      0 S   0.0  0.0   0:00.04 watchdog/0
# Notable Processes ##########################################
  PID    OOM    COMMAND
 1008    -17    sshd
# Simplified and fuzzy rounded vmstat (wait please) ##########
  procs  ---swap-- -----io---- ---system---- --------cpu--------
   r  b    si   so    bi    bo     ir     cs  us  sy  il  wa  st
   1  0     0    9   150   100    500   1000   4   5  91   0   0
   3  0     0    0   100     0   1500   4000   5  12  84   0   0
   0  0     0    0   125     0    800   1750   5   4  91   0   0
   0  0     0    0     0     0    800   1750   5   4  92   0   0
   0  0     0    0     0   175    800   1750   2   6  91   0   0
# Memory mamagement ##########################################
Transparent huge pages are enabled.
# The End ####################################################
root@ubuntu:~# 



     参考:

https://www.percona.com/doc/percona-toolkit/LATEST/pt-summary.html

猜你喜欢

转载自blog.csdn.net/sweeper_freedoman/article/details/80198975