# 系統監控

## apachetop

監控 apache 伺服器的整體性能。基於 mytop。它會顯示當前的讀取進程、寫入進程的數量以及請求進程的總數。

## ftptop

提供了當前所有連接到 ftp 伺服器的基本信息，如會話總數，正在上傳和下載的客戶端數量以及客戶端是誰。

## mytop

監控 mysql 的線程和性能。它能讓你實時查看資料庫以及正在處理哪些查詢。

## powertop

診斷與電量消耗和電源管理相關的問題

## iotop

檢查 I/O 的使用情況，它按列顯示讀和寫的速率，每行代表一個進程。發生**交換或 I/O 等待**時，它會顯示進程消耗時間的百分比<br>

vnstat

```

   rx:         0 bit/s     0 p/s          tx:         0 bit/s     0 p/s^C


 wlp4s0  /  traffic statistics

                           rx         |       tx
--------------------------------------+------------------
  bytes                     1.32 KiB  |        2.52 KiB
--------------------------------------+------------------
          max            2.78 kbit/s  |     5.60 kbit/s
      average              773 bit/s  |     1.47 kbit/s
          min                0 bit/s  |         0 bit/s
--------------------------------------+------------------
  packets                         16  |              16
--------------------------------------+------------------
          max                  4 p/s  |           4 p/s
      average                  1 p/s  |           1 p/s
          min                  0 p/s  |           0 p/s
--------------------------------------+------------------
  time                    14 seconds
```

絡流量監控工具，它的數據統計是由內核進行提供的，其消耗的系統資源非常少\ <br>

## ss

**ss**是**iproute2**的一部分， 命令能夠顯示的信息比 netstat 更多，也更快。如果你想查看統計結果的總信息，可以使用命令ss -s

```
ss -tn -o state established -p
```

查詢系統上所有使用 IPv4 所開啟的 sockets，並列出每個 sockets 所對應的應用程式：

```
sudo ss -t4lp
sudo ss -t4lpn
```

### 篩選器

列出從本機連線到 `192.168.43.100` 這台主機的所有連線：

```
ss -o state established dst 192.168.43.100
Netid               Recv-Q               Send-Q                              Local Address:Port                               Peer Address:Port               
tcp                 0                    0                                  192.168.43.129:ssh                              192.168.43.100:53954               timer:(keepalive,116min,0)

ss -o state established src 192.168.43.100
```

`ss` 指令可以自己指定port，篩選出自己需要的 sockets 資訊

```
ss -o state established '( dport = :ssh or sport = :ssh )'
Netid         Recv-Q         Send-Q                    Local Address:Port                       Peer Address:Port         Process                             
tcp           0              0                         192.168.122.1:38216                   192.168.122.247:ssh           timer:(keepalive,119min,0)         
tcp           0              0                        192.168.43.100:53954                    192.168.43.129:ssh           timer:(keepalive,110min,0)       
```

```
ss -o state syn-recv
Netid  Recv-Q Send-Q                                  Local Address:Port                                                   Peer Address:Port                
tcp    0      0                                 2001:288:7201:2::88:http                          2402:7500:466:2f24:84b0:efb4:da74:3ab:51668                 timer:(on,1.660ms,0)
tcp    0      0                                 ::ffff:120.115.2.88:http                                          ::ffff:46.229.168.134:54402                 timer:(on,848ms,0)
tcp    0      0                                 ::ffff:120.115.2.88:http                                          ::ffff:46.229.168.137:45508                 timer:(on,952ms,0)
tcp    0      0                                 2001:288:7201:2::88:http                                          2402:7500:567:5d8f::1:48538                 timer:(on,1.084ms,0)
tcp    0      0                                 2001:288:7201:2::88:http                                          2402:7500:567:5d8f::1:48546                 timer:(on,140ms,0)
tcp    0      0                                 2001:288:7201:2::88:http                                          2402:7500:567:5d8f::1:48539                 timer:(on,1.084ms,0)
tcp    0      0                                 2001:288:7201:2::88:http                            2001:288:759e:0:e8a0:1494:3694:c61b:49182                 timer:(on,4.304ms,0)
tcp    0      0                                 2001:288:7201:2::88:http                         2001:b400:e752:7989:160:a722:fb0d:f54f:46894                 timer:(on,4.620ms,0)
tcp    0      0                                 2001:288:7201:2::88:http                             2001:288:75d6:0:c0f:1b34:9fca:e79c:50063                 timer:(on,372ms,0)
tcp    0      0                                 2001:288:7201:2::88:http                          2402:7500:466:2f24:84b0:efb4:da74:3ab:51667                 
```

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kawsing.gitbook.io/opensystem/andoid-shou-ji/wang-lu-da-xiao-shi/xi-tong-jian-kong.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
