17.3.0: 系统管理-top工具



1. 命令:top

作用:用于动态监控进程所占系统资源。
参数:

输出内容格式:

#当前时间 "up" 启动时间,登录用户,负载信息
top - 07:10:09 up 1 day,  8:48,  1 user,  load average: 0.00, 0.00, 0.00
#进程总数,运行及等待进程数,睡眠进程数,停止进程数,僵尸进程数
Tasks:  78 total,   1 running,  77 sleeping,   0 stopped,   0 zombie
#cpu信息:用户占用,系统占用,调过优先级进程占用,空闲占用,等待io占用,硬中断占用,软中断占用
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
#memory:总内存,使用内存,空闲内存,buff内存
Mem:   1004772k total,   145920k used,   858852k free,    32096k buffers
#swap:总容量,使用量,空闲量,cached空间
Swap:  1023996k total,        0k used,  1023996k free,    40324k cached
## 下面的空白行是指令区域

# 进程号 用户 优先级 nice值 虚拟内存 使用内存 共享内存 状态 cpu用率 内存用率 cpu时间 命令
   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     1 root      20   0 19232 1492 1224 S  0.0  0.1   0:00.88 init
   ......

选项及其含义:

PS: top -bn1 它表示非动态打印系统资源使用情况,可以用在shell脚本中
pr越小优先级越高,ni的值等于pr-20
proc目录下存在pid为名称的文件夹


2. 命令:htop

安装:yum install htop -y
作用:类似于top工具,但可以用鼠标点选


3. 命令:iftop

安装:yum install iftop -y
作用:展示带宽使用情况
参数:

用法举例:

iftop -t
interface: em1
IP address is: 61.220.205.183
MAC address is: ffffffb0:ffffff83:fffffffe:ffffffe2:1d:6b
Listening on em1
   # Host name (port/service if enabled)            last 2s   last 10s   last 40s cumulative
--------------------------------------------------------------------------------------------
   1 61-220-205-183.HINET-IP.hinet.net        =>     1.89Kb     1.89Kb     1.89Kb       485B
     google-public-dns-a.google.com           <=     2.99Kb     2.99Kb     2.99Kb       766B
   2 61-220-205-183.HINET-IP.hinet.net        =>     1.64Kb     1.64Kb     1.64Kb       420B
     228.0.0.5                                <=         0b         0b         0b         0B
   3 61-220-205-183.HINET-IP.hinet.net        =>       560b       560b       560b       140B
     google-public-dns-b.google.com           <=       560b       560b       560b       140B
   4 61-220-205-183.HINET-IP.hinet.net        =>       432b       432b       432b       108B
     61.14.162.7                              <=       320b       320b       320b        80B
   5 61-220-205-183.HINET-IP.hinet.net        =>       356b       356b       356b        89B
     43.254.62.149                            <=         0b         0b         0b         0B
--------------------------------------------------------------------------------------------
Total send rate:                                     4.85Kb     4.85Kb     4.85Kb
Total receive rate:                                  3.85Kb     3.85Kb     3.85Kb
Total send and receive rate:                         8.70Kb     8.70Kb     8.70Kb
--------------------------------------------------------------------------------------------
Peak rate (sent/received/total):                     4.85Kb     3.85Kb     8.70Kb
Cumulative (sent/received/total):                    1.21KB       986B     2.18KB
============================================================================================