在CentOS Minimal系統中監控資源,你可以使用多種工具和方法。以下是一些常用的工具和步驟:
top
命令可以實時顯示系統中各個進程的資源占用情況,包括CPU使用率、內存使用量等。
top
vmstat
命令用于統計系統的虛擬內存使用情況,包括內存使用率、交換空間使用率等。
vmstat 1 4 # 持續監控4秒
iostat
命令用于監控磁盤I/O使用情況,包括磁盤讀寫速度、CPU使用率等。
iostat -x 1 4 # 持續監控4秒
nmon
是一個開源的性能監控工具,可以監控CPU、內存、磁盤和網絡等方面的性能指標,并以圖形化的形式展現。
wget https://github.com/syerram/nmon/releases/download/v2.04/nmon-2.04.tar.gz
tar -zxvf nmon-2.04.tar.gz
cd nmon-2.04
./configure
make
sudo make install
sudo nmon -c -d -t 10 # 持續監控10秒,每秒刷新一次
Prometheus是一個開源的監控系統,支持多種數據源,包括Node Exporter、JMX Exporter、Blackbox Exporter等。Grafana是一個開源的分析和監測平臺,可以與Prometheus等數據源集成,提供強大的可視化功能。
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
tar xvfz prometheus-2.30.3.linux-amd64.tar.gz
cd prometheus-2.30.3.linux-amd64
./prometheus --config.file=prometheus.yml
wget https://dl.grafana.com/oss/release/grafana-8.2.0.linux-amd64.tar.gz
tar -zxvf grafana-8.2.0.linux-amd64.tar.gz
cd grafana-8.2.0
./bin/grafana-server
編輯prometheus.yml
文件,添加Grafana的IP地址和端口。
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['node_exporter:9100']
訪問http://<your_server_ip>:3000
,登錄后,進入Configuration
-> Data Sources
,添加Prometheus作為數據源,并選擇相應的配置文件。
在Grafana中,點擊Add panel
,搜索并導入Prometheus提供的面板,如System Overview
、CPU Usage
等。
以上方法可以幫助你在CentOS Minimal系統中有效地監控資源使用情況。根據你的具體需求,可以選擇適合的工具進行監控。