2017-11-28 7周2次课 linux系统日常管理(二)
来源:互联网 发布:旅游网络推广方案 编辑:程序博客网 时间:2024/06/06 05:12
监控io性能
iostat -x 磁盘使用
iotop 磁盘使用
[root@node69 ~]# iostatLinux 3.10.0-514.el7.x86_64 (node69) 2017年11月29日 _x86_64_(1 CPU)avg-cpu: %user %nice %system %iowait %steal %idle 5.10 0.06 1.83 0.67 0.00 92.33Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtnsda 2.91 80.84 9.81 590553 71686sdb 0.04 0.27 0.00 1948 0scd0 0.00 0.01 0.00 66 0dm-0 0.01 0.06 0.00 456 0
[root@node69 ~]# iostat -xLinux 3.10.0-514.el7.x86_64 (node69) 2017年11月29日 _x86_64_(1 CPU)avg-cpu: %user %nice %system %iowait %steal %idle 4.94 0.06 1.76 0.63 0.00 92.61Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %utilsda 0.00 0.07 1.96 0.78 75.69 9.43 62.02 0.11 38.69 28.13 65.25 9.75 2.68sdb 0.00 0.00 0.04 0.00 0.25 0.00 12.45 0.00 5.70 5.70 0.00 4.27 0.02scd0 0.00 0.00 0.00 0.00 0.01 0.00 6.00 0.00 18.00 18.00 0.00 18.00 0.01dm-0 0.00 0.00 0.01 0.00 0.06 0.00 15.20 0.00 2.22 2.22 0.00 2.10 0.00
[root@node69 ~]# yum install -y iotopiotop 动态显示
free 查看内存使用情况
[root@node69 ~]# free total used free shared buff/cache availableMem: 1867264 552384 645152 10400 669728 1095004Swap: 2097148 0 2097148
[root@node69 ~]# free -m total used free shared buff/cache availableMem: 1823 539 629 10 654 1069Swap: 2047 0 2047[root@node69 ~]# free -h total used free shared buff/cache availableMem: 1.8G 539M 629M 10M 654M 1.0GSwap: 2.0G 0B 2.0G
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这个状态
Z 僵尸进程,杀不掉,打不死的垃圾进程,占系统一小点资源,不过没有关系。如果太多,就有问题了。
< 高优先级进程
N 低优先级进程
[root@node69 ~]# ps -elfF S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD4 S root 1 0 0 80 0 - 31338 ep_pol 06:23 ? 00:00:06 /usr/lib/s1 S root 2 0 0 80 0 - 0 kthrea 06:23 ? 00:00:00 [kthreadd]1 S root 3 2 0 80 0 - 0 smpboo 06:23 ? 00:00:01 [ksoftirqd1 S root 7 2 0 -40 - - 0 smpboo 06:23 ? 00:00:00 [migration1 S root 8 2 0 80 0 - 0 rcu_gp 06:23 ? 00:00:00 [rcu_bh]1 R root 9 2 0 80 0 - 0 - 06:23 ? 00:00:05 [rcu_sched5 S root 10 2 0 -40 - - 0 smpboo 06:23 ? 00:00:00 [watchdog/1 S root 12 2 0 60 -20 - 0 rescue 06:23 ? 00:00:00 [khelper]5 S root 13 2 0 80 0 - 0 devtmp 06:23 ? 00:00:00 [kdevtmpfs1 S root 14 2 0 60 -20 - 0 rescue 06:23 ? 00:00:00 [netns]1 S root 15 2 0 80 0 - 0 watchd 06:23 ? 00:0
L 在内存中被锁了内存分页
s 主进程
l 多线程进程
+ 在前台的进程
[root@node69 ~]# ps auxUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.2 125352 3912 ? Ss 06:23 0:06 /usr/lib/systemd/systroot 2 0.0 0.0 0 0 ? S 06:23 0:00 [kthreadd]root 3 0.0 0.0 0 0 ? S 06:23 0:01 [ksoftirqd/0]root 7 0.0 0.0 0 0 ? S 06:23 0:00 [migration/0]root 8 0.0 0.0 0 0 ? S 06:23 0:00 [rcu_bh]root 9 0.0 0.0 0 0 ? R 06:23 0:05 [rcu_sched]root 10 0.0 0.0 0 0 ? S 06:23 0:00 [watchdog/0]root 12 0.0 0.0 0 0 ? S< 06:23 0:00 [khelper]root 13 0.0 0.0 0 0 ? S 06:23 0:00 [kdevtmpfs]root 14 0.0 0.0 0 0 ? S< 06:23 0:00 [netns]root 15 0.0 0.0 0 0 ? S 06:23 0:00 [khungtaskd]root 16 0.0 0.0 0 0 ? S< 06:23 0:00 [writeback]root 17 0.0 0.0 0 0 ? S< 06:23 0:00 [kintegrityd]
netstat 查看网络状况
netstat -lnp 查看当前系统开启的端口以及socket
netstat -an 查看当前系统所有的连接
netstat -lntp 只看出tcp的,不包含socket
[root@node69 ~]# netstat -lnpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2197/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1044/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 915/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1652/master tcp6 0 0 :::111 :::* LISTEN 1/
[root@node69 ~]# netstat -anActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 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 tcp6 0 0 :::111 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN udp 0 0 0.0.0.0:5353 0.0.0.0:* udp 0 0 192.168.161.128:37103 51.15.41.135:123 ESTABLISHED
[root@node69 ~]# netstat -an |awk '/^tcp/ {++sta[$NF]} END {for(key in sta) print key,"\t",sta[key]}'LISTEN 9
Linux抓包工具
如果没有tcpdump 这个命令,需要用yum install-y tcpdump 命令去安装一下
抓包工具tcpdump
tcpdump -nn
[root@node69 ~]# tcpdump -nn -i ens33tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on ens33, link-type EN10MB (Ethernet), capture size 65535 bytes09:44:35.635215 ARP, Request who-has 192.168.161.128 tell 192.168.161.2, length 4609:44:35.635378 ARP, Reply 192.168.161.128 is-at 00:0c:29:a1:a0:a3, length 2809:44:35.635532 IP 51.15.41.135.123 > 192.168.161.128.54637: NTPv4, Server, length 4809:44:49.188985 IP 192.168.161.128.57335 > 85.199.214.100.123: NTPv4, Client, length 4809:44:50.202346 IP 85.199.214.100.123 > 192.168.161.128.57335: NTPv4, Server, length 4809:44:54.201297 ARP, Request who-has 192.168.161.2 tell 192.168.161.128, length 2809:44:54.201465 ARP, Reply 192.168.161.2 is-at 00:50:56:fd:f3:1b, length 46^C
[root@node69 ~]# tcpdump -nn port 80
[root@node69 ~]# tcpdump -nn -i ens33 -c 10 -w /tmp/1.captcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 65535 bytes10 packets captured10 packets received by filter0 packets dropped by kernel
wireshark 在linux下也可以安装 yum install -y wireshark
抓包分析http请求:tshark -n -t a -R http.request -T fields -e "frame.time" -e "ip.src" -e "http.host" -e "http.request.method" -e "http.request.uri"
阅读全文
0 0
- 2017-11-28 7周2次课 linux系统日常管理(二)
- 2017-11-27 7周1次课 linux系统日常管理(一)
- 2017-11-29 7周3次课 linux系统日常管理(三)
- 2017-11-30 7周4次课 linux系统日常管理(四)
- linux系统日常管理
- linux系统日常管理
- linux系统日常管理
- linux系统日常管理
- linux 系统日常管理
- Linux系统日常管理
- linux系统日常管理
- linux系统日常管理
- Linux学习笔记(系统日常管理-2)
- linux系统日常管理【转载】
- Linux-日常(二)
- Linux系统日常管理-Linux防火墙
- Linux学习--Linux系统日常管理1
- Linux运维-Linux系统日常管理
- 利用 AutoML 进行大规模图像分类和对象检测
- 多学一招(面试)
- 时间序列笔记(七)
- IT忍者神龟之Redis+Tomcat+Nginx集群实现Session共享
- myeclipse中的快捷键列表
- 2017-11-28 7周2次课 linux系统日常管理(二)
- java中NULL与""的区别
- SpringBoot非官方教程 | 第十篇: 用spring Restdocs创建API文档
- JAVA List<Map>结果集处理方法集合
- 对datatable对象参数进行部分配置以及说明
- Voxel Space:不到20行代码实现地形渲染
- 【Scikit-Learn 中文文档】神经网络模块(监督的)- 监督学习
- 已知一个GeoTiff,得到其边界矢量的方法
- Problem J 小鑫need help