linux系统监控命令参数讲解


linux监控有很多值得学习的地方,这里我们主要介绍几个常见的linux系统监控命令,包括介绍cache、swap、cpu等方面。

常用linux系统监控命令swap
1 ps监控命令:
linux系统监控命令中PS是一个强大的查看进程状态的命令。那些进程正在运行。进程的状态,进程占用的资源等等,主要监控后台进程。相关参数:
◆-e显示所有进程,-f全格式,-h不显示标题 -l长格式,-w宽输出
◆-a显示终端上的所有进程,包括其他用户的进程。
◆-r只显示正在运行的进程 -x显示没有控制终端的进程
最常用的是ps -aux。这个显示所有进程,
显示项的意义:
◆user,pid不考虑
◆VGZ--进程占用的虚拟记忆体的大小。
◆RSS--占用的共享存储区大小
◆STAT--进程状态,这是非常重要的一项。其中的状态如下:
R: 正在执行中
S: 静止状态
T: 暂停执行
Z: 不存在但暂时无法消除,也就是僵尸进程zombie)
W: 没有足够的记忆体分页可分配
N:低优先级
L: 有记忆体分页分配并锁在记忆体内
◆START:进程开始的时间
◆TIME:进程执行的时间
◆command进程命令行

2 top监控命令
第一行:开机时间,用户数,1s,5s,15s的cpu工作负载。
第二行:从上次刷新以来总进程数,睡眠进程数,运行进程数,僵死进程数,停止进程数
第三行:内存使用状态。总的,已用的,空闲的,共享的,缓存的。
第四行:交换分区虚拟内存)使用状态
下面的和ps显示的差不多,不过默认情况下每5秒刷新一次
例子
[root@localhost root]# top
18:11:19  up  1:37,  2 users,  load average: 0.00, 0.00, 0.00
67 processes: 66 sleeping, 1 running, 0 zombie, 0 stopped
CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
total    0.9%    0.0%    0.0%   0.0%     0.0%    0.0%   99.0%
Mem:   254140k av,  145172k used,  108968k free,       0k shrd,   13888k buff
108536k active,              15592k inactive
Swap: 2096440k av,       0k used, 2096440k free                   68736k cached

PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND
 2593 root      20   0  1092 1092   884 R     0.9  0.4   0:00   0 top
1 root      15   0   492  492   436 S     0.0  0.1   0:04   0 init
2 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 keventd
3 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kapmd
4 root      34  19     0    0     0 SWN   0.0  0.0   0:00   0 ksoftirqd/0
7 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 bdflush
5 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kswapd
6 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kscand
8 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kupdated
9 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 mdrecoveryd
17 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald
72 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 khubd
1363 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald
1364 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald
1365 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald
1366 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald
1367 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kjournald
1731 root      18   0  1004 1004   724 S     0.0  0.3   0:00   0 dhclient
1781 root      15   0   580  580   500 S     0.0  0.2   0:00   0 syslogd
1785 root      15   0   464  464   400 S     0.0  0.1   0:00   0 klogd
1813 rpc       15   0   568  568   496 S     0.0  0.2   0:00   0 portmap
1833 rpcuser   25   0   716  716   636 S     0.0  0.2   0:00   0 rpc.statd
1845 root      15   0   404  404   344 S     0.0  0.1   0:00   0 mdadm
1904 root      24   0   504  504   456 S     0.0  0.1   0:00   0 apmd
1948 root      15   0  1956 1956  1440 S     0.0  0.7   0:00   0 cupsd
1974 root      15   0  1548 1548  1296 S     0.0  0.6   0:00   0 sshd
1990 root      15   0   884  884   768 S     0.0  0.3   0:00   0 xinetd
2020 root      15   0  2548 2548  1876 S     0.0  1.0   0:00   0 sendmail
2029 smmsp     15   0  2296 2288  1752 S     0.0  0.9   0:00   0 sendmail
可以通过h查看交互名令列表

3 free监控命令
free也是常用的linux系统监控命令。
查看内存状态[root@localhost root]# free -m
total       used       free     shared    buffers     cached
Mem:           248        141        106          0         13         67
-/+ buffers/cache:         60        187
Swap:         2047          0       2047
第一行从内核角度看内存使用,第二行从应用程序角度看内存使用。
free=free+buffers+cached.

4 vmstat监控命令
vmstat命令报告关于内核线程、虚拟内存、磁盘、陷阱和 CPU 活动的统计信息。由vmstat命令生成的报告可以用于平衡系统负载活动。系统范围内的这些统计信息所有的处理器中)都计算出以百分比表示的平均值,或者计算其总和。
[root@localhost root]# vmstat -m 2 5
procs                      memory      swap          io     system         cpu
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
1  0      0    104     14     67    0    0    12     5  103    72  0  1 99  0
0  0      0    104     14     67    0    0     0    20  104   132  0  0 100  0
0  0      0    104     14     67    0    0     0     0  103   122  0  0 100  0
1  0      0    104     14     67    0    0     0    44  107   134  0  0 100  0
1  0      0    104     14     67    0    0     0     0  103   122  0  0 100  0
process
r 为置于运行队列的内核线程数目
b为置于等待对列的内核线程数目
cache
free  : the amount of free physical memory (in KB by default)
buff  : the amount of memory consumed by buffers (in KB by default)
inact : the amount of memory on the inactive list (in KB by default)
active: the amount of memory on the active list (in KB by default)

swap
si: 从磁盘写出的物理页总数(in KB/s by default)
so: 写入磁盘的物理页总数(in KB/s by default)

io
bi: 从磁盘获取的数据块总数 (in blocks/s).
bo: 写入磁盘的数据块总数 (in blocks/s).

system
in: the number of interrupts received (in interrupts/s)
cs: the number of context switches (in switches/s)

cpu
us: 用户空间消耗的cpu百分比
sy: 内黑消耗的cpu百分比
wa: i/o等待的cpu百分比
id: 空闲时间的百分比
以上给大家介绍的是linux系统监控命令。

  1. linux库技术文档学习笔记
  2. 中国政府提供补贴向农村地区推广Linux
  3. Linux Kernel的新时限调度方案
  4. 详细解析:Linux操作系统的无线网络命令
  5. Linux之父Linus向Windows 7竖起大拇指

相关内容

    暂无相关文章