1.1监控系统状态 -w
[root@niejicai-linux ~]# w 系统负载 1分钟内;5分钟内;15分钟 内;
16:02:39 up 17:25, 2 users, load
average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - Wed21 6:30m 0.44s 0.44s -bash 本地登录
root pts/0 192.168.1.217 09:44 0.00s 1.58s 0.00s w 远程登录
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.2ab 压力测试工具(Apache自带的)
[root@niejicai-linux ~]#ab -n 10000 -c 100 ‘http://bbs.hh010.com/forum-143-1.html’
10000次 ;并发量为100
[root@niejicai-linux
~]#ab -n 10000 -c 100 ‘http://ww.ypl.cc/forum.php' (这里会去请求数据库),系统加载会很高!
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.3怎么去查看cpu信息
[root@niejicai-linux ~]# cat /proc/cpuinfo
processor : 0(这个是总的核,有人问你cpu多少核直接回答这个就可以了)
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Celeron(R) CPU 1000M @ 1.80GHz
stepping : 9
microcode : 19
cpu MHz : 1795.979
cache size : 2048 KB
physical id : 0
siblings : 1
core id : 0 但是要真正的多少核,主要是看这里
cpu cores : 1
apicid : 0
initial apicid : 0
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss nx rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt xsave hypervisor lahf_lm arat epb xsaveopt pln pts dts fsgsbase smep
bogomips : 3591.95
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:
[root@niejicai-linux ~]# cat /proc/cpuinfo |grep 'core id'
core id : 0
[ root@niejicai-linux ~]#
[root@niejicai-linux ~]# uptime 启动时间
16:41:57 up 18:04, 2 users, load average: 0.00, 0.00, 0.00
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.4 top
监控系统状态 – top
用于动态监控进程所占系统资源,每隔3秒变一次。
RES 这一项为进程所占内存大小,而 %MEM 为使用内存百分比。在 top状态下,按 “shift + m”, 可以按照内存使用大小排序。按数字 ‘1’ 可以列出各颗cpu的使用状态。
top -bn1 它表示非动态打印系统资源使用情况,可以用在shell脚本中
top -c 最右侧的命令可以显示更详细的信息
[root@niejicai-linux ~]# top
top - 16:43:28 up 18:05, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 94 total, 1 running, 93 sleeping, 0 stopped, 0
zombie僵尸
Cpu(s): 0.3%us,
0.3%sy, 0.0%ni, 99.3%id,
0.0%wa, 0.0%hi, 0.0%si, 0.0%st
内核进程 处理过程需要等待的时间
Mem: 248724k total, 188352k used, 60372k free, 67940k
buffers
内存 总内存 所使用的内存 空闲的内存 缓冲
Swap: 1048572k total, 0k used, 1048572k free, 65340k
cached
缓存
列子:
cpu <------------->内存 <----------->硬盘
-----------> <------------
buffers cached
缓冲 缓存
-------------------------------------------->硬盘
进程 user 实时优先级 优先值 虚拟内存 真正内存 共享内存 状态 cpu使用率 内存使用率 时间 命令
PID USER PR NI VIRT
RES SHR S
%CPU
%MEM TIME+ COMMAND
1551 root 20 0 38936 4204 3424 S 0.3 1.7 2:03.11 vmtoolsd
1 root 20 0 2900 1432 1208 S 0.0 0.6 0:02.39 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:01.51 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 stopper/0
6 root RT 0 0 0 0 S 0.0 0.0 0:02.90 watchdog/0
7 root 20 0 0 0 0 S 0.0 0.0 0:06.81 events/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 events/0
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 events_long/0
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 events_power_ef
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cgroup
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 netns
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 async/mgr
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pm
[root@niejicai-linux ~]# top 然后按照”1“,就可以列出cpu的所有核数的具体情况!
top - 17:03:01 up 18:25, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 94 total, 1 running, 93 sleeping, 0 stopped, 0 zombie
Cpu0 : 0.0%us, 0.3%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 248724k total, 188592k used, 60132k free, 68236k buffers
Swap: 1048572k total, 0k used, 1048572k free, 65348k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1551 root 20 0 38936 4204 3424 S 0.3 1.7 2:04.81 vmtoolsd
1 root 20 0 2900 1432 1208 S 0.0 0.6 0:02.39 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:01.52 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 stopper/0
6 root RT 0 0 0 0 S 0.0 0.0 0:02.91 watchdog/0
7 root 20 0 0 0 0 S 0.0 0.0 0:06.88 events/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 events/0
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 events_long/0
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 events_power_ef
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cgroup
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 netns
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 async/mgr
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pm
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.5 vmstat
vmstat各指标含义:
r :表示运行和等待cpu时间片的进程数,如果长期大于服务器cpu的个数,则说明cpu不够用了;
b :表示等待资源的进程数,比如等待I/O, 内存等,这列的值如果长时间大于1,则需要关注一下了
si :由交换区进入内存的数量;
so :由内存进入交换区的数量;
bi :从块设备读取数据的量(读磁盘);
bo: 从块设备写入数据的量(写磁盘);
in : 每秒的中断次数,包含时钟中断;
cs : 每秒的上下文切换次数;
wa :表示I/O等待所占用cpu时间百分比.
[ root@niejicai-linux ~]# vmstat 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 58812 69088 65628 0 0 2 1 22 31 0 0 100 0 0
0 0 0 58804 69088 65628 0 0 0 0 24 32 0 0 100 0 0
0 0 0 58804 69096 65620 0 0 0 36 38 44 0 0 100 0 0
0 0 0 58804 69096 65628 0 0 0 0 25 32 0 0 100 0 0
0 0 0 58804 69096 65628 0 0 0 0 21 30 0 0 100 0 0
0 0 0 58804 69096 65628 0 0 0 0 26 33 0 1 99 0 0
0 0 0 58804 69096 65628 0 0 0 0 26 34 0 0 100 0 0
0 0 0 58804 69096 65628 0 0 0 0 26 34 0 0 100 0 0
0 0 0 58804 69104 65624 0 0 0 36 28 41 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 23 30 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 24 32 0 1 99 0 0
0 0 0 58804 69104 65628 0 0 0 68 38 42 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 33 32 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 22 28 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 24 31 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 21 30 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 28 34 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 28 35 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 25 30 0 1 99 0 0
0 0 0 58804 69104 65628 0 0 0 0 26 30 0 0 100 0 0
0 0 0 58804 69104 65628 0 0 0 0 25 33 0 0 100 0 0
测试一下
b的值(堵塞)
[root@niejicai-linux ~]# dd if=/dev/zero of=/root/1.log bs=1M count=1000 &
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.6ps
ps 查看系统进程
ps aux / ps -elf
PID :进程的id,这个id很有用,在linux中内核管理进程就得靠pid来识别和管理某一个程,比如我想终止某一个进
程,则用 ‘kill 进程的pid’ 有时并不能杀掉,则需要加一个-9选项了 kill -9 进程pid
STAT :表示进程的状态,进程状态分为以下几种
D 不能中断的进程(通常为IO)
R 正在运行中的进程
S 已经中断的进程,系统中大部分进程都是这个状态
T 已经停止或者暂停的进程,如果我们正在运行一个命令,比如说 sleep 10 如果我们按一下ctrl -z 让他暂停,那
么我们用ps查看就会显示T这个状态
X 已经死掉的进程(这个从来不会出现)
Z 僵尸进程,杀不掉,打不死的垃圾进程,占系统一小点资源,不过没有关系。如果太多,就有问题了。
< 高优先级进程
N 低优先级进程
L 在内存中被锁了内存分页
s 主进程
l 多线程进程
+ 在前台的进程
[root@niejicai-linux ~]# ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 0 6449 6447 0 80 0 - 1315 - pts/0 00:00:00 bash
4 R 0 6512 6449 0 80 0 - 1221 - pts/0 00:00:00 ps
[root@niejicai-linux ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.5 2900 1320 ? Ss Dec05 0:02 /sbin/init
root 2 0.0 0.0 0 0 ? S Dec05 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Dec05 0:00 [migration/0]
root 4 0.0 0.0 0 0 ? S Dec05 0:01 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S Dec05 0:00 [stopper/0]
root 6 0.0 0.0 0 0 ? S Dec05 0:06 [watchdog/0]
root 7 0.0 0.0 0 0 ? S Dec05 0:09 [events/0]
root 8 0.0 0.0 0 0 ? S Dec05 0:00 [events/0]
。。。。。。。。。。。。。。。。。。。。。。。。。
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.7 pstree
[root@niejicai-linux ~]# pstree
init─┬─NetworkManager
├─abrtd
├─acpid
├─atd
├─auditd───{auditd}
├─console-kit-dae───63*[{console-kit-da}]
├─crond
├─cupsd
├─dbus-daemon
├─hald─┬─hald-runner─┬─hald-addon-acpi
│ │ └─hald-addon-inpu
│ └─{hald}
├─login───bash───ping
├─master─┬─pickup
│ └─qmgr
├─5*[mingetty]
├─modem-manager
├─polkitd
├─rsyslogd───3*[{rsyslogd}]
├─sshd─┬─sshd───bash
│ └─sshd───bash───pstree
├─udevd───2*[udevd]
├─vmtoolsd───{vmtoolsd}
├─vmware-vmblock-───2*[{vmware-vmblock}]
└─wpa_supplicant
[root@niejicai-linux ~]# free
total used free shared buffers cached
Mem: 248724 127088 121636 212 46152 27336
-/+ buffers/cache: 53600 195124
Swap: 1048572 0 1048572
[root@niejicai-linux ~]# free -m
total used free shared buffers cached
Mem: 242 124 118 0 45 26
-/+ buffers/cache: 52
190 (真正所剩余的内存大小)
Swap: 1023 0 1023
[
root@niejicai-linux ~]# free -g
total used free shared buffers cached
Mem: 0 0 0 0 0 0
-/+ buffers/cache: 0 0
Swap: 0 0 0
[ root@niejicai-linux ~]#
真正剩余的内存=cached +buffers+free
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.8 nestat
netstat 查看网络状况
netstat -lnp 查看当前系统开启的端口以及socket
netstat -an 查看当前系统所有的连接
[root@niejicai-linux ~]# netstat -lnp (监听端口)以及监听所有端口的ip
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2102/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1952/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2268/master
tcp 0 0 :::22 :::* LISTEN 2102/sshd
tcp 0 0 ::1:631 :::* LISTEN 1952/cupsd
tcp 0 0 ::1:25 :::* LISTEN 2268/master
udp 0 0 0.0.0.0:631 0.0.0.0:* 1952/cupsd
raw 1032 0 0.0.0.0:1 0.0.0.0:* 7 6443/ping
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 10795 1999/hald @/var/run/hald/dbus-JFFm4yJQPb
unix 2 [ ACC ] STREAM LISTENING 10790 1999/hald @/var/run/hald/dbus-d1xNzwDZE6
unix 2 [ ACC ] STREAM LISTENING 10525 1915/dbus-daemon /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 10690 1952/cupsd /var/run/cups/cups.sock
unix 2 [ ACC ] STREAM LISTENING 11617 2268/master public/cleanup
unix 2 [ ACC ] STREAM LISTENING 11624 2268/master private/tlsmgr
unix 2 [ ACC ] STREAM LISTENING 7374 1/init @/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 11628 2268/master private/rewrite
unix 2 [ ACC ] STREAM LISTENING 11632 2268/master private/bounce
unix 2 [ ACC ] STREAM LISTENING 11636 2268/master private/defer
unix 2 [ ACC ] STREAM LISTENING 11640 2268/master private/trace
unix 2 [ ACC ] STREAM LISTENING 11644 2268/master private/verify
unix 2 [ ACC ] STREAM LISTENING 11648 2268/master public/flush
unix 2 [ ACC ] STREAM LISTENING 11652 2268/master private/proxymap
unix 2 [ ACC ] STREAM LISTENING 11656 2268/master private/proxywrite
unix 2 [ ACC ] STREAM LISTENING 11777 2297/abrtd /var/run/abrt/abrt.socket
unix 2 [ ACC ] STREAM LISTENING 11660 2268/master private/smtp
unix 2 [ ACC ] STREAM LISTENING 11664 2268/master private/relay
unix 2 [ ACC ] STREAM LISTENING 11668 2268/master public/showq
unix 2 [ ACC ] STREAM LISTENING 11672 2268/master private/error
unix 2 [ ACC ] STREAM LISTENING 11676 2268/master private/retry
unix 2 [ ACC ] STREAM LISTENING 11680 2268/master private/discard
unix 2 [ ACC ] STREAM LISTENING 11684 2268/master private/local
unix 2 [ ACC ] STREAM LISTENING 11688 2268/master private/virtual
unix 2 [ ACC ] STREAM LISTENING 11692 2268/master private/lmtp
unix 2 [ ACC ] STREAM LISTENING 11696 2268/master private/anvil
unix 2 [ ACC ] STREAM LISTENING 11700 2268/master private/scache
unix 2 [ ACC ] STREAM LISTENING 10757 1987/acpid /var/run/acpid.socket
[ root@niejicai-linux ~]#
[root@niejicai-linux ~]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2102/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1952/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2268/master
tcp 0 0 :::22 :::* LISTEN 2102/sshd
tcp 0 0 ::1:631 :::* LISTEN 1952/cupsd
tcp 0 0 ::1:25 :::* LISTEN 2268/master
[ root@niejicai-linux ~]#
[root@niejicai-linux ~]# netstat -an (查看系统所有的TCP/ip的连接状态)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.218:22 192.168.0.217:49747
ESTABLISHED
tcp 0 0 192.168.0.218:22 192.168.0.217:51720 ESTABLISHED
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:631 :::* LISTEN
tcp 0 0 ::1:25 :::* LISTEN
udp 0 0 192.168.0.218:57949 211.138.245.180:53 ESTABLISHED
udp 0 0 0.0.0.0:631 0.0.0.0:*
raw 1032 0 0.0.0.0:1 0.0.0.0:* 7
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 10795 @/var/run/hald/dbus-JFFm4yJQPb
unix 2 [ ACC ] STREAM LISTENING 10790 @/var/run/hald/dbus-d1xNzwDZE6
unix 2 [ ACC ] STREAM LISTENING 10525 /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 10690 /var/run/cups/cups.sock
unix 2 [ ACC ] STREAM LISTENING 11617 public/cleanup
unix 2 [ ACC ] STREAM LISTENING 11624 private/tlsmgr
unix 2 [ ACC ] STREAM LISTENING 7374 @/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 11628 private/rewrite
unix 2 [ ACC ] STREAM LISTENING 11632 private/bounce
unix 2 [ ACC ] STREAM LISTENING 11636 private/defer
unix 2 [ ACC ] STREAM LISTENING 11640 private/trace
unix 2 [ ACC ] STREAM LISTENING 11644 private/verify
unix 2 [ ACC ] STREAM LISTENING 11648 public/flush
unix 2 [ ACC ] STREAM LISTENING 11652 private/proxymap
unix 2 [ ACC ] STREAM LISTENING 11656 private/proxywrite
unix 2 [ ACC ] STREAM LISTENING 11777 /var/run/abrt/abrt.socket
unix 2 [ ACC ] STREAM LISTENING 11660 private/smtp
unix 2 [ ACC ] STREAM LISTENING 11664 private/relay
unix 2 [ ACC ] STREAM LISTENING 11668 public/showq
unix 2 [ ACC ] STREAM LISTENING 11672 private/error
unix 2 [ ACC ] STREAM LISTENING 11676 private/retry
unix 2 [ ACC ] STREAM LISTENING 11680 private/discard
unix 2 [ ACC ] STREAM LISTENING 11684 private/local
unix 2 [ ACC ] STREAM LISTENING 11688 private/virtual
unix 2 [ ACC ] STREAM LISTENING 11692 private/lmtp
unix 2 [ ACC ] STREAM LISTENING 11696 private/anvil
unix 2 [ ACC ] STREAM LISTENING 11700 private/scache
unix 2 [ ] DGRAM 10820 @/org/freedesktop/hal/udev_event
unix 2 [ ] DGRAM 7779 @/org/kernel/udev/udevd
unix 2 [ ACC ] STREAM LISTENING 10757 /var/run/acpid.socket
unix 13 [ ] DGRAM 10416 /dev/log
unix 2 [ ] DGRAM 117825
unix 2 [ ] DGRAM 116275
unix 2 [ ] DGRAM 115784
unix 2 [ ] DGRAM 94189
unix 3 [ ] STREAM CONNECTED 23463 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 23462
unix 3 [ ] STREAM CONNECTED 23175 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 23174
unix 3 [ ] STREAM CONNECTED 23151 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 23150
unix 3 [ ] STREAM CONNECTED 23139 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 23138
unix 3 [ ] STREAM CONNECTED 23079 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 23078
unix 2 [ ] DGRAM 11807
unix 2 [ ] DGRAM 11779
unix 2 [ ] DGRAM 11758
unix 3 [ ] STREAM CONNECTED 11703
unix 3 [ ] STREAM CONNECTED 11702
unix 3 [ ] STREAM CONNECTED 11699
unix 3 [ ] STREAM CONNECTED 11698
unix 3 [ ] STREAM CONNECTED 11695
unix 3 [ ] STREAM CONNECTED 11694
unix 3 [ ] STREAM CONNECTED 11691
unix 3 [ ] STREAM CONNECTED 11690
unix 3 [ ] STREAM CONNECTED 11687
unix 3 [ ] STREAM CONNECTED 11686
unix 3 [ ] STREAM CONNECTED 11683
unix 3 [ ] STREAM CONNECTED 11682
unix 3 [ ] STREAM CONNECTED 11679
unix 3 [ ] STREAM CONNECTED 11678
unix 3 [ ] STREAM CONNECTED 11675
unix 3 [ ] STREAM CONNECTED 11674
unix 3 [ ] STREAM CONNECTED 11671
unix 3 [ ] STREAM CONNECTED 11670
unix 3 [ ] STREAM CONNECTED 11667
unix 3 [ ] STREAM CONNECTED 11666
unix 3 [ ] STREAM CONNECTED 11663
unix 3 [ ] STREAM CONNECTED 11662
unix 3 [ ] STREAM CONNECTED 11659
unix 3 [ ] STREAM CONNECTED 11658
unix 3 [ ] STREAM CONNECTED 11655
unix 3 [ ] STREAM CONNECTED 11654
unix 3 [ ] STREAM CONNECTED 11651
unix 3 [ ] STREAM CONNECTED 11650
unix 3 [ ] STREAM CONNECTED 11647
unix 3 [ ] STREAM CONNECTED 11646
unix 3 [ ] STREAM CONNECTED 11643
unix 3 [ ] STREAM CONNECTED 11642
unix 3 [ ] STREAM CONNECTED 11639
unix 3 [ ] STREAM CONNECTED 11638
unix 3 [ ] STREAM CONNECTED 11635
unix 3 [ ] STREAM CONNECTED 11634
unix 3 [ ] STREAM CONNECTED 11631
unix 3 [ ] STREAM CONNECTED 11630
unix 3 [ ] STREAM CONNECTED 11627
unix 3 [ ] STREAM CONNECTED 11626
unix 3 [ ] STREAM CONNECTED 11623
unix 3 [ ] STREAM CONNECTED 11622
unix 3 [ ] STREAM CONNECTED 11620
unix 3 [ ] STREAM CONNECTED 11619
unix 3 [ ] STREAM CONNECTED 11616
unix 3 [ ] STREAM CONNECTED 11615
unix 3 [ ] STREAM CONNECTED 11613
unix 3 [ ] STREAM CONNECTED 11612
unix 2 [ ] DGRAM 11572
unix 3 [ ] STREAM CONNECTED 11149 /var/run/acpid.socket
unix 3 [ ] STREAM CONNECTED 11148
unix 3 [ ] STREAM CONNECTED 11141 @/var/run/hald/dbus-d1xNzwDZE6
unix 3 [ ] STREAM CONNECTED 11140
unix 3 [ ] STREAM CONNECTED 11039 @/var/run/hald/dbus-d1xNzwDZE6
unix 3 [ ] STREAM CONNECTED 11037
unix 3 [ ] STREAM CONNECTED 10815 @/var/run/hald/dbus-JFFm4yJQPb
unix 3 [ ] STREAM CONNECTED 10814
unix 3 [ ] STREAM CONNECTED 10792 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 10791
unix 2 [ ] DGRAM 10761
unix 3 [ ] STREAM CONNECTED 10683 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 10682
unix 3 [ ] STREAM CONNECTED 10628 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 10627
unix 2 [ ] DGRAM 10626
unix 3 [ ] STREAM CONNECTED 10580 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 10579
unix 3 [ ] STREAM CONNECTED 10570 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 10569
unix 2 [ ] DGRAM 10563
unix 3 [ ] STREAM CONNECTED 10537 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 10536
unix 3 [ ] STREAM CONNECTED 10530
unix 3 [ ] STREAM CONNECTED 10529
unix 3 [ ] DGRAM 7800
unix 3 [ ] DGRAM 7799
[ root@niejicai-linux ~]#
[root@niejicai-linux ~]# netstat -an | wc -l
139 (这个数字很小说明很闲。65535(就要考虑加服务器了)
[ root@niejicai-linux ~]#
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.9 sar
监控系统状态 – sar
没有这个命令,使用yum install -y sysstat
网卡流量 sar -n DEV, sar -n DEV 1 10
sar -n DEV -f /var/log/sa/sa24
查看历史负载 sar -q
查看磁盘读写 sar -b
测试:
[root@niejicai-linux ~]# sar -n DEV 1 10 (查看网卡流量)最常用的选项!
Linux 2.6.32-573.7.1.el6.i686 (niejicai-linux) 12/06/2015 _i686_ (1 CPU)
06:15:21 PM IFACE
rxpck/s txpck/s
rxkB/s
txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:22 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:22 PM eth0 2.11 1.05 0.12 0.19 0.00 0.00 0.00
06:15:22 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:23 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:23 PM eth0 2.02 1.01 0.12 0.38 0.00 0.00 0.00
06:15:23 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:24 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:24 PM eth0 2.00 1.00 0.12 0.38 0.00 0.00 0.00
06:15:24 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:25 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:25 PM eth0 2.04 1.02 0.12 0.39 0.00 0.00 0.00
06:15:25 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:26 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:26 PM eth0 1.98 0.99 0.12 0.38 0.00 0.00 0.00
06:15:26 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:27 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:27 PM eth0 2.02 1.01 0.12 0.38 0.00 0.00 0.00
06:15:27 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:28 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:28 PM eth0 2.13 1.06 0.12 0.41 0.00 0.00 0.00
06:15:28 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:29 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:29 PM eth0 2.00 1.00 0.12 0.38 0.00 0.00 0.00
06:15:29 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:30 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:30 PM eth0 2.00 1.00 0.12 0.38 0.00 0.00 0.00
06:15:30 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
06:15:31 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
06:15:31 PM eth0 12.12 1.01 0.71 0.38 0.00 0.00 0.00
Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
Average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Average: eth0 3.05 1.02 0.18 0.37 0.00 0.00 0.00
[ root@niejicai-linux ~]#
[root@niejicai-linux ~]# sar -q
Linux 2.6.32-573.7.1.el6.i686 (niejicai-linux) 12/06/2015 _i686_ (1 CPU)
05:40:05 PM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
05:50:01 PM 0 169 0.00 0.02 0.00
06:00:01 PM 0 169 0.00 0.00 0.00
06:10:02 PM 0 170 0.00 0.00 0.00
06:20:01 PM 0 170 0.00 0.00 0.00
Average: 0 170 0.00 0.01 0.00
[root@niejicai-linux ~]# sar -q -f /var/log/sa/sa10 可以指定文件名,这里的10,表示10号的。
Linux 2.6.32-431.el6.i686 (localhost.localdomain) 11/10/2015 _i686_ (1 CPU)
06:26:24 PM LINUX RESTART
07:19:22 PM LINUX RESTART
04:00:01 PM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
04:10:01 PM 0 159 0.25 0.06 0.15
Average: 0 159 0.25 0.06 0.15
04:10:38 PM LINUX RESTART
04:15:09 PM LINUX RESTART
04:20:11 PM LINUX RESTART
04:23:25 PM LINUX RESTART
04:28:35 PM LINUX RESTART
04:30:01 PM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
04:40:02 PM 0 185 0.00 0.01 0.00
Average: 0 185 0.00 0.01 0.00
08:58:48 PM LINUX RESTART
09:01:25 PM LINUX RESTART
09:11:00 PM LINUX RESTART
09:20:01 PM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
09:30:01 PM 0 185 0.00 0.00 0.00
09:40:02 PM 0 185 0.00 0.00 0.00
09:50:01 PM 0 185 0.00 0.00 0.00
10:00:01 PM 0 185 0.00 0.00 0.00
10:10:01 PM 0 186 0.00 0.00 0.00
10:20:01 PM 0 186 0.00 0.00 0.00
10:30:01 PM 0 186 0.00 0.00 0.00
10:40:02 PM 0 185 0.54 0.56 0.25
10:50:01 PM 0 185 0.00 0.06 0.11
11:00:01 PM 0 185 0.00 0.00 0.04
11:10:01 PM 0 185 0.00 0.00 0.00
11:20:01 PM 0 185 0.00 0.00 0.00
11:30:01 PM 0 185 0.00 0.00 0.00
Average: 0 185 0.04 0.05 0.03
10:00:20 AM LINUX RESTART
10:04:37 AM LINUX RESTART
10:10:33 AM LINUX RESTART
10:20:01 AM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
10:30:01 AM 0 95 0.00 0.00 0.00
10:40:01 AM 0 95 0.00 0.00 0.00
10:50:01 AM 0 95 0.00 0.00 0.00
11:10:01 AM 0 93 0.00 0.02 0.01
11:20:01 AM 0 95 0.12 0.03 0.01
11:30:01 AM 0 95 0.00 0.00 0.00
Average: 0 95 0.02 0.01 0.00
11:32:04 AM LINUX RESTART
11:40:01 AM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
11:50:01 AM 0 99 0.00 0.00 0.00
Average: 0 99 0.00 0.00 0.00
11:59:24 AM LINUX RESTART
[ root@niejicai-linux ~]#
[root@niejicai-linux ~]# sar -b
Linux 2.6.32-573.7.1.el6.i686 (niejicai-linux) 12/06/2015 _i686_ (1 CPU)
05:40:05 PM tps rtps wtps bread/s bwrtn/s
05:50:01 PM 0.38 0.10 0.27 2.07 3.60
06:00:01 PM 0.17 0.01 0.16 0.11 1.99
06:10:02 PM 0.18 0.02 0.16 0.87 2.05
06:20:01 PM 0.43 0.21 0.21 4.97 3.44
Average: 0.29 0.08 0.20 2.00 2.77