[root@Rocky8-mini ~]# free total used free shared buff/cache available Mem: 1833232 224152 1306820 8900 302260 1448232 Swap: 2097148 0 2097148 [root@Rocky8-mini ~]# free -h total used free shared buff/cache available Mem: 1.7Gi 218Mi 1.2Gi 8.0Mi 295Mi 1.4Gi Swap: 2.0Gi 0B 2.0Gi
关于缓存的清理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[root@Rocky8-mini ~]# man proc ··· /proc/sys/vm/drop_caches (since Linux 2.6.16) Writing to this file causes the kernel to drop clean caches, dentries, and inodes from memory, causing that memory to become free. This can be useful for memory management testing and performing reproducible filesystem benchmarks.Because writing to this file causes the benefits of caching to be lost, it can degrade overall system performance. To free pagecache, use: echo 1 > /proc/sys/vm/drop_caches To free dentries and inodes, use: echo 2 > /proc/sys/vm/drop_caches To free pagecache, dentries and inodes, use: echo 3 > /proc/sys/vm/drop_caches Because writing to this file is a nondestructive operation and dirty objects are not freeable, the user should run sync(1) first.
cpu: us: Time spent running non-kernel code sy: Time spent running kernel code id: Time spent idle. Linux 2.5.41前,包括IO-wait time. wa: Time spent waiting for IO. 2.5.41前,包括in idle. st: Time stolen from a virtual machine. 2.6.11前, unknown.
[root@Rocky8-mini ~]# 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 1389468 4252 225424 0 0 43 10 47 90 0 0 100 0 0 [root@Rocky8-mini ~]# vmstat 1 3 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 1389656 4252 225468 0 0 43 10 47 90 0 0 100 0 0 0 0 0 1389468 4252 225468 0 0 0 0 106 150 0 0 99 0 0 0 0 0 1389468 4252 225468 0 0 0 0 89 135 0 0 100 0 0 [root@Rocky8-mini ~]# vmstat -s 1833232 K total memory 213812 K used memory 81988 K active memory 164084 K inactive memory 1389708 K free memory 4252 K buffer memory 225460 K swap cache 2097148 K total swap 0 K used swap 2097148 K free swap 177 non-nice user cpu ticks 0 nice user cpu ticks 1140 system cpu ticks 444917 idle cpu ticks 22 IO-wait cpu ticks 357 IRQ cpu ticks 301 softirq cpu ticks 0 stolen cpu ticks 190362 pages paged in 42375 pages paged out 0 pages swapped in 0 pages swapped out 211123 interrupts 402441 CPU context switches 1671328052 boot time 1763 forks
r/s: 每秒合并后读的请求数 w/s: 每秒合并后写的请求数 rsec/s:每秒读取的扇区数; wsec/:每秒写入的扇区数。 rKB/s:The number of read requests that were issued to the device per second wKB/s:The number of write requests that were issued to the device per second rrqm/s:每秒这个设备相关的读取请求有多少被Merge了(当系统调用需要读取数据的时候,VFS将请求发到各个FS,如果FS发现不同的读取请求读取的是相同Block的数据,FS会将这个请求合并Merge) wrqm/s:每秒这个设备相关的写入请求有多少被Merge了 %rrqm: The percentage of read requests merged together before being sent to the device. %wrqm: The percentage of write requests merged together before being sent to the device. avgrq-sz 平均请求扇区的大小 avgqu-sz 是平均请求队列的长度。毫无疑问,队列长度越短越好 await: 每一个IO请求的处理的平均时间(单位是微秒毫秒)。这里可以理解为IO的响应时间,一般地系统IO响应时间应该低于5ms,如果大于10ms就比较大了。这个时间包括了队列时间和服务时间,也就是说,一般情况下,await大于svctm,它们的差值越小,则说明队列时间越短,反之差值越大,队列时间越长,说明系统出了问题 svctm 表示平均每次设备I/O操作的服务时间(以毫秒为单位)。如果svctm的值与await很接近,表示几乎没有I/O等待,磁盘性能很好,如果await的值远高于svctm的值,则表示I/O队列等待太长,系统上运行的应用程序将变慢 %util: 在统计时间内所有处理IO时间,除以总共统计时间。例如,如果统计间隔1秒,该设备有0.8秒在处理IO,而0.2秒闲置,那么该设备的%util = 0.8/1 = 80%,所以该参数暗示了设备的繁忙程度。一般地,如果该参数是100%表示设备已经接近满负荷运行了(当然如果是多磁盘,即使%util是100%,因为磁盘的并发能力,所以磁盘使用未必就到了瓶颈)
OPTIONS --version Show the version number and exit
-h, --help Show usage information and exit
-o, --only Only show processes or threads actually doing I/O, instead of showing all processes or threads. This can be dynamically toggled by pressing o.
-b, --batch Turn on non-interactive mode. Useful for logging I/O usage over time.
-n NUM, --iter=NUM Set the number of iterations before quitting (never quit by default). This is most useful in non-interactive mode.
-d SEC, --delay=SEC Set the delay between iterations in seconds (1 second by default). Accepts non-integer values such as 1.1 seconds.
-p PID, --pid=PID A list of processes/threads to monitor (all by default).
-u USER, --user=USER A list of users to monitor (all by default)
-P, --processes Only show processes. Normally iotop shows all threads.
-a, --accumulated Show accumulated I/O instead of bandwidth. In this mode, iotop shows the amount of I/O processes have done since iotop started.
-k, --kilobytes Use kilobytes instead of a human friendly unit. This mode is useful when scripting the batch mode of iotop. Instead of choosing the most appropriate unit iotop will display all sizes in kilobytes.
-t, --time Add a timestamp on each line (implies --batch). Each line will be prefixed by the current time.
-q, --quiet suppress some lines of header (implies --batch). This option can be specified up to three times to remove header lines. -q column names are only printed on the first iteration, -qq column names are never printed, -qqq the I/O summary is never printed.
交互按键
1 2 3 4 5 6 7
left 和 right 方向键: 改变排序 r: 反向排序 o: 切换至选项--only p: 切换至--processes选项 a: 切换至--accumulate选项 q: 退出 i: 改变线程的优先级
2.14 显示网络带宽使用情况 iftop
来自于epel源的iftop包
1 2 3 4
[root@Rocky8-mini ~]# iftop interface: eth0 IP address is: 192.168.119.128 MAC address is: 00:0c:29:4d:a8:89
a Sort processes automatically l Show/hide logs c Sort processes by CPU% b Bytes or bits for network I/O m Sort processes by MEM% w Delete warning logs p Sort processes by name x Delete warning and critical logs i Sort processes by I/O rate 1 Global CPU or per-CPU stats d Show/hide disk I/O stats h Show/hide this help screen f Show/hide file system stats t View network I/O as combination n Show/hide network stats u View cumulative network I/O s Show/hide sensors stats q Quit (Esc and Ctrl-C also work) y Show/hide hddtemp stats
[root@Rocky8-mini ~]# nohup ping 127.0.0.1 nohup: ignoring input and appending output to 'nohup.out'
[root@Rocky8-mini ~]# tail -f nohup.out 64 bytes from 127.0.0.1: icmp_seq=34 ttl=64 time=0.030 ms 64 bytes from 127.0.0.1: icmp_seq=35 ttl=64 time=0.040 ms 64 bytes from 127.0.0.1: icmp_seq=36 ttl=64 time=0.032 ms 64 bytes from 127.0.0.1: icmp_seq=37 ttl=64 time=0.029 ms
[root@Rocky8-mini ~]# cat test.sh #!/bin/bash net=192.168.0 for i in {100..110};do { ping -c1 -w1 ${net}.${i} &> /dev/null && echo${net}.${i} is up || echo${net}.${i} is done; }& done wait
[root@wh-ctyun ~]# man 5 crontab The time and date fields are:
field allowed values ----- -------------- minute 0-59 hour 0-23 day of month 1-31 month 1-12 (or names, see below) day of week 0-7 (0 or 7 is Sunday, or use names) Note: The day of a command's execution can be specified in the following two fields — 'day of month', and 'day of week'. If both fields are restricted (i.e., do not contain the "*" character), the command will be run when either field matches the current time. For example, "30 4 1,15 * 5" would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.