第十章 日常运维

  • w查看系统负载

[root@izm5e9voc4k5nenpa42yb3z ~]# w

 22:49:45 up  2 min,  3 users,  load average: 0.02, 0.04, 0.02

USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

root     tty1                             22:47    2:01   0.00s  0.00s -bash

root     pts/0    101.92.172.88    22:48    1:13   0.00s  0.00s -bash

root     pts/1     101.92.172.88    22:49    1.00s  0.00s  0.00s w

说明如下:

 22:49:45 up          系统时间(当前时间) 

 2 min                   系统启动的时长

 3 users                 登录的用户数

 load average         单位时间内使用CPU活动进程的个数;

扫描二维码关注公众号,回复: 1244658 查看本文章

 0.02, 0.04, 0.02     一分钟,五分钟,十五分钟(段内); 

root     tty1                             22:47    2:01   0.00s  0.00s -bash  【主机直接登录】

root     pts/0    101.92.172.88    22:48    1:13   0.00s  0.00s -bash  【远程登录】

root     pts/1     101.92.172.88    22:49    1.00s  0.00s  0.00s w       【远程登录】

  • vmstat命令 

[root@izm5e9voc4k5nenpa42yb3z ~]# vmstat 1 5  【每秒显示一次,展现五次退出】

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----

 r   b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

 3  0      0 805072  11032 132760    0    0   117     9  172  302  1  0 99  0  0

 0  0      0 805088  11032 132760    0    0     0     0  190  235  1  0 99  0  0

 0  0      0 805088  11032 132760    0    0     0     0  154  190  0  0 100  0  0

 0  0      0 805088  11032 132760    0    0     0     0  176  213  0  0 100  0  0

 0  0      0 805088  11032 132760    0    0     0     0  171  210  0  0 100  0  0

r : 表示多少个进程处理RUNING的状态;

  • top命令

[root@izm5e9voc4k5nenpa42yb3z ~]# top

top - 23:09:46 up 22 min,  3 users,  load average: 0.00, 0.01, 0.02

Tasks:  65 total,   2 running,  63 sleeping,   0 stopped,   0 zombie

%Cpu(s):  0.3 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

KiB Mem :  1016164 total,   804048 free,    67592 used,   144524 buff/cache

KiB Swap:        0 total,        0 free,        0 used.   803320 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                                                                 

 1199 root      20   0  148276   5796   4488 S  0.3  0.6   0:00.03 sshd                                                                                                                                    

    1 root      20   0   43272   3644   2488 S  0.0  0.4   0:00.61 systemd                                                                                                                                 

    2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd                                                                                                                                

    3 root      20   0       0      0      0 S  0.0  0.0   0:00.00 ksoftirqd/0                                                                                                                             

    5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H                                                                                                                            

    6 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kworker/u2:0                                                                                                                            

    7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0                                                                                                                             

  • sar 命令

[root@izm5e9voc4k5nenpa42yb3z ~]# sar

Linux 3.10.0-693.2.2.el7.x86_64 (localhost.localdomain)     2018年03月20日     _x86_64_    (1 CPU)

20时41分46秒       LINUX RESTART

20时49分23秒       LINUX RESTART

20时50分01秒     CPU     %user     %nice   %system   %iowait    %steal     %idle

21时00分01秒     all      0.12      0.00      0.08      0.01      0.00     99.79

21时10分01秒     all      0.13      0.00      0.08      0.01      0.00     99.78

21时20分01秒     all      0.11      0.00      0.09      0.00      0.00     99.80

21时30分01秒     all      0.11      0.23      0.38      0.25      0.00     99.04

21时40分01秒     all      0.11      0.00      0.08      0.00      0.00     99.82

21时50分01秒     all      0.11      0.00      0.07      0.00      0.00     99.82

22时00分01秒     all      0.12      0.00      0.09      0.00      0.00     99.79

22时10分01秒     all      0.45      0.00      0.16      0.37      0.00     99.02

22时20分01秒     all      0.14      0.00      0.13      0.01      0.00     99.72

平均时间:     all      0.16      0.03      0.13      0.07      0.00     99.62

22时50分01秒     CPU     %user     %nice   %system   %iowait    %steal     %idle

23时00分01秒     all      0.12      0.00      0.07      0.00      0.00     99.81

23时10分01秒     all      0.12      0.00      0.08      0.00      0.00     99.80

平均时间:     all      0.12      0.00      0.07      0.00      0.00     99.81

  • nload 命令

[root@izm5e9voc4k5nenpa42yb3z ~]# nload

Device eth0 [172.31.110.12] (1/2):

================================================================

Incoming:

            Curr: 1.02 kBit/s

            Avg: 1.16 kBit/s

            Min: 1.02 kBit/s

            Max: 3.08 kBit/s

            Ttl: 21.38 MByte

Outgoing:

            Curr: 9.94 kBit/s

            Avg: 9.05 kBit/s

             Min: 2.82 kBit/s

            Max: 9.94 kBit/s

            Ttl: 304.54 kByte

  • iostat

[root@izm5e9voc4k5nenpa42yb3z ~]# iostat
Linux 3.10.0-693.2.2.el7.x86_64 (izm5e9voc4k5nenpa42yb3z)       03/22/2018      _x86_64_        (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.12    0.00    0.07    0.01    0.00   99.80

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               0.26         1.44         2.56     216405     383716

  • iotop

[root@izm5e9voc4k5nenpa42yb3z ~]# iotop
 3949 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.01 % [kworker/0:1]
Total DISK READ :       0.00 B/s | Total DISK WRITE :       0.00 B/s
Actual DISK READ:       0.00 B/s | Actual DISK WRITE:       0.00 B/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                                                                                         
 3584 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % sshd: root@pts/0
    1 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % systemd --switched-root --system --deserialize 21
    2 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kthreadd]
    3 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [ksoftirqd/0]
    5 be/0 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kworker/0:0H]
    6 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kworker/u2:0]
    7 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [migration/0]
    8 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [rcu_bh]
    9 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [rcu_sched]

  • free

[root@izm5e9voc4k5nenpa42yb3z ~]# free
              total        used        free      shared  buff/cache   available
Mem:        1016164       75072      539164         416      401928      787988
Swap:             0           0           0
[root@izm5e9voc4k5nenpa42yb3z ~]# free -k
              total        used        free      shared  buff/cache   available
Mem:        1016164       74916      539336         416      401912      788160
Swap:             0           0           0
[root@izm5e9voc4k5nenpa42yb3z ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:            992          73         526           0         392         769
Swap:             0           0           0
[root@izm5e9voc4k5nenpa42yb3z ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           992M         73M        526M        416K        392M        769M
Swap:            0B          0B          0B

  • tcpdump

[root@izm5e9voc4k5nenpa42yb3z ~]# tcpdump -nn -c 10
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
16:29:51.834760 IP 172.31.110.12.22 > 222.66.77.18.17685: Flags [P.], seq 4166017567:4166017763, ack 3983410145, win 281, length 196
16:29:51.834886 IP 172.31.110.12.22 > 222.66.77.18.17685: Flags [P.], seq 196:376, ack 1, win 281, length 180
16:29:51.834931 IP 172.31.110.12.22 > 222.66.77.18.17685: Flags [P.], seq 376:540, ack 1, win 281, length 164
16:29:51.834954 IP 172.31.110.12.22 > 222.66.77.18.17685: Flags [P.], seq 540:704, ack 1, win 281, length 164
16:29:51.834976 IP 172.31.110.12.22 > 222.66.77.18.17685: Flags [P.], seq 704:868, ack 1, win 281, length 164
16:29:51.834996 IP 172.31.110.12.22 > 222.66.77.18.17685: Flags [P.], seq 868:1032, ack 1, win 281, length 164

猜你喜欢

转载自my.oschina.net/u/3771523/blog/1648142
今日推荐