Linux 性能监测工具总结

网友投稿 533 2023-03-20

本站部分文章、图片属于网络上可搜索到的公开信息,均用于学习和交流用途,不能代表睿象云的观点、立场或意见。我们接受网民的监督,如发现任何违法内容或侵犯了您的权益,请第一时间联系小编邮箱jiasou666@gmail.com 处理。

Linux 性能监测工具总结

前言:

Linux系统出现问题时,我们不仅需要查看系统日志信息,而且还要使用大量的性能监测工具来判断究竟是哪一部分(内存、CPU、硬盘……)出了问题。在Linux系统中,所有的运行参数保存在虚拟目录/proc中,换句话说,我们使用的性能监控工具取到的数据值实际上就是源自于这个目录,当涉及到系统高估时,我们就可以修改/proc目录中的相关参数了,当然有些是不能乱改的。下面就让我们了解一下这些常用的性能监控工具。

1、uptimeuptime命令用于查看服务器运行了多长时间以及有多少个用户登录,快速获知服务器的负荷情况。uptime的输出包含一项内容是load average,显示了最近1,5,15分钟的负荷情况。它的值代表等待CPU处理的进程数,如果CPU没有时间处理这些进程,load average值会升高;反之则会降低。load average的最佳值是1,说明每个进程都可以马上处理并且没有CPU cycles被丢失。对于单CPU的机器,1或者2是可以接受的值;对于多路CPU的机器,load average值可能在8到10之间。也可以使用uptime命令来判断网络性能。例如,某个网络应用性能很低,通过运行uptime查看服务器的负荷是否很高,如果不是,那么问题应该是网络方面造成的。以下是uptime的运行实例:

1
2
3
[root@localhost ~]# uptime
 04:43:35 up  2:49,  2 users,  load average: 0.00, 0.00, 0.00
[root@localhost ~]#

1 2 3 [root@localhost ~]# uptime  04:43:35 up  2:49,  2 users,  load average: 0.00, 0.00, 0.00 [root@localhost ~]#

也可以查看/proc/loadavg和/proc/uptime两个文件,注意不能编辑/proc中的文件,要用cat等命令来查看,如:

1
2
3
[root@localhost ~]# cat /proc/loadavg
0.00 0.00 0.00 1/118 15960
[root@localhost ~]#

1 2 3 [root@localhost ~]# cat /proc/loadavg 0.00 0.00 0.00 1/118 15960 [root@localhost ~]#

2、dmesgdmesg命令主要用来显示内核信息。使用dmesg可以有效诊断机器硬件故障或者添加硬件出现的问题。另外,使用dmesg可以确定您的服务器安装了那些硬件。每次系统重启,系统都会检查所有硬件并将信息记录下来。执行/bin/dmesg命令可以查看该记录。()

3、top

top命令显示处理器的活动状况。缺省情况下,显示占用CPU最多的任务,并且每隔5秒钟做一次刷新。

Process priority的数值决定了CPU处理进程的顺序。LIUNX内核会根据需要调整该数值的大小。nice value局限于priority。priority的值不能低于nice value(nice value值越低,优先级越高)。您不可以直接修改Process priority的值,但是可以通过调整nice level值来间接地改变Process priority值,然而这一方法并不是所有时候都可用。如果某个进程运行异常的慢,可以通过降低nice level为该进程分配更多的CPU。

iostat显示实例:

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@localhost ~]# iostat
Linux 2.6.28l7 (localhost.localdomain)  07/05/2013
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.07    0.14    0.29    0.03    0.00   99.46
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               3.17        68.54        19.41     715323     202580
sda1              0.01         0.25         0.00       2568         28
sda2              3.15        67.79        19.40     707458     202496
sda3              0.01         0.27         0.01       2771         56
sda4              0.00         0.00         0.00          6          0
sda5              0.00         0.19         0.00       2000          0
hdc               0.00         0.05         0.00        496          0
[root@localhost ~]#

1 2 3 4 5 6 7 8 9 10 11 12 13 [root@localhost ~]# iostat Linux 2.6.28l7 (localhost.localdomain)  07/05/2013 avg-cpu:  %user   %nice %system %iowait  %steal   %idle            0.07    0.14    0.29    0.03    0.00   99.46 Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn sda               3.17        68.54        19.41     715323     202580 sda1              0.01         0.25         0.00       2568         28 sda2              3.15        67.79        19.40     707458     202496 sda3              0.01         0.27         0.01       2771         56 sda4              0.00         0.00         0.00          6          0 sda5              0.00         0.19         0.00       2000          0 hdc               0.00         0.05         0.00        496          0 [root@localhost ~]#

CPU占用情况包括四块内容:

1
2
3
4
%user:显示user level (applications)时,CPU的占用情况。
%nice:显示user level在nice priority时,CPU的占用情况。
%system:显示system level (kernel)时,CPU的占用情况。
%idle: 显示CPU空闲时间所占比例。

1 2 3 4 %user:显示user level (applications)时,CPU的占用情况。 %nice:显示user level在nice priority时,CPU的占用情况。 %system:显示system level (kernel)时,CPU的占用情况。 %idle: 显示CPU空闲时间所占比例。

磁盘使用报告分成以下几个部分:

1
2
3
4
5
6
7
8
9
Device: 块设备的名字
tps: 该设备每秒I/O传输的次数。多个I/O请求可以组合为一个,每个I/O请求传输的字节数不同,因此可以将多个I/O请求合并为一个。
Blk_read/s, Blk_wrtn/s: 表示从该设备每秒读写的数据块数量。块的大小可以不同,如1024, 2048 或 4048字节,这取决于partition的大小。
例如,执行下列命令获得设备/dev/sda1 的数据块大小:
dumpe2fs -h /dev/sda1 |grep -F "Block size"
输出结果如下
dumpe2fs 1.34 (25-Jul-2003)
Block size: 1024
Blk_read, Blk_wrtn: 指示自从系统启动之后数据块读/写的合计数。

1 2 3 4 5 6 7 8 9 Device: 块设备的名字 tps: 该设备每秒I/O传输的次数。多个I/O请求可以组合为一个,每个I/O请求传输的字节数不同,因此可以将多个I/O请求合并为一个。 Blk_read/s, Blk_wrtn/s: 表示从该设备每秒读写的数据块数量。块的大小可以不同,如1024, 2048 或 4048字节,这取决于partition的大小。 例如,执行下列命令获得设备/dev/sda1 的数据块大小: dumpe2fs -h /dev/sda1 |grep -F "Block size" 输出结果如下 dumpe2fs 1.34 (25-Jul-2003) Block size: 1024 Blk_read, Blk_wrtn: 指示自从系统启动之后数据块读/写的合计数。

也可以查看这几个文件/proc/stat,/proc/partitions,/proc/diskstats的内容。5、vmstatvmstat提供了processes, memory, paging, block I/O, traps和CPU的活动状况

1
2
3
4
5
6
7
8
[root@localhost ~]# vmstat -n 1
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 535520  67236 320296    0    0     9     3 1005   16  0  0 99  0  0
 0  0      0 535512  67236 320296    0    0     0     0 3965   36  0  0 100  0  0
 0  0      0 535512  67236 320296    0    0     0     0 3941   26  0  1 99  0  0
 0  0      0 535396  67252 320284    0    0     0   180 3895  124  0  1 99  0  0
 0  0      0 535372  67252 320304    0    0     0     0 3733   28  0  1 99  0  0

1 2 3 4 5 6 7 8 [root@localhost ~]# vmstat -n 1 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st  0  0      0 535520  67236 320296    0    0     9     3 1005   16  0  0 99  0  0  0  0      0 535512  67236 320296    0    0     0     0 3965   36  0  0 100  0  0  0  0      0 535512  67236 320296    0    0     0     0 3941   26  0  1 99  0  0  0  0      0 535396  67252 320284    0    0     0   180 3895  124  0  1 99  0  0  0  0      0 535372  67252 320304    0    0     0     0 3733   28  0  1 99  0  0

各输出列的含义:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Process
– r: The number of processes waiting for runtime.
– b: The number of processes in uninterruptable sleep.
Memory
– swpd: The amount of virtual memory used (KB).
– free: The amount of idle memory (KB).
– buff: The amount of memory used as buffers (KB).
Swap
– si: Amount of memory swapped from the disk (KBps).
– so: Amount of memory swapped to the disk (KBps).
IO
– bi: Blocks sent to a block device (blocks/s).
– bo: Blocks received from 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 included IO-wait time.
– wa: Time spent waiting for IO. Prior to Linux 2.5.41, this appeared as zero.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Process – r: The number of processes waiting for runtime. – b: The number of processes in uninterruptable sleep. Memory – swpd: The amount of virtual memory used (KB). – free: The amount of idle memory (KB). – buff: The amount of memory used as buffers (KB). Swap – si: Amount of memory swapped from the disk (KBps). – so: Amount of memory swapped to the disk (KBps). IO – bi: Blocks sent to a block device (blocks/s). – bo: Blocks received from 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 included IO-wait time. – wa: Time spent waiting for IO. Prior to Linux 2.5.41, this appeared as zero.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost ~]# sar -u 3 10
Linux 2.6.28l7 (localhost.localdomain)  07/05/2013
04:51:29 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle
04:51:32 AM       all      0.00      0.00      0.17      0.00      0.00     99.83
04:51:35 AM       all      0.00      0.00      0.34      0.00      0.00     99.66
04:51:38 AM       all      0.00      0.00      0.45      0.00      0.00     99.55
04:51:41 AM       all      0.00      0.00      0.19      0.00      0.00     99.81
04:51:44 AM       all      0.00      0.00      0.17      0.00      0.00     99.83
04:51:47 AM       all      0.00      0.00      0.17      0.00      0.00     99.83
04:51:50 AM       all      0.00      0.00      0.17      0.00      0.00     99.83
04:51:53 AM       all      0.00      0.00      0.17      0.00      0.00     99.83
04:51:56 AM       all      0.00      0.00      0.26      0.00      0.00     99.74
04:51:59 AM       all      0.00      0.00      0.09      0.00      0.00     99.91
Average:          all      0.00      0.00      0.22      0.00      0.00     99.78
[root@localhost ~]#

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [root@localhost ~]# sar -u 3 10 Linux 2.6.28l7 (localhost.localdomain)  07/05/2013 04:51:29 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle 04:51:32 AM       all      0.00      0.00      0.17      0.00      0.00     99.83 04:51:35 AM       all      0.00      0.00      0.34      0.00      0.00     99.66 04:51:38 AM       all      0.00      0.00      0.45      0.00      0.00     99.55 04:51:41 AM       all      0.00      0.00      0.19      0.00      0.00     99.81 04:51:44 AM       all      0.00      0.00      0.17      0.00      0.00     99.83 04:51:47 AM       all      0.00      0.00      0.17      0.00      0.00     99.83 04:51:50 AM       all      0.00      0.00      0.17      0.00      0.00     99.83 04:51:53 AM       all      0.00      0.00      0.17      0.00      0.00     99.83 04:51:56 AM       all      0.00      0.00      0.26      0.00      0.00     99.74 04:51:59 AM       all      0.00      0.00      0.09      0.00      0.00     99.91 Average:          all      0.00      0.00      0.22      0.00      0.00     99.78 [root@localhost ~]#

7、KDE System GuardKDE System Guard (KSysguard) 是KDE图形方式的任务管理和性能监视工具。监视本地及远程客户端/服务器架构体系的中的主机。8、free/bin/free命令显示所有空闲的和使用的内存数量,包括swap。同时也包含内核使用的缓存。

1
2
3
4
5
6
[root@localhost ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           998        476        522          0         65        312
-/+ buffers/cache:         97        901
Swap:          996          0        996
[root@localhost ~]#

1 2 3 4 5 6 [root@localhost ~]# free -m              total       used       free     shared    buffers     cached Mem:           998        476        522          0         65        312 -/+ buffers/cache:         97        901 Swap:          996          0        996 [root@localhost ~]#

9、Traffic-visTraffic-vis是一套测定哪些主机在IP网进行通信、通信的目标主机以及传输的数据量。并输出纯文本、HTML或者GIF格式的报告。注:Traffic-vis仅仅适用于SUSE LINUX ENTERPRISE SERVER。如下命令用来收集网口eth0的信息:

1
traffic-collector -i eth0 -s /root/output_traffic-collector

1 traffic-collector -i eth0 -s /root/output_traffic-collector

可以使用killall命令来控制该进程。如果要将报告写入磁盘,可使用如下命令:

1
killall -9 traffic-collector

1 killall -9 traffic-collector

要停止对信息的收集,执行如下命令:killall -9 traffic-collector注意,不要忘记执行最后一条命令,否则会因为内存占用而影响性能。可以根据packets, bytes, TCP连接数对输出进行排序,根据每项的总数或者收/发的数量进行。例如根据主机上packets的收/发数量排序,执行命令:

1
traffic-sort -i output_traffic-collector -o output_traffic-sort -Hp

1 traffic-sort -i output_traffic-collector -o output_traffic-sort -Hp

如要生成HTML格式的报告,显示传输的字节数,packets的记录、全部TCP连接请求和网络中每台服务器的信息,请运行命令:

1
traffic-tohtml -i output_traffic-sort -o output_traffic-tohtml.html

1 traffic-tohtml -i output_traffic-sort -o output_traffic-tohtml.html

如要生成GIF格式(600X600)的报告,请运行命令:

1
traffic-togif -i output_traffic-sort -o output_traffic-togif.gif -x 600 -y 600

1 traffic-togif -i output_traffic-sort -o output_traffic-togif.gif -x 600 -y 600

GIF格式的报告可以方便地发现网络广播,查看哪台主机在TCP网络中使用IPX/SPX协议并隔离网络,需要记住的是,IPX是基于广播包的协议。如果我们需要查明例如网卡故障或重复IP的问题,需要使用特殊的工具。例如SUSE LINUX Enterprise Server自带的Ethereal。技巧和提示:使用管道,可以只需执行一条命令来产生报告。如生成HTML的报告,执行命令:

1
cat output_traffic-collector | traffic-sort -Hp | traffic-tohtml -o output_traffic-tohtml.html

1 cat output_traffic-collector | traffic-sort -Hp | traffic-tohtml -o output_traffic-tohtml.html

如要生成GIF文件,执行命令:

1
cat output_traffic-collector | traffic-sort -Hp | traffic-togif -o output_traffic-togif.gif -x 600 -y 600

1 cat output_traffic-collector | traffic-sort -Hp | traffic-togif -o output_traffic-togif.gif -x 600 -y 600

10、pmappmap可以报告某个或多个进程的内存使用情况。使用pmap判断主机中哪个进程因占用过多内存导致内存瓶颈。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@localhost ~]# pmap 1
1:   init [3]              
0000000000400000     36K r-x--  /sbin/init
0000000000609000      4K rw---  /sbin/init
000000000060a000    132K rw---    [ anon ]
00000039f8200000    112K r-x--  /lib64/ld-2.5.so
00000039f841b000      4K r----  /lib64/ld-2.5.so
00000039f841c000      4K rw---  /lib64/ld-2.5.so
00000039f8600000   1336K r-x--  /lib64/libc-2.5.so
00000039f874e000   2044K -----  /lib64/libc-2.5.so
00000039f894d000     16K r----  /lib64/libc-2.5.so
00000039f8951000      4K rw---  /lib64/libc-2.5.so
00000039f8952000     20K rw---    [ anon ]
00000039f8a00000      8K r-x--  /lib64/libdl-2.5.so
00000039f8a02000   2048K -----  /lib64/libdl-2.5.so
00000039f8c02000      4K r----  /lib64/libdl-2.5.so
00000039f8c03000      4K rw---  /lib64/libdl-2.5.so
00000039f9600000     84K r-x--  /lib64/libselinux.so.1
00000039f9615000   2048K -----  /lib64/libselinux.so.1
00000039f9815000      8K rw---  /lib64/libselinux.so.1
00000039f9817000      4K rw---    [ anon ]
00000039f9a00000    236K r-x--  /lib64/libsepol.so.1
00000039f9a3b000   2048K -----  /lib64/libsepol.so.1
00000039f9c3b000      4K rw---  /lib64/libsepol.so.1
00000039f9c3c000     40K rw---    [ anon ]
00007f51cc8f5000     12K rw---    [ anon ]
00007f51cc908000      8K rw---    [ anon ]
00007fffd48f4000     84K rw---    [ stack ]
00007fffd4917000      4K r-x--    [ anon ]
ffffffffff600000      4K r-x--    [ anon ]
 total            10360K
[root@localhost ~]#

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 [root@localhost ~]# pmap 1 1:   init [3]               0000000000400000     36K r-x--  /sbin/init 0000000000609000      4K rw---  /sbin/init 000000000060a000    132K rw---    [ anon ] 00000039f8200000    112K r-x--  /lib64/ld-2.5.so 00000039f841b000      4K r----  /lib64/ld-2.5.so 00000039f841c000      4K rw---  /lib64/ld-2.5.so 00000039f8600000   1336K r-x--  /lib64/libc-2.5.so 00000039f874e000   2044K -----  /lib64/libc-2.5.so 00000039f894d000     16K r----  /lib64/libc-2.5.so 00000039f8951000      4K rw---  /lib64/libc-2.5.so 00000039f8952000     20K rw---    [ anon ] 00000039f8a00000      8K r-x--  /lib64/libdl-2.5.so 00000039f8a02000   2048K -----  /lib64/libdl-2.5.so 00000039f8c02000      4K r----  /lib64/libdl-2.5.so 00000039f8c03000      4K rw---  /lib64/libdl-2.5.so 00000039f9600000     84K r-x--  /lib64/libselinux.so.1 00000039f9615000   2048K -----  /lib64/libselinux.so.1 00000039f9815000      8K rw---  /lib64/libselinux.so.1 00000039f9817000      4K rw---    [ anon ] 00000039f9a00000    236K r-x--  /lib64/libsepol.so.1 00000039f9a3b000   2048K -----  /lib64/libsepol.so.1 00000039f9c3b000      4K rw---  /lib64/libsepol.so.1 00000039f9c3c000     40K rw---    [ anon ] 00007f51cc8f5000     12K rw---    [ anon ] 00007f51cc908000      8K rw---    [ anon ] 00007fffd48f4000     84K rw---    [ stack ] 00007fffd4917000      4K r-x--    [ anon ] ffffffffff600000      4K r-x--    [ anon ]  total            10360K [root@localhost ~]#

11、stracestrace截取和记录系统进程调用,以及进程收到的信号。是一个非常有效的检测、指导和调试工具。系统管理员可以通过该命令容易地解决程序问题。

使用该命令需要指明进程的ID(PID),例如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@localhost ~]# strace -p 1
Process 1 attached - interrupt to quit
select(11, [10], NULL, NULL, {4, 868510}) = 0 (Timeout)
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
select(11, [10], NULL, NULL, {5, 0})    = 0 (Timeout)
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
select(11, [10], NULL, NULL, {5, 0})    = 0 (Timeout)
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
select(11, [10], NULL, NULL, {5, 0})    = 0 (Timeout)
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
select(11, [10], NULL, NULL, {5, 0}

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [root@localhost ~]# strace -p 1 Process 1 attached - interrupt to quit select(11, [10], NULL, NULL, {4, 868510}) = 0 (Timeout) stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 select(11, [10], NULL, NULL, {5, 0})    = 0 (Timeout) stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 select(11, [10], NULL, NULL, {5, 0})    = 0 (Timeout) stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 select(11, [10], NULL, NULL, {5, 0})    = 0 (Timeout) stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0 select(11, [10], NULL, NULL, {5, 0}

12、ulimit (常用)

ulimit内置在bash shell中,用来提供对shell和进程可用资源的控制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@localhost ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 8192
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 8192
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@localhost ~]#

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [root@localhost ~]# ulimit -a core file size          (blocks, -c) 0 data seg size           (kbytes, -d) unlimited scheduling priority             (-e) 0 file size               (blocks, -f) unlimited pending signals                 (-i) 8192 max locked memory       (kbytes, -l) 64 max memory size         (kbytes, -m) unlimited open files                      (-n) 1024 pipe size            (512 bytes, -p) 8 POSIX message queues     (bytes, -q) 819200 real-time priority              (-r) 0 stack size              (kbytes, -s) 8192 cpu time               (seconds, -t) unlimited max user processes              (-u) 8192 virtual memory          (kbytes, -v) unlimited file locks                      (-x) unlimited [root@localhost ~]#

-H和-S选项指明所给资源的软硬限制。如果超过了软限制,系统管理员会收到警告信息。硬限制指在用户收到超过文件句炳限制的错误信息之前,可以达到的最大值。例如可以设置对文件句炳的硬限制:ulimit -Hn 4096例如可以设置对文件句炳的软限制:ulimit -Sn 1024查看软硬值,执行如下命令:

1
2
ulimit -Hn
ulimit -Sn

1 2 ulimit -Hn ulimit -Sn

1
2
3
4
5
6
7
8
[root@localhost ~]#  mpstat 2 3
Linux 2.6.28l7 (localhost.localdomain)  07/05/2013
05:01:26 AM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
05:01:28 AM  all    0.00    0.00    0.00    0.00    0.00    0.14    0.00   99.86   3914.81
05:01:30 AM  all    0.00    0.00    0.12    0.00    0.00    0.00    0.00   99.88   4007.00
05:01:32 AM  all    0.00    0.00    0.25    0.00    0.00    0.12    0.00   99.62   4019.10
Average:     all    0.00    0.00    0.13    0.00    0.00    0.09    0.00   99.79   3981.46
[root@localhost ~]#

1 2 3 4 5 6 7 8 [root@localhost ~]#  mpstat 2 3 Linux 2.6.28l7 (localhost.localdomain)  07/05/2013 05:01:26 AM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s 05:01:28 AM  all    0.00    0.00    0.00    0.00    0.00    0.14    0.00   99.86   3914.81 05:01:30 AM  all    0.00    0.00    0.12    0.00    0.00    0.00    0.00   99.88   4007.00 05:01:32 AM  all    0.00    0.00    0.25    0.00    0.00    0.12    0.00   99.62   4019.10 Average:     all    0.00    0.00    0.13    0.00    0.00    0.09    0.00   99.79   3981.46 [root@localhost ~]#

如下命令每隔1秒显示一次多路CPU主机的处理器活动情况,执行3次

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@localhost ~]# mpstat -P ALL 1 3
Linux 2.6.28l7 (localhost.localdomain)  07/05/2013
05:02:15 AM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
05:02:16 AM  all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   4008.91
05:02:16 AM    0    0.00    0.00    0.99    0.00    0.00    0.00    0.00   99.01      4.95
05:02:16 AM    1    0.00    0.00    0.00    0.00    0.00    0.98    0.00   99.02      0.99
05:02:16 AM    2    0.00    0.00    0.99    0.00    0.00    0.00    0.00   99.01      0.00
05:02:16 AM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00
05:02:16 AM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
05:02:17 AM  all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   4005.00
05:02:17 AM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00
05:02:17 AM    1    0.99    0.00    0.00    0.00    0.00    0.00    0.00   99.01      3.00
05:02:17 AM    2    0.00    0.00    1.00    0.00    0.00    0.00    0.00   99.00      0.00
05:02:17 AM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00
05:02:17 AM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
05:02:18 AM  all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   4010.00
05:02:18 AM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      5.00
05:02:18 AM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      2.00
05:02:18 AM    2    0.00    0.00    1.00    0.00    0.00    0.00    0.00   99.00      0.00
05:02:18 AM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00
Average:     CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
Average:     all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   4007.97
Average:       0    0.00    0.00    0.33    0.00    0.00    0.00    0.00   99.67      3.32
Average:       1    0.33    0.00    0.00    0.00    0.00    0.33    0.00   99.34      1.99
Average:       2    0.00    0.00    1.00    0.00    0.00    0.00    0.00   99.00      0.00
Average:       3    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00
[root@localhost ~]#

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [root@localhost ~]# mpstat -P ALL 1 3 Linux 2.6.28l7 (localhost.localdomain)  07/05/2013 05:02:15 AM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s 05:02:16 AM  all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   4008.91 05:02:16 AM    0    0.00    0.00    0.99    0.00    0.00    0.00    0.00   99.01      4.95 05:02:16 AM    1    0.00    0.00    0.00    0.00    0.00    0.98    0.00   99.02      0.99 05:02:16 AM    2    0.00    0.00    0.99    0.00    0.00    0.00    0.00   99.01      0.00 05:02:16 AM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00 05:02:16 AM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s 05:02:17 AM  all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   4005.00 05:02:17 AM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00 05:02:17 AM    1    0.99    0.00    0.00    0.00    0.00    0.00    0.00   99.01      3.00 05:02:17 AM    2    0.00    0.00    1.00    0.00    0.00    0.00    0.00   99.00      0.00 05:02:17 AM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00 05:02:17 AM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s 05:02:18 AM  all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   4010.00 05:02:18 AM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      5.00 05:02:18 AM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      2.00 05:02:18 AM    2    0.00    0.00    1.00    0.00    0.00    0.00    0.00   99.00      0.00 05:02:18 AM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00 Average:     CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s Average:     all    0.00    0.00    0.25    0.00    0.00    0.00    0.00   99.75   4007.97 Average:       0    0.00    0.00    0.33    0.00    0.00    0.00    0.00   99.67      3.32 Average:       1    0.33    0.00    0.00    0.00    0.00    0.33    0.00   99.34      1.99 Average:       2    0.00    0.00    1.00    0.00    0.00    0.00    0.00   99.00      0.00 Average:       3    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00      0.00 [root@localhost ~]#

上面就是铁匠为大家推荐和演示的几款监控工具的用法.

上一篇:淘宝开发:Nginx经典模块(Nginx+Http+Footer+Filter)
下一篇:成都智能运维公司(成都运维培训哪家机构好)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~