Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux RRDtool 入門實戰:建庫、更新資料、繪圖三步驟完整指令範例

編輯:關於 Linux

RRDtool (Round Robin Database) 以固定大小環狀空間存儲時間序列資料,廣泛用於 MRTG、Ganglia 等監控繪圖。本文詳細拆解 rrdtool create 建庫語法 (DS、RRA、CF、PDP、CDP 參數含義)、rrdtool updatev 定時寫入資料、rrdtool graph 繪製堆疊面積圖 (AREA/STACK/LINE/GPRINT/VDEF) 的完整指令範例,並展示含無資料區間的輸出圖片。

核心指令結構

建庫 (cpu.rrd,每 15 秒更新):

rrdtool create cpu.rrd \
  --start $(date -d '1 days ago' +%s) --step 15 \
  DS:cpu_user:GAUGE:120:0:NaN \
  DS:cpu_system:GAUGE:120:0:NaN \
  DS:cpu_wio:GAUGE:120:0:NaN \
  DS:cpu_idle:GAUGE:120:0:NaN \
  RRA:AVERAGE:0.5:1:244 \
  RRA:AVERAGE:0.5:24:244 \
  RRA:AVERAGE:0.5:168:244 \
  RRA:AVERAGE:0.5:672:244 \
  RRA:AVERAGE:0.5:5760:374

更新: rrdtool updatev cpu.rrd timestamp:user:system:wio:idle

繪圖: 使用 DEF 取得變數,AREA/STACK 繪製堆疊,VDEF 計算統計值,GPRINT 列印當前/平均值。

掌握 RRDtool 三步驟,即可自建輕量級時間序列資料庫與即時圖表系統。

Copyright © Windows教程網 All Rights Reserved