Linux系统监控命令
ps 查看进程
top 显示根据cpu使用率排序的活动进程
uptime 显示系统运行了多长时间。并显示用户登录数的相关信息
free 显示内存使用率
vmstat 显示内存、分页、块传输和CPU活动的相关信息
iostat 显示平均磁盘活动和处理负载情况
netstat 显示网络活动相关信息
mpstat 显示多处理器系统的使用率
pmap 显示各种进程分别占用内存情况
sar 显示系统活动报告
要使用sar iostat mpstat pmap需要先安装systat包,
下载地址:wget http://pagesperso-orange.fr/sebastien.godard/sysstat-10.1.2.tar.bz2
tar -jxvf sysstat-10.1.2.tar.bz2
make
make install
[root@master1 ~]# uptime
16:57:18 up 2 days, 1 min, 2 users, load average: 0.07, 0.03, 0.00
[root@master1 ~]# iostat
Linux 2.6.18-308.el5 (master1) 03/06/2013
avg-cpu: %user %nice %system %iowait %steal %idle
0.32 0.08 1.15 0.12 0.00 98.33
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 0.47 6.51 11.49 1110965 1960276
sda1 0.00 0.01 0.00 2090 20
sda2 0.47 6.49 11.49 1106834 1960096
sda3 0.00 0.01 0.00 1617 160
[root@master1 ~]# vmstat
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 80 24884 56524 206840 0 0 3 6 4 34 0 1 98 0 0
[root@master1 ~]# sar 2 5
Linux 2.6.18-308.el5 (master1) 03/06/2013
04:49:19 PM CPU %user %nice %system %iowait %steal %idle
04:49:21 PM all 0.00 0.00 1.02 0.00 0.00 98.98
04:49:23 PM all 0.00 0.00 1.01 0.00 0.00 98.99
04:49:25 PM all 0.00 0.00 1.52 0.00 0.00 98.48
04:49:27 PM all 0.00 0.00 1.01 0.00 0.00 98.99
04:49:29 PM all 0.00 0.00 1.51 0.00 0.00 98.49
Average: all 0.00 0.00 1.21 0.00 0.00 98.79
[root@master1 ~]# mpstat
Linux 2.6.18-308.el5 (master1) 03/06/2013
04:49:57 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
04:49:57 PM all 0.32 0.08 0.40 0.12 0.04 0.70 0.00 98.33 1010.73
[root@master1 ~]# pmap -d 6342
6342: /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --log-error=/usr/local/mysql/var/master1.err --pid-file=/usr/local/mysql/var/master1.pid --socket=/tmp/mysql.sock --port=3306
Address Kbytes Mode Offset Device Mapping
00110000 40 r-x-- 0000000000000000 008:00002 libnss_files-2.5.so
0011a000 4 r-x-- 0000000000009000 008:00002 libnss_files-2.5.so
0011b000 4 rwx-- 000000000000a000 008:00002 libnss_files-2.5.so
0024f000 108 r-x-- 0000000000000000 008:00002 ld-2.5.so
0026a000 4 r-x-- 000000000001a000 008:00002 ld-2.5.so
0026b000 4 rwx-- 000000000001b000 008:00002 ld-2.5.so
00360000 4 r-x-- 0000000000360000 000:00000 [ anon ]
003ca000 12 r-x-- 0000000000000000 008:00002 libdl-2.5.so
003cd000 4 r-x-- 0000000000002000 008:00002 libdl-2.5.so
003ce000 4 rwx-- 0000000000003000 008:00002 libdl-2.5.so
003d1000 84 r-x-- 0000000000000000 008:00002 libpthread-2.5.so
003e6000 4 --x-- 0000000000015000 008:00002 libpthread-2.5.so
003e7000 4 r-x-- 0000000000015000 008:00002 libpthread-2.5.so
003e8000 4 rwx-- 0000000000016000 008:00002 libpthread-2.5.so
003e9000 8 rwx-- 00000000003e9000 000:00000 [ anon ]
003ed000 156 r-x-- 0000000000000000 008:00002 libm-2.5.so
00414000 4 r-x-- 0000000000026000 008:00002 libm-2.5.so
00415000 4 rwx-- 0000000000027000 008:00002 libm-2.5.so
00418000 72 r-x-- 0000000000000000 008:00002 libz.so.1.2.3
0042a000 4 rwx-- 0000000000011000 008:00002 libz.so.1.2.3
0053a000 36 r-x-- 0000000000000000 008:00002 libcrypt-2.5.so
00543000 4 r-x-- 0000000000008000 008:00002 libcrypt-2.5.so
00544000 4 rwx-- 0000000000009000 008:00002 libcrypt-2.5.so
00545000 156 rwx-- 0000000000545000 000:00000 [ anon ]
006a5000 44 r-x-- 0000000000000000 008:00002 libgcc_s-4.1.2-20080825.so.1
006b0000 4 rwx-- 000000000000a000 008:00002 libgcc_s-4.1.2-20080825.so.1
006be000 84 r-x-- 0000000000000000 008:00002 libnsl-2.5.so
006d3000 4 r-x-- 0000000000014000 008:00002 libnsl-2.5.so
006d4000 4 rwx-- 0000000000015000 008:00002 libnsl-2.5.so
006d5000 8 rwx-- 00000000006d5000 000:00000 [ anon ]
006d7000 1356 r-x-- 0000000000000000 008:00002 libc-2.5.so
0082a000 4 --x-- 0000000000153000 008:00002 libc-2.5.so
0082b000 8 r-x-- 0000000000153000 008:00002 libc-2.5.so
0082d000 4 rwx-- 0000000000155000 008:00002 libc-2.5.so
0082e000 12 rwx-- 000000000082e000 000:00000 [ anon ]
0095e000 16 r-x-- 0000000000000000 008:00002 libnss_dns-2.5.so
00962000 4 r-x-- 0000000000003000 008:00002 libnss_dns-2.5.so
00963000 4 rwx-- 0000000000004000 008:00002 libnss_dns-2.5.so
00a74000 68 r-x-- 0000000000000000 008:00002 libresolv-2.5.so
00a85000 4 r-x-- 0000000000010000 008:00002 libresolv-2.5.so
00a86000 4 rwx-- 0000000000011000 008:00002 libresolv-2.5.so
00a87000 8 rwx-- 0000000000a87000 000:00000 [ anon ]
00aef000 896 r-x-- 0000000000000000 008:00002 libstdc++.so.6.0.8
00bcf000 16 r-x-- 00000000000df000 008:00002 libstdc++.so.6.0.8
00bd3000 4 rwx-- 00000000000e3000 008:00002 libstdc++.so.6.0.8
00bd4000 24 rwx-- 0000000000bd4000 000:00000 [ anon ]
08048000 4416 r-x-- 0000000000000000 008:00002 mysqld
08498000 268 rw--- 0000000000450000 008:00002 mysqld
084db000 44 rw--- 00000000084db000 000:00000 [ anon ]
08a44000 900 rw--- 0000000008a44000 000:00000 [ anon ]
b643a000 4 ----- 00000000b643a000 000:00000 [ anon ]
b643b000 192 rw--- 00000000b643b000 000:00000 [ anon ]
b646b000 4 ----- 00000000b646b000 000:00000 [ anon ]
b646c000 192 rw--- 00000000b646c000 000:00000 [ anon ]
b649c000 4 ----- 00000000b649c000 000:00000 [ anon ]
b649d000 192 rw--- 00000000b649d000 000:00000 [ anon ]
b64cd000 4 ----- 00000000b64cd000 000:00000 [ anon ]
b64ce000 16580 rw--- 00000000b64ce000 000:00000 [ anon ]
b74ff000 4 ----- 00000000b74ff000 000:00000 [ anon ]
b7500000 10256 rw--- 00000000b7500000 000:00000 [ anon ]
b7f0e000 4 rw--- 00000000b7f0e000 000:00000 [ anon ]
bfd66000 84 rw--- 00000000bffe9000 000:00000 [ stack ]
mapped: 36460K writeable/private: 28980K shared: 0K