Linux 下各种监控系统的命令小结

Linux 下各种监控系统的命令小结

linux 里面监控了各种 系统资源,也采取了不同的命令,这里说下几种常用的命令

1、 top 命令

以下是 top 命令中,几个关键字段的含义

Table 17-1. top Column headers

Header   Meaning

PID     Tasks process ID. This unique identifier allows you to manipulate a task.

USER   The user name of the tasks owner, the account it runs as.

PR      The task priority.

NI          The task niceness, an indication of how willing this task is to yield CPU cycles to other tasks. A lower or negative niceness means a high priority.

VIRT     The total amount of memory used by the task, including shared and swap memory.

RES       The total amount of physical memory used by the task, excluding swap memory.

SHR      The amount of shared memory used by the task. This memory is usually allocated by libraries and also usable by other tasks.

S           Task status. This indicates whether a task is running (R), sleeping (D or S), stopped (T),or zombie (Z).

%CPU    Percentage of available CPU cycles this task has used since the last screen update.

%MEM Percentage of available RAM used by this task.  --记住,这里不包括 swap

TIME+   Total CPU time the task has used since it started.

COMMAND The name of the task being monitored.

----------------------------------------------------------------------------------------------

还有一点要记住,top 命令对于 cpu 不是叠加的,也就是说,如果有 8 cpu,那么,有可能 top 出来的 某个 pid cpu 占有率已经 100% 了,我们只能说这个 程序耗掉了 一个 cpu 的资源,其它 cpu 可能是空闲的。

 

2、 vmstat

以下是从 man vmstat 里面摘抄出来的 vmstat 的解释:

Procs  --process

       r: The number of processes waiting for run time.

       b: The number of processes in uninterruptible sleep.

 

   Memory

       swpd: the amount of virtual memory used.

       free: the amount of idle memory.

       buff: the amount of memory used as buffers.

       cache: the amount of memory used as cache.

       inact: the amount of inactive memory. (-a option)

       active: the amount of active memory. (-a option)

 

   Swap

       si: Amount of memory swapped in from disk (/s).

       so: Amount of memory swapped to disk (/s).

 

   IO

       bi: Blocks received from a block device (blocks/s).

       bo: Blocks sent to a block device (blocks/s).

 

   System

       in: The number of interrupts per second, including the clock.

       cs: The number of context switches per second.

 

   CPU

       These are percentages of total CPU time.

       us: Time spent running non-kernel code. (user time, including nice time)

       sy: Time spent running kernel code. (system time)

       id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.

       wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.

       st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

这里,我重点说下 swap IO CPU 这三个值

首先说下 swap CPU wa

os 出现 性能下降时,我们 通过 vmstat 观察发现 swap si so 两项值特别高时,我们就应该注意,是不是 os 的内存不够用,导致了 过度的  swap page in page out,而当 swap si so 值较高时,往往 CPU wa 值也很高,这个 wa 值表示cpu 花在 等待 swap 数据的时间。所以,一旦 这三个指标都很高时,就要注意,应用是否占用了过多的内存,导致了 swap 不断得 page in page out

 

接着,再来说下 IO

Bi 表示 读入数据,bo 表示 写入数据

这个值 监控 系统的 IO 状态,我们可以根据 vmstat 的采样时间,和 bo bi 的数据,估算下,这段时间内,系统的 IO 负载,然后根据 硬盘的 最大读写负载,看看,是否有 IO 问题。

 

3、 iostat

这个命令比较简单,查看 IO 的,基本上都应该看得懂

 

4、 mpstat

mpstatMultiprocessor Statistics的缩写,是实时系统监控工具。其报告与CPU的一些统计信息,这些信息存放在/proc/stat文件中。在多CPUs系统里,其不但能查看所有CPU的平均状况信息,而且能够查看特定CPU的信息。下面只介绍 mpstatCPU相关的参数,

CPU 处理器ID

user internal时间段里,用户态的CPU时间(% ,不包含 nice值为负 进程 ?usr/?total*100

nice internal时间段里,nice值为负进程的CPU时间(% ?nice/?total*100

system internal时间段里,核心时间(% ?system/?total*100

iowait internal时间段里,硬盘IO等待时间(% ?iowait/?total*100

irq internal时间段里,软中断时间(% ?irq/?total*100

soft internal时间段里,软中断时间(% ?softirq/?total*100

idle internal时间段里,CPU除去等待磁盘IO操作外的因为任何原因而空闲的时间闲置时间 % ?idle/?total*100

intr/s internal时间段里,每秒CPU接收的中断的次数 ?intr/?total*100

 

mpstat 的语句如下:

$mpstat –查看所有 cpu 的汇总信息

$mpstat –P ALL 分开显示 不同 cpu 的汇总信息

$mpstat –P 1    只显示 cpu 1 的汇总信息

 

5、 pidstat

可以列出具体的 某个进程所使用的 IOcpumemory 等等

 

6、 netstat

列出网络资源状态

 

7、 sar

collects, reports and saves system activity information (CPU, memory, disks, interrupts, network interfaces, TTY, kernel tables,etc.)

可以说,sar 的功能是很强大的,它会收集历史的统计信息,保存到文本文档或者二进制的文档中,以后要看时,就可以随时查看了。

这里就不写具体用法了,重点关注上面那个

http://www.lslnet.com/linux/docs/linux-6034.htm

比较有价值的网址:

http://sebastien.godard.pagesperso-orange.fr/documentation.html

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14730395/viewspace-683847/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/14730395/viewspace-683847/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值