0413 日常运维1

日常运维1.w命令 查看系统负载2.vmstat命令3.top 显示进程所占的系统资源4.sar命令(瑞士军刀)5.nload 查看网卡流量6.监控io性能7.free命令8.ps命令9.netstat 查看网络状态10.抓包工具11linux网络相关1.w命令 查看系统负载uptime 会显示第一行负载参数第一行从左到右依次表示当前时间、系统已运行时间、登录用户数(终端登录显示为...
摘要由CSDN通过智能技术生成

在这里插入图片描述

1.w命令 查看系统负载

w  查看系统负载
[root@dazhou ~]# w
 18:34:30 up  3:37,  2 users,  load average: 0.15, 0.05, 0.06
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.31.1     六21   45:01m  0.02s  0.02s -bash
root     pts/1    192.168.31.1     18:34    2.00s  0.03s  0.02s w
[root@dazhou ~]# 

uptime 会显示第一行负载参数

[root@dazhou ~]# uptime 
 18:36:11 up  3:39,  2 users,  load average: 0.03, 0.04, 0.05
[root@dazhou ~]#

第一行从左到右依次表示
当前时间、
系统已运行时间、
登录用户数(终端登录显示为tty1,远程登录显示为pts/0)、
平均负载(每1分钟、每5分钟、每15分钟)主要是注意第一个负载值,值越大说明服务器压力越大。一般情况下,这个值不要超过服务器的逻辑cpu数量就没有关系

cat  /proc/cpuinfo  查看系统逻辑cpu
[root@dazhou ~]# cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 60
model name	: Intel(R) Pentium(R) CPU G3260 @ 3.30GHz
stepping	: 3
microcode	: 0x19
cpu MHz		: 3292.410
cache size	: 3072 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
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 syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt xsave rdrand hypervisor lahf_lm fsgsbase xsaveopt dtherm arat pln pts
bogomips	: 6584.82
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

[root@dazhou ~]# 

逻辑cpu数量为processor显示数加1个

2.vmstat命令

 vmstat     监控系统状态 cpu 内存 磁盘等

vmstat 1    每秒显示一次
vmstat 1 5 每秒显示一次  共显示五次
[root@dazhou ~]# vmstat 
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0      0 741252   2076 138712    0    0     6     1   27   48  0  0 100  0  0
[root@dazhou ~]# 

procs 进程相关

r(run)    表示运行或等待cpu时间片的进程数
b(block)  表示等待资源的进程数,这个资源指的是I/O、内存、网速等资源

memory 内存相关

swpd       表示切换到交换分区中的内存数量。
free       当前空闲的内存数量
buff       缓冲大小(KB)
cache      缓存大小(KB)

swap 内存的交换情况

si         表示由交换分区写去到内存的数据量(KB)
so         表示由内存写入到交换分区的数据量(KB)

io 磁盘的使用情况

 bi        从磁盘读取数据量的多少(读磁盘)(KB)
 bo        从磁盘写入数据量的多少(写磁盘)(KB)

cpu cpu的使用情况

us         用户级别(网站、mysql)占用cpu资源的时间百分比 长时间大于50 说明资源不够
sy         系统本身占用cpu资源的时间百分比
id         cpu处于空闲状态的时间百分比

    us+sy+id=100

wa         I/O等待所占用的cpu的时间百分比
st         被偷走的cpu资源(虚拟化 子机器 会偷走)

3.top 显示进程所占的系统资源

在这里插入图片描述

top   动态显示进程所占的系统资源 3秒更新一次

 默认按照%cpu排序
shift m   会按内存排序
shift p   会按cpu排序
1         可以列出所有核CPU的使用状态
q         退出top

total      总进程数
runing     正在运行的进程数
sleeping   正在处于休眠状态的进程数  
stopped    已经停止的进程数 
zombie     僵尸进程(主进程被终止,子进程无人管就是僵尸进程)
 
RES      为进程所占的内存大小
%MEM     为使用内存的百分比
COMMAND  进程名称

top -c 查看具体进程路径
在这里插入图片描述
top -bn1 所有进程一次性静态列出

[root@dazhou ~]# top -bn1
top - 22:12:51 up  7:15,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  89 total,   2 running,  87 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  6.2 sy,  0.0 ni, 93.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1005628 total,   475404 free,   124492 used,   405732 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   695172 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    1 root      20   0   46100   6612   4176 S  0.0  0.7   0:03.34 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:01.26 ksoftirqd/0
    5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
    7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0
    8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh
    9 root      20   0       0      0      0 R  0.0  0.0   0:01.63 rcu_sched
   10 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 lru-add-drain
   11 root      rt   0       0      0      0 S  0.0  0.0   0:00.16 watchdog/0
   13 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kdevtmpfs
   14 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 netns
   15 root      20   0       0      0      0 S  0.0  0.0   0:00.00 khungtaskd
   16 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 writeback
   17 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kintegrityd
   18 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
   19 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
   20 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
   21 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kblockd
   22 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 md
   23 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 edac-poller
   24 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 watchdogd
   30 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kswapd0
   31 root      25   5       0      0      0 S  0.0  0.0   0:00.00 ksmd
   32 root      39  19       0      0      0 S  0.0  0.0   0:00.12 khugepaged
   33 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 crypto
   41 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kthrotld
   42 root      20   0       0      0      0 S  0.0  0.0   0:01.06 kworker/u128:1
   43 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kmpath_rdacd
   44 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kaluad
   45 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kpsmoused
   47 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 ipv6_addrconf
   60 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 deferwq
   91 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kauditd
 1532 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 mpt_poll_0
 1533 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 mpt/0
 1534 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 ata_sff
 1557 root      20   0       0      0      0 S  0.0  0.0   0:00.00 scsi_eh_0
 1560 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 scsi_tmf_0
 1568 root      20   0       0      0      0 S  0.0  0.0   0:00.01 scsi_eh_1
 1569 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 scsi_tmf_1
 1571 root      20   0       0      0      0 S  0.0  0.0   0:00.02 scsi_eh_2
 1573 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 scsi_tmf_2
 1872 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 ttm_swap
 1873 root     -51   0       0      0      0 S  0.0  0.0   0:00.00 irq/16-vmwgfx
 2516 root       0 -20       0      0      0 S  0.0  0.0   0:00.10 kworker/0:1H
 2525 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
 2530 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfsalloc
 2531 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs_mru_cache
 2537 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-buf/sda3
 2541 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-data/sda3
 2542 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-conv/sda3
 2543 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-cil/sda3
 2544 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-reclaim/sda
 2545 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-log/sda3
 2547 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-eofblocks/s
 2549 root      20   0       0      0      0 S  0.0  0.0   0:01.05 xfsaild/sda3
 2615 root      20   0   37172   2876   2556 S  0.0  0.3   0:00.31 systemd-journal
 2646 root      20   0   48604   6016   2864 S  0.0  0.6   0:02.44 systemd-udevd
 4182 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-buf/sda1
 4184 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-data/sda1
 4186 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-conv/sda1
 4187 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-cil/sda1
 4196 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-reclaim/sda
 4199 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-log/sda1
 4205 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-eofblocks/s
 4207 root      20   0       0      0      0 S  0.0  0.0   0:00.00 xfsaild/sda1
 5338 root      16  -4   62044   1084    496 S  0.0  0.1   0:00.04 auditd
 5362 root      20   0   99564   6124   4516 S  0.0  0.6   0:00.06 VGAuthService
 5363 root      20   0  301008   6396   4948 S  0.0  0.6   0:32.53 vmtoolsd
 5364 dbus      20   0   66292   2508   1900 S  0.0  0.2   0:00.29 dbus-daemon
 5366 chrony    20   0  117784   1824   1364 S  0.0  0.2   0:00.19 chronyd
 5372 root      20   0   26376   1748   1436 S  0.0  0.2   0:00.20 systemd-logind
 5375 polkitd   20   0  612996  11948   4948 S  0.0  1.2   0:00.25 polkitd
 5379 root      20   0  126320   1740   1072 S  0.0  0.2   0:00.94 crond
 5384 root      20   0  110092    856    728 S  0.0  0.1   0:00.02 agetty
 5436 root      20   0  358468  29340   7184 S  0.0  2.9   0:01.59 firewalld
 5913 root      20   0  112756   4308   3288 S  0.0  0.4   0:00.12 sshd
 5914 root      20   0  220844   6156   3316 S  0.0  0.6   0:01.87 rsyslogd
 5915 root      20   0  573820  19180   6040 S  0.0  1.9   0:03.55 tuned
 6009 root      20   0   89544   2184   1152 S  0.0  0.2   0:00.17 master
 6028 postfix   20   0   89716   4092   3088 S  0.0  0.4   0:00.03 qmgr
 6671 root      20   0  158760   5612   4260 S  0.0  0.6   0:05.44 sshd
 6740 root      20   0  115572   2244   1720 S  0.0  0.2   0:00.12 bash
 7128 postfix   20   0   89648   4064   3064 S  0.0  0.4   0:00.01 pickup
 7136 root      20   0       0      0      0 S  0.0  0.0   0:00.26 kworker/0:1
 7204 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kworker/u128:0
 7209 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kworker/0:0
 7219 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kworker/0:2
 7221 root      20   0  161880   2084   1536 R  0.0  0.2   0:00.00 top
[root@dazhou ~]# 

4.sar命令(瑞士军刀)

yum install -y sysstat 安装sar命令

sar -n DEV 查看网卡流量 打印当天的


[root@dazhou ~]# sar -n DEV
Linux 3.10.0-957.el7.x86_64 (dazhou) 	2019年04月15日 	_x86_64_	(1 CPU)

20时20分01秒     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
20时30分01秒        lo
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值