linux流量监控命令,Linux流量监控-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

linux流量监控命令,Linux流量监控

几个常用的linux性能监控命令

1. sar

麦积ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联建站的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

每两秒刷新一次, 总共5次

[root@dbhost01 ~]# sar 2 5

Linux 2.6.32-504.el6.x86_64 (dbhost01) 03/30/2018 _x86_64_ (4 CPU)

02:53:15 PM CPU %user %nice %system %iowait %steal %idle

02:53:17 PM all 0.66 0.00 1.72 0.66 0.00 96.96

02:53:19 PM all 1.34 0.00 3.35 0.80 0.00 94.51

02:53:21 PM all 0.79 0.00 1.59 1.45 0.00 96.17

02:53:23 PM all 0.40 0.00 2.00 0.80 0.00 96.80

02:53:25 PM all 0.66 0.00 1.85 0.79 0.00 96.70

Average: all 0.77 0.00 2.10 0.90 0.00 96.23

2. top

top -a 按照内存降序

[root@dbhost01 ~]# top -a

top - 15:00:54 up 6:04, 1 user, load average: 0.31, 0.19, 0.11

Tasks: 306 total, 1 running, 305 sleeping, 0 stopped, 0 zombie

Cpu(s): 7.8%us, 2.4%sy, 0.0%ni, 88.9%id, 0.8%wa, 0.0%hi, 0.1%si, 0.0%st

Mem: 4048972k total, 3848576k used, 200396k free, 134844k buffers

Swap: 4194300k total, 1788k used, 4192512k free, 1835360k cached

3. vmstat

vmstat用于显示虚拟内存,内核线程,磁盘,系统进程, CPU活动等统计信息。

需要安装sysstat工具。

[root@dbhost01 ~]# 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 1788 202508 135064 1835920 0 0 32 26 96 276 1 2 95 1 0

[root@dbhost01 ~]#

[root@dbhost01 ~]# vmstat 2 5

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 1788 202336 135068 1836000 0 0 32 26 97 276 1 2 95 1 0

0 0 1788 202624 135068 1836000 0 0 25 29 4012 6682 0 1 98 1 0

0 0 1788 202624 135072 1836004 0 0 57 87 4003 6685 0 1 98 1 0

1 0 1788 202508 135072 1836004 0 0 57 33 4402 7353 1 1 98 0 0

0 0 1788 202540 135076 1836004 0 0 33 47 4002 6674 0 1 98 1 0

4. lsof(list open files)

[root@dbhost01 ~]# lsof | grep 1521

certmonge 2348 root 16r FIFO 0,8 0t0 15212 pipe

certmonge 2348 root 18r FIFO 0,8 0t0 15218 pipe

gipcd.bin 2754 grid 109u unix 0xffff880139152180 0t0 36936 socket

5. tcpdump

tcpdump -i eth1

15:24:28.777779 IP dbhost01.ssh 192.168.2.82.50990: Flags [P.], seq 393080:393596, ack 105, win 148, options [nop,nop,TS val 22996360 ecr 2443327], length 516

15:24:28.777809 IP dbhost01.ssh 192.168.2.82.50990: Flags [P.], seq 393080:393596, ack 105, win 148, options [nop,nop,TS val 22996360 ecr 2443327], length 516

15:24:28.778976 IP dbhost01.ssh 192.168.2.82.50990: Flags [P.], seq 393596:393968, ack 105, win 148, options [nop,nop,TS val 22996361 ecr 2443327], length 372

15:24:28.779011 IP dbhost01.ssh 192.168.2.82.50990: Flags [P.], seq 393596:393968, ack 105, win 148, options [nop,nop,TS val 22996361 ecr 2443327], length 372

15:24:28.779013 IP 192.168.2.82.50990 dbhost01.ssh: Flags [.], ack 393968, win 16652, options [nop,nop,TS val 2443327 ecr 22996360], length 0

15:24:28.779481 IP dbhost02-priv.23602 dbhost01-priv.24271: UDP, length 556

15:24:28.779585 IP dbhost01-priv.24271 dbhost02-priv.23602: UDP, length 80

15:24:28.779909 IP dbhost01-priv.24271 dbhost02-priv.23602: UDP, length 80

15:24:28.780584 IP dbhost01.ssh 192.168.2.82.50990: Flags [P.], seq 393968:394724, ack 105, win 148, options [nop,nop,TS val 22996362 ecr 2443327], length 756

15:24:28.780590 IP dbhost01.ssh 192.168.2.82.50990: Flags [P.], seq 393968:394724, ack 105, win 148, options [nop,nop,TS val 22996362 ecr 2443327], length 756

15:24:28.780820 IP dbhost01-priv.24271 dbhost02-priv.23602: UDP, length 556

15:24:28.782232 IP dbhost01.ssh 192.168.2.82.50990: Flags [P.], seq 394724:395176, ack 105, win 148, options [nop,nop,TS val 22996364 ecr 2443327], length 452

15:24:28.782235 IP dbhost01.ssh 192.168.2.82.50990: Flags [P.], seq 394724:395176, ack 105, win 148, options [nop,nop,TS val 22996364 ecr 2443327], length 452

6.netstat

[root@dbhost01 ~]# netstat -a | grep oracle

unix 2 [ ACC ] STREAM LISTENING 31861 /var/tmp/.oracle/ora_gipc_sdbhost01gridmyracdb-clusterCRFM_SIPC

unix 2 [ ACC ] STREAM LISTENING 33820 /var/tmp/.oracle/sdbhost01DBG_LOGD

unix 2 [ ACC ] STREAM LISTENING 41177 /var/tmp/.oracle/sdbhost01DBG_EVMD

unix 2 [ ACC ] STREAM LISTENING 65106 /var/tmp/.oracle/sAevm

unix 2 [ ACC ] STREAM LISTENING 65108 /var/tmp/.oracle/sSYSTEM.evm.acceptor.auth

7. htop

需要安装

8. iostat

Total DISK READ: 91.48 K/s | Total DISK WRITE: 45.27 K/s

TID PRIO USER DISK READ DISK WRITE SWAPIN IO COMMAND

4071 be/4 oracle 30.18 K/s 0.00 B/s 0.00 % 4.69 % ora_lmon_orcl1

4117 be/4 oracle 60.36 K/s 15.09 K/s 0.00 % 3.69 % ora_ckpt_orcl1

2989 rt/4 grid 965.71 B/s 0.00 B/s 0.00 % 2.13 % ocssd.bin

4099 be/4 oracle 0.00 B/s 30.18 K/s 0.00 % 0.07 % ora_ckpt_test

2987 rt/4 grid 0.00 B/s 482.86 B/s 0.00 % 0.03 % ocssd.bin

2979 rt/3 root 0.00 B/s 3.77 K/s 0.00 % 0.00 % ologgerd -M -d /g01/grid/app/11.2.0/grid/crf/db/dbhost01

2980 rt/3 root 0.00 B/s 15.09 K/s 0.00 % 0.00 % ologgerd -M -d /g01/grid/app/11.2.0/grid/crf/db/dbhost01

9. iftop(流量监控工具)

在Linux下怎么看网络流量

1. 使用 iptraf

iptraf是一个实时查看网络流量的文本屏幕界面工具。

如果系统没有安装

如果是 RHEL,那么就去找安装盘中的 iptraf*.rpm 包安装;

如果是 CentOS,那么用 yum install -y iptraf 进行安装

iptraf是一个文本全屏幕界面,操作起来比较简单明了。最好使用 putty 来看,SecureCRT可能显示乱码。

它提供了很多统计方式:

(1)IP traffic monitor

(2)General interface statistics

(3)Detailed interface statistics

如果跟上 -B 参数,还可以后台执行,把数据保存到文件中,位于 /var/log/iptraf 目录。

2. sar

如果系统没有安装,

如果是 RHEL,那么就去安装盘中找 sysstat*.rpm 包安装;

如果是 CentOS,那么用 yum install -y sysstat 安装。

sysstat是一个工具包,包含有几个很有用的系统检测程序,iostat,mpstat和sar.

Turbolinux的各个版本上,都包含这个工具包.

iostat用于输出CPU,I/O系统和磁盘分区的统计信息.可以用来分析磁盘I/O,带宽等信息.

mpstat用于输出CPU的各种统计信息. 可以用来分析程序运行时在内核态和用户态的工作情况.

sar用于定时搜集系统的各种状态信息.然后可以对系统各个时间点的状态进行监控.

sar有很多用途,如果要来监控网络流量,使用下面的命令行方式:

sar -n DEV interval count

其中,interval是统计时间间隔,以秒为单位;count是总共统计几次,如果为0就不断的统计直到 Ctrl+C 打断,否则执行count次就退出。

比如:sar -n DEV 1 4

比如:sar -n DEV 10 0

IFACE:LAN接口

rxpck/s:每秒钟接收的数据包

txpck/s:每秒钟发送的数据包

rxbyt/s:每秒钟接收的字节数

txbyt/s:每秒钟发送的字节数

Linux下经常用来查看网络流量的有哪些命令?

nethogs: 按进程查看流量占用

iptraf: 按连接/端口查看流量

ifstat: 按设备查看流量

ethtool: 诊断工具

tcpdump: 抓包工具

ss: 连接查看工具

查看linux网络流量及带宽

在类Unix系统中可以使用top查看系统资源、进程、内存占用等信息。查看网络状态可以使用netstat、nmap等工具。若要查看实时的网络流量,监控TCP/IP连接等,则可以使用iftop。

iftop类似于top的实时流量监控工具,可以用来监控网卡的实时流量(可以指定网段)、反向解析IP、显示端口信息等。

查看流量是从哪些端口发送出去的:

# iftop -P

-P 选项会在iftop 的输出结果中开启端口显示

界面上面显示的是类似刻度尺的刻度范围,为显示流量图形的长条作标尺用的。

中间的= =这两个左右箭头,表示的是流量的方向。

TX:发送流量

RX:接收流量

TOTAL:总流量

Cumm:运行iftop到目前时间的总流量

peak:流量峰值

rates:分别表示过去 2s 10s 40s 的平均流量

要找到运行在该端口的进程,那么可以用netstat 或者lsof 来找到相应的进程。

使用netstat 命令来找到运行在10910这个端口上的进程:

# netstat -tunp | grep 10910

可以使用lsof 命令来找到运行在10909这个端口上的进程:

# lsof -i:10909

查看进程PID为51919的应用程序:

# ps -ef |grep 51919


网站标题:linux流量监控命令,Linux流量监控
网页链接:http://kswsj.cn/article/dsgoohg.html

其他资讯