最後更新: 2022-02-09
rrd 結構
The data is stored in a circular buffer based database,
thus the system storage footprint remains constant over time.
RRDtool assumes time-variable data in intervals of a certain length.
This interval, usually named step, is specified upon creation of a RRD file and cannot be changed afterwards.
The value for a specific step, that has been interpolated, is named a primary data point (PDP).
Multiple PDPs may be consolidated according to a consolidation function (CF) to form a consolidated data point (CDP).
Typical consolidation functions(CF) are average, minimum, maximum.
After the data has been consolidated, the resulting CDP is stored in a round-robin archive (RRA).
PDP__step__PDP__step__PDP__step__PDP__step__PDP | CF | CF CDP CDP = RRA
A round-robin archive stores a fixed number of CDPs and
specifies how many PDPs should be consolidated into one CDP and which CF to use.
The total time covered by a RRA can be calculated as follows:
Time covered = (CDPs stored) x (PDPs per CDP) x (Step time length)
rrdtool
info
# localhost-load-load-g.rrd 是 munin 的 rrd 檔
rrdtool info localhost-swap-swap_out-d.rrd
filename = "localhost-load-load-g.rrd" rrd_version = "0003" step = 300 last_update = 1542081304 ds[42].type = "GAUGE" ds[42].minimal_heartbeat = 600 ds[42].min = NaN ds[42].max = NaN ds[42].last_ds = "0.03" ds[42].value = 1.2000000000e-01 ds[42].unknown_sec = 0 rra[0].cf = "AVERAGE" rra[0].rows = 576 rra[0].cur_row = 429 rra[0].pdp_per_row = 1 rra[0].xff = 5.0000000000e-01 rra[0].cdp_prep[0].value = NaN rra[0].cdp_prep[0].unknown_datapoints = 0 rra[1].cf = "MIN" rra[1].rows = 576 rra[1].cur_row = 326 rra[1].pdp_per_row = 1 rra[1].xff = 5.0000000000e-01 rra[1].cdp_prep[0].value = NaN rra[1].cdp_prep[0].unknown_datapoints = 0 ....
last_ds is the last received value of the DS, prior to calculation of Rate, at last_update time.
last_ds is different from value as it is before rate calculations and normalisation.
new_value = ( new_ds - last_ds ) / ( current_time - last_update )
dump
rrdtool dump localhost-load-load-g.rrd
StepSize 與 HeartBeat
StepSize
This tells RRDTool how many seconds there will be between updates.
set to the interval in which the data is collected
Note: When using 1 min polling, Step has to be adjusted, e.g. to a value of 60.
* of newly created RRD-files
Heartbeat
If rrd's are not updated within Heartbeat's seconds,
the needed data point is assumed to be NaN (“Not a Number = no valid data).
Usually set to twice the StepSize
Data 數量
Number of PDPs per CDP = RRATimespan / (StepSize x RRARows)
ie.
StepSize 30 RRARows 288 RRATimespan 86400
Reault: 10 <= 當採集了 10 次 data 後就會行一次 CF(consolidation functions) 建立 CFP