系统的性能指标---》如何判断系统忙还是不忙,看哪些指标?
1.cpu(Central Processing Unit ,中央处理器)
2.memory 内存
3.磁盘 disk(容量、IO速度)
4.网络 network(流量带宽) --》100Mb/s、1000Mb/s
5.服务 service(进程、端口)
top 是一个在 Linux 和其他类 Unix 系统上常用的实时系统监控工具。它提供了一个动态的、交互式的实时视图,显示系统的整体性能信息以及正在运行的进程的相关信息。
%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
top命令统计cpu使用率的时候,
us表示user 用户态的进程所消耗的cpu的资源
sy表示system 内核态的进程所消耗的cpu的资源
当进程进行读写操作的时候,调用系统调用,例如:read()、write()、fork()等
系统调用就是操作系统给其他应用程序的接口,也是实现某个功能的程序。
%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
idle 空闲的,未使用的cpu百分比
us表示user 用户态的进程所消耗的cpu的资源
i++
100%= us + sy +id
sy表示system 内核态的进程所消耗的cpu的资源
磁盘有大量的读写操作会导致sy的使用率偏高
分配内存:产生大量的变量,需要分配内存空间
在网络上接受和发送数据
us + sy 表示正在使用的cpu比率
top - 15:38:07 up 5:55, 2 users, load average: 0.00, 0.04, 0.05
load average: 0.00, 0.04, 0.05
负载的平均值: cpu的平均负载
0.00, 0.04, 0.05
最近的1分钟,5分钟,15分钟的cup的平均负载
the system load averages for the past 1, 5, and 15 minutes.
System load averages
System load averages is the average number of processes that are either in a runnable or uninterruptable state. A process in a runnable
state is either using the CPU or waiting to use the CPU. A process in uninterruptable state is waiting for some I/O access, eg waiting
for disk. The averages are taken over the three time intervals. Load averages are not normalized for the number of CPUs in a system, so
a load average of 1 means a single CPU system is loaded all the time while on a 4 CPU system it means it was idle 75% of the time.
系统平均负载是指过去的1分钟,5分钟,15分钟,处于可运行或不可中断状态的进程的平均数量。
系统平均负载是指过去的1分钟,5分钟,15分钟,处于可运行或就绪或者阻塞的状态的进程的平均数量。这是进程的平均数量,用来判断系统是否繁忙的指标,假如我们的系统是1个cpu核心,这个值超过1就说明系统比较繁忙了,但是不超过5说明还没有达到最忙的时候。 0~5以内,说明系统还可以,只要超过1就比较忙了
假如有8个cpu核心,这个值就是8 ,超过8就比较忙,但是可以承受的总值是5*8=40
通过看进程的数量来判断cpu是否忙,内存是否消耗多等
runnable or uninterruptable state.
系统平均负载是处于可运行或不可中断状态的进程的平均数量。
cpu的就绪队列里单位时间里有多少个进程在等待运行
中断: 中间打断
当这个值为1的时候,其实就是cpu处于饱和状态运行,队列里同时有5个进程在排队等待运行的时候,就说明cpu很忙
0~5 能够接受的一个负载
超过5的时候,就说明cpu非常的忙
top命令的使用
1.按q是退出 quit
2.按数字 1 查看cpu每个核的使用率
M:根据驻留内存大小进行排序; memory
P:根据CPU使用百分比大小进行排序; processershift+<> 根据其他的列来排序
h 查看帮助,可以使用哪些命令
指定监控某个进程
[root@aliyun ~]# top -p 30556
指定延迟间隔时间 (默认top是延迟1.5秒)
[root@aliyun ~]# top -d 3
-n 1 刷新1次就退出
[root@aliyun ~]# top -n 1
top - 15:30:31 up 19 days, 22:25, 2 users, load average: 0.00, 0.01, 0.05
Tasks: 82 total, 1 running, 81 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1798476 total, 109592 free, 178288 used, 1510596 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 1432532 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 125644 3800 2320 S 0.0 0.2 2:12.00 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
4 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:04.63 ksoftirqd/0
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 S 0.0 0.0 1:52.59 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:03.34 watchdog/0
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 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.25 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
htop 是Linux系统中的一个互动的进程查看器
Htop是一款运行于Linux系统监控与进程管理软件,用于取代传统的top命令。
与top只提供最消耗资源的进程列表不同,htop提供所有进程的列表,并且使用彩色标识出处理器、swap和内存状态。
用户一般可以在top无法提供详尽系统信息的情况下选择安装并使用htop。与top相比,htop提供更方便、光标控制的界面来杀死进程。
安装
yum install epel-release -y
yum install htop -y
使用
上下键或PgUP, PgDn 选定想要的进程,左右键或Home, End 移动字段,也可以直接用鼠标选定进程;
空格 Space 标记/取消标记一个进程。
U 取消标记所有进程
s 选择某一进程
l 显示进程打开的文件: 如果安装了lsof,按此键可以显示进程所打开的文件
I 倒转排序顺序,如果排序是正序的,则反转成倒序的
a (在有多处理器的机器上) 设置 CPU affinity: 标记一个进程允许使用哪些CPU
u 显示特定用户进程
M 按Memory 使用排序
P 按CPU 使用排序
T 按Time+ 使用排序
F 跟踪进程
K 显示/隐藏内核线程
H 显示/隐藏用户线程
Ctrl-L 刷新
Numbers PID 查找: 输入PID,光标将移动到相应的进程上
iotop 是一个类似 top 的工具,用来显示实时的磁盘活动。iotop 监控 Linux 内核输出的 I/O 使用信息,并且显示一个系统中进程或线程的当前 I/O 使用情况。它显示每个进程/线程读写 I/O 带宽。它同样显示当等待换入和等待 I/O 的线程/进程花费的时间的百分比。
安装
yum install iotop -y
选项
-o:只显示有io操作的进程
-b:批量显示,无交互,主要用作记录到文件。
-n NUM:显示NUM次,主要用于非交互式模式。
-d SEC:间隔SEC秒显示一次。
-p PID:监控的进程pid。
-u USER:监控的进程用户。
使用
左右箭头:改变排序方式,默认是按IO排序。
r:改变排序顺序。
o:只显示有IO输出的进程。
p:进程/线程的显示方式的切换。
a:显示累积使用量。
q:退出。
iftop是一款基于终端的实时流量监控工具,它能够显示网络接口的实时流量情况,包括每个连接的源IP地址、目标IP地址、传输速率等。iftop在网络管理和故障排查中非常有用,可以帮助我们实时监控网络流量,了解网络连接的情况。
安装
yum install iftop -y
选项
-i 接口:指定要监控的网络接口。
-B 显示单位:设置显示单位,如b、Kb、Mb等。
-F 过滤规则:设置过滤规则,只显示符合规则的连接。
-n 不解析主机名:禁止解析主机名,只显示IP地址。
-N 不解析端口号:禁止解析端口号,只显示端口号。
-o 排序时间间隔:设置排序时间间隔,以秒为单位。
-s 排序字段:设置排序字段,如2表示按照流量排序。
# 监控eth0接口的流量情况
iftop -i eth0
# 按流量排序显示连接,每3秒刷新一次,只显示前2条记录
iftop -i eth0 -o 3s -s 2
# 只显示源IP地址为192.168.1.1的连接
iftop -i ens33 -f "src host 192.168.1.1"
# 显示连接的详细信息,包括端口号和协议
iftop -i eth0 -nN
Glances 是一个开源免费的跨平台命令行监视工具,可提供有关系统性能的大量信息。您可以监视系统指标,例如内存和 CPU 利用率,网络带宽,磁盘 I/O,文件系统和运行进程等。
安装
yum install glances -y
# 查看glances 帮助文档
[root@jenkins ~]# glances -h
usage: glances [-h] [-V] [-d] [-C CONF_FILE] [-3] [-4] [--disable-cpu]
[--disable-mem] [--disable-swap] [--disable-load]
[--disable-network] [--disable-ip] [--disable-diskio]
[--disable-fs] [--disable-sensors] [--disable-hddtemp]
[--disable-raid] [--disable-docker] [-2] [--disable-process]
[--disable-log] [--disable-bold] [--enable-process-extended]
[--enable-history] [--path-history PATH_HISTORY]
[--export-csv EXPORT_CSV] [--export-influxdb]
[--export-opentsdb] [--export-statsd] [--export-rabbitmq]
[-c CLIENT] [-s] [--browser] [--disable-autodiscover] [-p PORT]
[-B BIND_ADDRESS] [--password]
[--snmp-community SNMP_COMMUNITY] [--snmp-port SNMP_PORT]
[--snmp-version SNMP_VERSION] [--snmp-user SNMP_USER]
[--snmp-auth SNMP_AUTH] [--snmp-force] [-t TIME] [-w] [-q]
[-f PROCESS_FILTER] [--process-short-name] [-0]
[--hide-kernel-threads] [--tree] [-b] [--fahrenheit] [-1]
[--fs-free-space] [--theme-white]
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-d, --debug enable debug mode
-C CONF_FILE, --config CONF_FILE
path to the configuration file
-3, --disable-quicklook
disable quick look module
-4, --full-quicklook disable all but quick look and load
--disable-cpu disable CPU module
--disable-mem disable memory module
--disable-swap disable swap module
--disable-load disable load module
--disable-network disable network module
--disable-ip disable IP module
--disable-diskio disable disk I/O module
--disable-fs disable filesystem module
--disable-sensors disable sensors module
--disable-hddtemp disable HD temperature module
--disable-raid disable RAID module
--disable-docker disable Docker module
-2, --disable-left-sidebar
disable network, disk I/O, FS and sensors modules
(py3sensors needed)
--disable-process disable process module
--disable-log disable log module
--disable-bold disable bold mode in the terminal
--enable-process-extended
enable extended stats on top process
--enable-history enable the history mode (matplotlib needed)
--path-history PATH_HISTORY
set the export path for graph history
--export-csv EXPORT_CSV
export stats to a CSV file
--export-influxdb export stats to an InfluxDB server (influxdb needed)
--export-opentsdb export stats to an OpenTSDB server (potsdb needed)
--export-statsd export stats to a StatsD server (statsd needed)
--export-rabbitmq export stats to rabbitmq broker (pika needed)
-c CLIENT, --client CLIENT
connect to a Glances server by IPv4/IPv6 address or
hostname
-s, --server run Glances in server mode
--browser start the client browser (list of servers)
--disable-autodiscover
disable autodiscover feature
-p PORT, --port PORT define the client/server TCP port [default: 61209]
-B BIND_ADDRESS, --bind BIND_ADDRESS
bind server to the given IPv4/IPv6 address or hostname
--password define a client/server password
--snmp-community SNMP_COMMUNITY
SNMP community
--snmp-port SNMP_PORT
SNMP port
--snmp-version SNMP_VERSION
SNMP version (1, 2c or 3)
--snmp-user SNMP_USER
SNMP username (only for SNMPv3)
--snmp-auth SNMP_AUTH
SNMP authentication key (only for SNMPv3)
--snmp-force force SNMP mode
-t TIME, --time TIME set refresh time in seconds [default: 3 sec]
-w, --webserver run Glances in web server mode (bottle needed)
-q, --quiet do not display the curses interface
-f PROCESS_FILTER, --process-filter PROCESS_FILTER
set the process filter pattern (regular expression)
--process-short-name force short name for processes name
-0, --disable-irix Task's cpu usage will be divided by the total number
of CPUs
--hide-kernel-threads
hide kernel threads in process list
--tree display processes as a tree
-b, --byte display network rate in byte per second
--fahrenheit display temperature in Fahrenheit (default is Celsius)
-1, --percpu start Glances in per CPU mode
--fs-free-space display FS free space instead of used
--theme-white optimize display colors for white background
Examples of use:
Monitor local machine (standalone mode):
$ glances
Monitor local machine with the Web interface (Web UI):
$ glances -w
Glances web server started on http://0.0.0.0:61208/
Monitor local machine and export stats to a CSV file (standalone mode):
$ glances --export-csv
Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):
$ glances -t 5 --export-influxdb
Start a Glances server (server mode):
$ glances -s
Connect Glances to a Glances server (client mode):
$ glances -c <ip_server>
Connect Glances to a Glances server and export stats to a StatsD server (client mode):
$ glances -c <ip_server> --export-statsd
Start the client browser (browser mode):
$ glances --browser
[root@jenkins ~]#
free 作为一个简单而强大的工具,可以帮助我们实时监测系统的内存使用情况。
-m 以MB为单位显示内存使用情况;
-h 以人类能识别的单位输出
[root@aliyun ~]# free -m
total used free shared buff/cache available
Mem: 1756 173 107 0 1475 1399
Swap: 0 0 0
[root@jenkins ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 396M 83M 9.8M 1.3G 1.2G
Swap: 2.0G 520K 2.0G
total 总的内存大小
used 应用程序已经使用的内存
free 表示空闲的
shared 共享内存消耗的空间
buff/cache 缓存:使用的内存
buffer : 内存--》data--》磁盘 正在运行的进程将内存里的数据写到磁盘的时候,先写到buffer里,等buffer满了再写到磁盘,减少IO的次数,提升性能。
cache : 磁盘--》data--》内存 将经常需要的数据先读取到cache里,这样可以提升速度
total=used + free + shared + buff/cache
available :下一个进程可以使用的内存空间
available = free + buff/cache里的未使用完的空间
严格看: 我们只看free
Mem 是物理内存: 内存条的内存大小 memory
Swap: 是交换分区的内存大小 : 交换分区是从磁盘里划分出来的一块空间临时做内存使用的,当物理内存不足的时候,将不活跃的进程交换到swap分区里
尽量不使用交换分区,因为速度慢
[root@jenkins ~]# cat /proc/sys/vm/swappiness # 当物理内存只剩下30%的空间的时候,开始使用交换分区
30
[root@jenkins ~]# echo 0 >/proc/sys/vm/swappiness # 临时调整 --》属于linux系统的内核参数优化,调整使用交换分区的时机,当物理内存剩下0的时候,开始使用交换分区
[root@jenkins ~]# cat /proc/sys/vm/swappiness
0
ps(Process Status)监控和管理系统中正在运行的进程。
-e:显示系统中所有进程,而不仅仅是当前用户的进程。
-f:显示完整的进程信息,包括进程的父进程ID、CPU使用率、内存使用量等。
-a 显示当前终端的所有进程
-u:显示与指定用户相关的进程信息。
x:显示所有程序常见组合:ps -aux , ps -ef
USER:进程属于哪个用户
PID(进程ID):每个进程都有一个唯一的标识符,它用于在系统中区分不同的进程。
PPID(父进程ID):每个进程都有一个父进程,PPID表示当前进程的父进程ID。
%CPU(CPU使用率):表示进程在一段时间内使用掉的cpu资源百分比。
%MEM(内存使用率):表示进程当前所占用的物理内存百分比。
VSZ:进程使用掉的虚拟内存量
RSS:进程占用的固定内存量
TTY:进程是在哪个终端上面运作,若与终端机无关,则显示?,若是tty1-tty6,代表本机上面的登入者程序,若为pts/0,则表示为网络连接进主机的程序
STAT(进程状态):表示进程的当前状态,常见的状态包括运行(R)、睡眠(S)、僵尸(Z)等。
START:进程被触发启动的时间
TIME(运行时间):表示进程在CPU上际使用cpu运作的时间
COMMAND:进程的实际指令
[root@jenkins ~]# ps aux|more
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 125756 4156 ? Ss 09:42 0:06 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root 2 0.0 0.0 0 0 ? S 09:42 0:00 [kthreadd]
root 4 0.0 0.0 0 0 ? S< 09:42 0:00 [kworker/0:0H]
root 6 0.0 0.0 0 0 ? S 09:42 0:01 [ksoftirqd/0]
root 7 0.0 0.0 0 0 ? S 09:42 0:00 [migration/0]
root 8 0.0 0.0 0 0 ? S 09:42 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? R 09:42 0:04 [rcu_sched]
root 10 0.0 0.0 0 0 ? S< 09:42 0:00 [lru-add-drain]
root 11 0.0 0.0 0 0 ? S 09:42 0:00 [watchdog/0]
root 13 0.0 0.0 0 0 ? S 09:42 0:00 [kdevtmpfs]
root 14 0.0 0.0 0 0 ? S< 09:42 0:00 [netns]
root 15 0.0 0.0 0 0 ? S 09:42 0:00 [khungtaskd]
root 16 0.0 0.0 0 0 ? S< 09:42 0:00 [writeback]
root 17 0.0 0.0 0 0 ? S< 09:42 0:00 [kintegrityd]
root 18 0.0 0.0 0 0 ? S< 09:42 0:00 [bioset]
root 19 0.0 0.0 0 0 ? S< 09:42 0:00 [bioset]
root 20 0.0 0.0 0 0 ? S< 09:42 0:00 [bioset]
root 21 0.0 0.0 0 0 ? S< 09:42 0:00 [kblockd]
root 22 0.0 0.0 0 0 ? S< 09:42 0:00 [md]
root 23 0.0 0.0 0 0 ? S< 09:42 0:00 [edac-poller]
root 24 0.0 0.0 0 0 ? S< 09:42 0:00 [watchdogd]
root 30 0.0 0.0 0 0 ? S 09:42 0:00 [kswapd0]
root 31 0.0 0.0 0 0 ? SN 09:42 0:00 [ksmd]
root 32 0.0 0.0 0 0 ? SN 09:42 0:00 [khugepaged]
root 33 0.0 0.0 0 0 ? S< 09:42 0:00 [crypto]
root 41 0.0 0.0 0 0 ? S< 09:42 0:00 [kthrotld]
root 43 0.0 0.0 0 0 ? S< 09:42 0:00 [kmpath_rdacd]
root 44 0.0 0.0 0 0 ? S< 09:42 0:00 [kaluad]
root 45 0.0 0.0 0 0 ? S< 09:42 0:00 [kpsmoused]
root 47 0.0 0.0 0 0 ? S< 09:42 0:00 [ipv6_addrconf]
root 60 0.0 0.0 0 0 ? S< 09:42 0:00 [deferwq]
root 96 0.0 0.0 0 0 ? S 09:42 0:00 [kauditd]
root 275 0.0 0.0 0 0 ? S< 09:42 0:00 [mpt_poll_0]
root 276 0.0 0.0 0 0 ? S< 09:42 0:00 [mpt/0]
root 277 0.0 0.0 0 0 ? S< 09:42 0:00 [nfit]
root 278 0.0 0.0 0 0 ? S< 09:42 0:00 [ata_sff]
root 286 0.0 0.0 0 0 ? S 09:42 0:00 [scsi_eh_0]
root 287 0.0 0.0 0 0 ? S< 09:42 0:00 [scsi_tmf_0]
root 288 0.0 0.0 0 0 ? S 09:42 0:01 [kworker/u256:2]
root 289 0.0 0.0 0 0 ? S 09:42 0:00 [scsi_eh_1]
[root@jenkins ~]# ps -ef |more
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 09:42 ? 00:00:06 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root 2 0 0 09:42 ? 00:00:00 [kthreadd]
root 4 2 0 09:42 ? 00:00:00 [kworker/0:0H]
root 6 2 0 09:42 ? 00:00:01 [ksoftirqd/0]
root 7 2 0 09:42 ? 00:00:00 [migration/0]
root 8 2 0 09:42 ? 00:00:00 [rcu_bh]
root 9 2 0 09:42 ? 00:00:04 [rcu_sched]
root 10 2 0 09:42 ? 00:00:00 [lru-add-drain]
root 11 2 0 09:42 ? 00:00:00 [watchdog/0]
root 13 2 0 09:42 ? 00:00:00 [kdevtmpfs]
root 14 2 0 09:42 ? 00:00:00 [netns]
root 15 2 0 09:42 ? 00:00:00 [khungtaskd]
root 16 2 0 09:42 ? 00:00:00 [writeback]
root 17 2 0 09:42 ? 00:00:00 [kintegrityd]
root 18 2 0 09:42 ? 00:00:00 [bioset]
root 19 2 0 09:42 ? 00:00:00 [bioset]
root 20 2 0 09:42 ? 00:00:00 [bioset]
root 21 2 0 09:42 ? 00:00:00 [kblockd]
root 22 2 0 09:42 ? 00:00:00 [md]
root 23 2 0 09:42 ? 00:00:00 [edac-poller]
root 24 2 0 09:42 ? 00:00:00 [watchdogd]
root 30 2 0 09:42 ? 00:00:00 [kswapd0]
root 31 2 0 09:42 ? 00:00:00 [ksmd]
root 32 2 0 09:42 ? 00:00:00 [khugepaged]
root 33 2 0 09:42 ? 00:00:00 [crypto]
root 41 2 0 09:42 ? 00:00:00 [kthrotld]
root 43 2 0 09:42 ? 00:00:00 [kmpath_rdacd]
root 44 2 0 09:42 ? 00:00:00 [kaluad]
root 45 2 0 09:42 ? 00:00:00 [kpsmoused]
root 47 2 0 09:42 ? 00:00:00 [ipv6_addrconf]
root 60 2 0 09:42 ? 00:00:00 [deferwq]
root 96 2 0 09:42 ? 00:00:00 [kauditd]
root 275 2 0 09:42 ? 00:00:00 [mpt_poll_0]
root 276 2 0 09:42 ? 00:00:00 [mpt/0]
root 277 2 0 09:42 ? 00:00:00 [nfit]
root 278 2 0 09:42 ? 00:00:00 [ata_sff]
root 286 2 0 09:42 ? 00:00:00 [scsi_eh_0]
root 287 2 0 09:42 ? 00:00:00 [scsi_tmf_0]
root 288 2 0 09:42 ? 00:00:01 [kworker/u256:2]
root 289 2 0 09:42 ? 00:00:00 [scsi_eh_1]
dstat是一个通用的系统资源统计工具。
安装
yum install dstat -y
[root@jenkins ~]# dstat --help
Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics
Dstat options:
-c, --cpu enable cpu stats
-C 0,3,total include cpu0, cpu3 and total
-d, --disk enable disk stats
-D total,hda include hda and total
-g, --page enable page stats
-i, --int enable interrupt stats
-I 5,eth2 include int5 and interrupt used by eth2
-l, --load enable load stats
-m, --mem enable memory stats
-n, --net enable network stats
-N eth1,total include eth1 and total
-p, --proc enable process stats
-r, --io enable io stats (I/O requests completed)
-s, --swap enable swap stats
-S swap1,total include swap1 and total
-t, --time enable time/date output
-T, --epoch enable time counter (seconds since epoch)
-y, --sys enable system stats
--aio enable aio stats
--fs, --filesystem enable fs stats
--ipc enable ipc stats
--lock enable lock stats
--raw enable raw stats
--socket enable socket stats
--tcp enable tcp stats
--udp enable udp stats
--unix enable unix stats
--vm enable vm stats
--plugin-name enable plugins by plugin name (see manual)
--list list all available plugins
-a, --all equals -cdngy (default)
-f, --full automatically expand -C, -D, -I, -N and -S lists
-v, --vmstat equals -pmgdsc -D total
--bits force bits for values expressed in bytes
--float force float values on screen
--integer force integer values on screen
--bw, --blackonwhite change colors for white background terminal
--nocolor disable colors (implies --noupdate)
--noheaders disable repetitive headers
--noupdate disable intermediate updates
--output file write CSV output to file
--profile show profiling statistics when exiting dstat
delay is the delay in seconds between each update (default: 1)
count is the number of updates to display before exiting (default: unlimited)
iostat命令主要用于输出磁盘IO和CPU的统计信息。iostat首次运行时显示自系统启动开始的各项统计信息,之后运行iostat将显示自上次运行该命令以后的统计信息。
安装
[root@aliyun ~]# yum provides iostat
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/filelists_db | 12 MB 00:00:00
sysstat-10.1.5-19.el7.x86_64 : Collection of performance monitoring tools for Linux
Repo : base
Matched from:
Filename : /usr/bin/iostat
sysstat-10.1.5-20.el7_9.x86_64 : Collection of performance monitoring tools for Linux
Repo : updates
Matched from:
Filename : /usr/bin/iostat
sysstat-10.1.5-20.el7_9.x86_64 : Collection of performance monitoring tools for Linux
Repo : @updates
Matched from:
Filename : /usr/bin/iostat
yum install sysstat -y
# 查看iostat的版本
[root@aliyun ~]# iostat -V
sysstat version 10.1.5
(C) Sebastien Godard (sysstat <at> orange.fr)
# 显示所有设备负载情况
[root@aliyun ~]# iostat
Linux 3.10.0-1160.90.1.el7.x86_64 (aliyun) 07/17/2023 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.31 0.00 0.32 0.01 0.00 99.35
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
vda 0.44 0.70 5.74 1195732 9843536
# x,该选项将用于显示和io相关的扩展数据。%util --》繁忙度
[root@jenkins ~]# iostat -x
Linux 3.10.0-1160.88.1.el7.x86_64 (jenkins) 2023年07月17日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.41 0.00 0.34 0.01 0.00 99.24
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.00 0.03 0.59 0.35 24.11 42.75 141.68 0.00 0.69 0.52 0.97 0.34 0.03
sdb 0.00 1.37 0.13 0.03 36.33 10.41 615.59 0.00 0.71 0.75 0.51 0.41 0.01
scd0 0.00 0.00 0.00 0.00 0.04 0.00 114.22 0.00 1.33 1.33 0.00 1.00 0.00
dm-0 0.00 0.00 0.50 0.37 22.56 42.63 149.87 0.00 0.76 0.59 1.00 0.35 0.03
dm-1 0.00 0.00 0.00 0.01 0.09 0.04 19.19 0.00 0.70 0.23 0.92 0.16 0.00
dm-2 0.00 0.00 0.03 1.39 0.30 10.32 14.95 0.00 0.32 0.18 0.32 0.01 0.00
df 查看磁盘里已经挂载的分区的使用的情况
[root@jenkins ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 898M 0 898M 0% /dev
tmpfs tmpfs 910M 0 910M 0% /dev/shm
tmpfs tmpfs 910M 9.8M 900M 2% /run
tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 17G 7.4G 9.7G 44% /
/dev/sda1 xfs 1014M 190M 825M 19% /boot
tmpfs tmpfs 182M 0 182M 0% /run/user/0
/dev/mapper/sc-sanchuang ext4 6.8G 18M 6.5G 1% /feng
dd 是一个备份工具,可以备份磁盘里的数据
if=/dev/zero input file 输入文件是/dev/zero 零产生器文件
of output file 输出文件
[root@jenkins ~]# dd if=/dev/sdb1 of=sc.dd
^C记录了1705393+0 的读入
记录了1705392+0 的写出
873160704字节(873 MB)已复制,11.6976 秒,74.6 MB/秒
nethogs 查看某个进程消耗了多少流量。
安装
yum install nethogs
使用
# 查看版本
[root@jenkins ~]# nethogs -V
version 0.8.5
# 查看帮助文档
[root@jenkins ~]# nethogs -h
usage: nethogs [-V] [-h] [-b] [-d seconds] [-v mode] [-c count] [-t] [-p] [-s] [device [device [device ...]]]
-V : prints version.
-h : prints this help.
-b : bughunt mode - implies tracemode.
-d : delay for update refresh rate in seconds. default is 1.
-v : view mode (0 = KB/s, 1 = total KB, 2 = total B, 3 = total MB). default is 0.
-c : number of updates. default is 0 (unlimited).
-t : tracemode.
-p : sniff in promiscious mode (not recommended).
-s : sort output by sent column.
-a : monitor all devices, even loopback/stopped ones.
device : device(s) to monitor. default is all interfaces up and running excluding loopback
When nethogs is running, press:
q: quit
s: sort by SENT traffic
r: sort by RECEIVE traffic
m: switch between total (KB, B, MB) and KB/s mode
netstat 命令是Linux系统中的一个常用网络工具,用于显示网络连接、路由表和网络接口等相关信息。它可以帮助我们监控网络活动、诊断网络问题,以及查看网络连接的状态。
安装
yum install net-tools -y
[root@jenkins ~]# netstat -anplut|more
Active Internet connections (servers and established)
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 1011/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1460/master
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1373/mysqld
tcp 0 36 192.168.1.141:22 192.168.1.125:52880 ESTABLISHED 33488/sshd: root@pt
tcp 0 0 192.168.1.141:22 192.168.1.125:55666 ESTABLISHED 2530/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 1011/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1460/master
tcp6 0 0 :::2377 :::* LISTEN 1350/dockerd
tcp6 0 0 :::7946 :::* LISTEN 1350/dockerd
udp 0 0 127.0.0.1:323 0.0.0.0:* 737/chronyd
udp 0 0 0.0.0.0:4789 0.0.0.0:* -
udp6 0 0 ::1:323 :::* 737/chronyd
udp6 0 0 :::7946 :::* 1350/dockerd
-anutlp
-a all 显示所有的信息
-n [--numeric|-n] 以数字的形式显示--》不显示名字
-u 查看udp协议
-t 查看tcp协议
-l 处于listen状态
-p 显示程序的名字 PID/Program name
Recv-Q:接受数据的队列 receive queue --》内存里存放数据的临时空间
Send-Q:发送数据的队列 send queue
Local Address
127.0.0.1 --》loopback
192.168.1.141 --》ens33
0.0.0.0 --》代表这个linux服务器所有接口的ip地址--》通配符--》任意ip地址
Foreign Address
0.0.0.0:* --》ipv4---》代表任意ip任意端口
:::* --》ipv6里的任意ip任意端口
State
LISTEN --》监听 --》服务器开启了某个端口,对外提供服务
ESTABLISHED --》建立连接
TIME_WAIT 表示已经要断开--》自己发起的断开--》释放连接
lsof(list open files)命令可以列出当前系统已经打开的所有文件。
安装
yum install lsof -y
# 查看端口被那个进程占用了
[root@jenkins ~]# lsof -i:22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1011 root 3u IPv4 28940 0t0 TCP *:ssh (LISTEN)
sshd 1011 root 4u IPv6 28954 0t0 TCP *:ssh (LISTEN)
sshd 2530 root 3u IPv4 37734 0t0 TCP jenkins:ssh->192.168.1.125:55666 (ESTABLISHED)
sshd 33488 root 3u IPv4 147093 0t0 TCP jenkins:ssh->192.168.1.125:52880 (ESTABLISHED)
# 查看某个进程加载了哪些库
[root@jenkins ~]# lsof -p 1
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd 1 root cwd DIR 253,0 4096 64 /
systemd 1 root rtd DIR 253,0 4096 64 /
systemd 1 root txt REG 253,0 1632960 33708267 /usr/lib/systemd/systemd
systemd 1 root mem REG 253,0 20064 41923 /usr/lib64/libuuid.so.1.3.0
systemd 1 root mem REG 253,0 265576 42164 /usr/lib64/libblkid.so.1.1.0
systemd 1 root mem REG 253,0 90160 251688 /usr/lib64/libz.so.1.2.7
systemd 1 root mem REG 253,0 157440 251696 /usr/lib64/liblzma.so.5.2.2
systemd 1 root mem REG 253,0 23968 42206 /usr/lib64/libcap-ng.so.0.0.0
systemd 1 root mem REG 253,0 19896 41914 /usr/lib64/libattr.so.1.1.0
systemd 1 root mem REG 253,0 19248 38454 /usr/lib64/libdl-2.17.so
systemd 1 root mem REG 253,0 402384 41925 /usr/lib64/libpcre.so.1.2.0
systemd 1 root mem REG 253,0 2156592 38448 /usr/lib64/libc-2.17.so
systemd 1 root mem REG 253,0 142144 251366 /usr/lib64/libpthread-2.17.so
systemd 1 root mem REG 253,0 88720 15878 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
systemd 1 root mem REG 253,0 43712 251371 /usr/lib64/librt-2.17.so
systemd 1 root mem REG 253,0 277808 42303 /usr/lib64/libmount.so.1.1.0
systemd 1 root mem REG 253,0 91800 42585 /usr/lib64/libkmod.so.2.2.10
systemd 1 root mem REG 253,0 127184 42207 /usr/lib64/libaudit.so.1.0.0
systemd 1 root mem REG 253,0 61680 446837 /usr/lib64/libpam.so.0.83.1
systemd 1 root mem REG 253,0 20048 251704 /usr/lib64/libcap.so.2.22
systemd 1 root mem REG 253,0 155744 251682 /usr/lib64/libselinux.so.1
systemd 1 root mem REG 253,0 163312 38440 /usr/lib64/ld-2.17.so
systemd 1 root 0u CHR 1,3 0t0 6513 /dev/null
systemd 1 root 1u CHR 1,3 0t0 6513 /dev/null
systemd 1 root 2u CHR 1,3 0t0 6513 /dev/null
systemd 1 root 3u a_inode 0,10 0 6509 [timerfd]
systemd 1 root 4u a_inode 0,10 0 6509 [eventpoll]
systemd 1 root 5u a_inode 0,10 0 6509 [signalfd]
systemd 1 root 6r DIR 0,22 0 8717 /sys/fs/cgroup/systemd
systemd 1 root 7u a_inode 0,10 0 6509 [timerfd]
systemd 1 root 8u netlink 0t0 13810 KOBJECT_UEVENT
systemd 1 root 9r REG 0,3 0 8993 /proc/1/mountinfo
systemd 1 root 10r a_inode 0,10 0 6509 inotify
systemd 1 root 11r REG 0,3 0 4026532019 /proc/swaps
systemd 1 root 12u unix 0xffff8871f69ba200 0t0 13811 /run/systemd/private
systemd 1 root 14u unix 0xffff8872365efb40 0t0 61250 socket
systemd 1 root 15r a_inode 0,10 0 6509 inotify
systemd 1 root 16u unix 0xffff887239755500 0t0 9000 /run/systemd/notify
systemd 1 root 17u unix 0xffff887239755d80 0t0 9002 /run/systemd/cgroups-agent
systemd 1 root 18u unix 0xffff887239756600 0t0 15195 /run/systemd/shutdownd
systemd 1 root 19u netlink 0t0 13816 AUDIT
systemd 1 root 20r a_inode 0,10 0 6509 inotify
systemd 1 root 32r CHR 10,235 0t0 8486 /dev/autofs
systemd 1 root 41u unix 0xffff8872365ed500 0t0 22479 /run/docker.sock
systemd 1 root 44u unix 0xffff8872356ef2c0 0t0 23470 socket
systemd 1 root 46u unix 0xffff887239755940 0t0 9019 /run/systemd/journal/stdout
systemd 1 root 48u unix 0xffff887239754c80 0t0 9022 /run/systemd/journal/socket
systemd 1 root 52u unix 0xffff887239751dc0 0t0 9024 /dev/log
systemd 1 root 54u unix 0xffff8871f69bbfc0 0t0 14131 /run/lvm/lvmpolld.socket
systemd 1 root 55u unix 0xffff8871f69b9540 0t0 14021 /run/udev/control
systemd 1 root 57u unix 0xffff8871f69b9dc0 0t0 30085 /run/systemd/journal/stdout
systemd 1 root 58u unix 0xffff88722f8cd0c0 0t0 29303 /run/systemd/journal/stdout
systemd 1 root 60u unix 0xffff887235449dc0 0t0 28871 /run/systemd/journal/stdout
systemd 1 root 61u unix 0xffff8871f69bfb40 0t0 28699 /run/systemd/journal/stdout
systemd 1 root 62u unix 0xffff8872366c6600 0t0 25158 /run/systemd/journal/stdout
systemd 1 root 63u unix 0xffff8872366c3b80 0t0 23967 /run/systemd/journal/stdout
systemd 1 root 64u unix 0xffff8871f69b9100 0t0 23585 /run/systemd/journal/stdout
systemd 1 root 65u unix 0xffff8872365ef2c0 0t0 23581 /run/systemd/journal/stdout
systemd 1 root 66u unix 0xffff8872365ee1c0 0t0 23577 /run/systemd/journal/stdout
systemd 1 root 67u unix 0xffff8872365ed0c0 0t0 23574 /run/systemd/journal/stdout
systemd 1 root 68u unix 0xffff8872356ea200 0t0 18108 /run/systemd/journal/stdout
systemd 1 root 69u unix 0xffff8872356eea40 0t0 17938 /run/systemd/journal/stdout
systemd 1 root 70u unix 0xffff8872397561c0 0t0 15082 /run/lvm/lvmetad.socket
systemd 1 root 71u FIFO 0,20 0t0 14128 /run/dmeventd-server
systemd 1 root 72u FIFO 0,20 0t0 14129 /run/dmeventd-client
systemd 1 root 73r FIFO 0,9 0t0 15078 pipe
systemd 1 root 74u unix 0xffff8872365ea200 0t0 22481 /run/dbus/system_bus_socket
systemd 1 root 75u netlink 0t0 14130 KOBJECT_UEVENT
systemd 1 root 76u FIFO 0,20 0t0 14135 /run/systemd/initctl/fifo
# 查看某个文件或者文件夹被那个进程使用
[root@jenkins ~]# lsof /root
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 33490 root cwd DIR 253,0 4096 33574977 /root
lsof 34636 root cwd DIR 253,0 4096 33574977 /root
lsof 34637 root cwd DIR 253,0 4096 33574977 /root
nc(netcat)是一个功能强大的网络工具
1.实现任意TCP/UDP端口的侦听(nc可以作为server以TCP或UDP方式侦听指定端口)
2.端口的扫描(nc可以作为client发起TCP或UDP连接)
安装
yum install nc -y
[root@jenkins ~]# nc -zv 192.168.1.125 22
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.1.125:22.
Ncat: 0 bytes sent, 0 bytes received in 0.04 seconds.
[root@jenkins ~]# nc -zv 192.168.1.125 21
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connection timed out.
# 查看版本
[root@jenkins ~]# nc -v
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: You must specify a host to connect to. QUITTING.
[root@jenkins ~]# nc -h
Ncat 7.50 ( https://nmap.org/ncat )
Usage: ncat [options] [hostname] [port]
Options taking a time assume seconds. Append 'ms' for milliseconds,
's' for seconds, 'm' for minutes, or 'h' for hours (e.g. 500ms).
-4 Use IPv4 only
-6 Use IPv6 only
-U, --unixsock Use Unix domain sockets only
-C, --crlf Use CRLF for EOL sequence
-c, --sh-exec <command> Executes the given command via /bin/sh
-e, --exec <command> Executes the given command
--lua-exec <filename> Executes the given Lua script
-g hop1[,hop2,...] Loose source routing hop points (8 max)
-G <n> Loose source routing hop pointer (4, 8, 12, ...)
-m, --max-conns <n> Maximum <n> simultaneous connections
-h, --help Display this help screen
-d, --delay <time> Wait between read/writes
-o, --output <filename> Dump session data to a file
-x, --hex-dump <filename> Dump session data as hex to a file
-i, --idle-timeout <time> Idle read/write timeout
-p, --source-port port Specify source port to use
-s, --source addr Specify source address to use (doesn't affect -l)
-l, --listen Bind and listen for incoming connections
-k, --keep-open Accept multiple connections in listen mode
-n, --nodns Do not resolve hostnames via DNS
-t, --telnet Answer Telnet negotiations
-u, --udp Use UDP instead of default TCP
--sctp Use SCTP instead of default TCP
-v, --verbose Set verbosity level (can be used several times)
-w, --wait <time> Connect timeout
-z Zero-I/O mode, report connection status only
--append-output Append rather than clobber specified output files
--send-only Only send data, ignoring received; quit on EOF
--recv-only Only receive data, never send anything
--allow Allow only given hosts to connect to Ncat
--allowfile A file of hosts allowed to connect to Ncat
--deny Deny given hosts from connecting to Ncat
--denyfile A file of hosts denied from connecting to Ncat
--broker Enable Ncat's connection brokering mode
--chat Start a simple Ncat chat server
--proxy <addr[:port]> Specify address of host to proxy through
--proxy-type <type> Specify proxy type ("http" or "socks4" or "socks5")
--proxy-auth <auth> Authenticate with HTTP or SOCKS proxy server
--ssl Connect or listen with SSL
--ssl-cert Specify SSL certificate file (PEM) for listening
--ssl-key Specify SSL private key (PEM) for listening
--ssl-verify Verify trust and domain name of certificates
--ssl-trustfile PEM file containing trusted SSL certificates
--ssl-ciphers Cipherlist containing SSL ciphers to use
--version Display Ncat's version information and exit
See the ncat(1) manpage for full options, descriptions and usage examples
nmap(Network Mapper)它是一个免费的开源网络扫描和侦察工具,用于扫描主机和收集有关主机的详细信息。
安装
yum install nmap -y
# nmap命令用于扫描单个主机
[root@jenkins ~]# nmap 192.168.1.1
Starting Nmap 6.40 ( http://nmap.org ) at 2023-07-17 20:00 CST
Nmap scan report for 192.168.1.1
Host is up (0.0041s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
53/tcp filtered domain
80/tcp open http
1900/tcp open upnp
MAC Address: 98:97:CC:85:DF:51 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 15.01 seconds
[root@jenkins ~]# nmap -v
Starting Nmap 6.40 ( http://nmap.org ) at 2023-07-17 20:01 CST
Read data files from: /usr/bin/../share/nmap
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 0.03 seconds
Raw packets sent: 0 (0B) | Rcvd: 0 (0B)
[root@jenkins ~]# nmap -h
Nmap 6.40 ( http://nmap.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
Can pass hostnames, IP addresses, networks, etc.
Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
-iL <inputfilename>: Input from list of hosts/networks
-iR <num hosts>: Choose random targets
--exclude <host1[,host2][,host3],...>: Exclude hosts/networks
--excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
-sL: List Scan - simply list targets to scan
-sn: Ping Scan - disable port scan
-Pn: Treat all hosts as online -- skip host discovery
-PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
-PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
-PO[protocol list]: IP Protocol Ping
-n/-R: Never do DNS resolution/Always resolve [default: sometimes]
--dns-servers <serv1[,serv2],...>: Specify custom DNS servers
--system-dns: Use OS's DNS resolver
--traceroute: Trace hop path to each host
SCAN TECHNIQUES:
-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
-sU: UDP Scan
-sN/sF/sX: TCP Null, FIN, and Xmas scans
--scanflags <flags>: Customize TCP scan flags
-sI <zombie host[:probeport]>: Idle scan
-sY/sZ: SCTP INIT/COOKIE-ECHO scans
-sO: IP protocol scan
-b <FTP relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
-p <port ranges>: Only scan specified ports
Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
-F: Fast mode - Scan fewer ports than the default scan
-r: Scan ports consecutively - don't randomize
--top-ports <number>: Scan <number> most common ports
--port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
-sV: Probe open ports to determine service/version info
--version-intensity <level>: Set from 0 (light) to 9 (try all probes)
--version-light: Limit to most likely probes (intensity 2)
--version-all: Try every single probe (intensity 9)
--version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
-sC: equivalent to --script=default
--script=<Lua scripts>: <Lua scripts> is a comma separated list of
directories, script-files or script-categories
--script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
--script-args-file=filename: provide NSE script args in a file
--script-trace: Show all data sent and received
--script-updatedb: Update the script database.
--script-help=<Lua scripts>: Show help about scripts.
<Lua scripts> is a comma separted list of script-files or
script-categories.
OS DETECTION:
-O: Enable OS detection
--osscan-limit: Limit OS detection to promising targets
--osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
Options which take <time> are in seconds, or append 'ms' (milliseconds),
's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
-T<0-5>: Set timing template (higher is faster)
--min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
--min-parallelism/max-parallelism <numprobes>: Probe parallelization
--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
probe round trip time.
--max-retries <tries>: Caps number of port scan probe retransmissions.
--host-timeout <time>: Give up on target after this long
--scan-delay/--max-scan-delay <time>: Adjust delay between probes
--min-rate <number>: Send packets no slower than <number> per second
--max-rate <number>: Send packets no faster than <number> per second
FIREWALL/IDS EVASION AND SPOOFING:
-f; --mtu <val>: fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
-S <IP_Address>: Spoof source address
-e <iface>: Use specified interface
-g/--source-port <portnum>: Use given port number
--data-length <num>: Append random data to sent packets
--ip-options <options>: Send packets with specified ip options
--ttl <val>: Set IP time-to-live field
--spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
--badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
-oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
and Grepable format, respectively, to the given filename.
-oA <basename>: Output in the three major formats at once
-v: Increase verbosity level (use -vv or more for greater effect)
-d: Increase debugging level (use -dd or more for greater effect)
--reason: Display the reason a port is in a particular state
--open: Only show open (or possibly open) ports
--packet-trace: Show all packets sent and received
--iflist: Print host interfaces and routes (for debugging)
--log-errors: Log errors/warnings to the normal-format output file
--append-output: Append to rather than clobber specified output files
--resume <filename>: Resume an aborted scan
--stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
--webxml: Reference stylesheet from Nmap.Org for more portable XML
--no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
-6: Enable IPv6 scanning
-A: Enable OS detection, version detection, script scanning, and traceroute
--datadir <dirname>: Specify custom Nmap data file location
--send-eth/--send-ip: Send using raw ethernet frames or IP packets
--privileged: Assume that the user is fully privileged
--unprivileged: Assume the user lacks raw socket privileges
-V: Print version number
-h: Print this help summary page.
EXAMPLES:
nmap -v -A scanme.nmap.org
nmap -v -sn 192.168.0.0/16 10.0.0.0/8
nmap -v -iR 10000 -Pn -p 80
SEE THE MAN PAGE (http://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES
telnet命令是TELNET协议的用户接口,它支持两种模式:命令模式和会话模式,一般使用它查看目标主机是否打开了某端口(默认是23)。
安装
yum install telnet -y
# 端口已打开
[root@jenkins ~]# telnet 192.168.1.141 22
Trying 192.168.1.141...
Connected to 192.168.1.141.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4
^C^Z^C^C^C^C
Connection closed by foreign host.
# 端口未打开
[root@jenkins ~]# telnet 192.168.1.141 21
Trying 192.168.1.141...
telnet: connect to address 192.168.1.141: Connection refused
iptraf是一款交互式、色彩鲜艳的IP局域网监控工具。它可以显示每个连接以及主机之间传输的数据量。下面是屏幕截图。
安装
yum install iptraf -y
iptraf-ng