Python的系统管理_12_rrdtool
shell 創(chuàng)建rrd文件步驟:
rrdtool create interface2.rrd DS:packets:COUNTER:600:U:U RRA:AVERAGE:0.5:1:288 RRA:AVERAGE:0.5:6:336rrdtool 創(chuàng)建語法 (rrdtool create)
rrdtool create filename ? ? ? ? ? ? 創(chuàng)建
[--start|-b start time] ? ? ? ? ? ? ? ?1970 年至今的秒數(shù) (預(yù)設(shè)是現(xiàn)在)
[--step|-s step] ? ? ? ? ? ? ? ? ? ? ? ? ?時(shí)間間隔,我們會設(shè) 300 (秒),
[DS:ds-nameST] ? ? ? ? ? ? ? ? ? ? ? ?Data Source DS name
packets ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 是 DSN (name) , ? ?
COUNTER ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 是DST(type),習(xí)慣上常用98 100 98:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1.GAUGE(個(gè)別值,像CPU loading):產(chǎn)生圖檔時(shí),畫 98 100 98
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2.COUNTER (累計(jì)值,像流量資料):產(chǎn)生圖檔時(shí),畫,2 -2
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3.DERIVE (累計(jì)值,像流量資料),小於0畫0:產(chǎn)生圖檔時(shí),畫 ? ?2 ? 0
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 4.ABSOLUTE 同 COUNTER,但overflow(數(shù)值過大),所以會取絕對值
600 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?有效期,如在12:00需要產(chǎn)生的數(shù)據(jù)未產(chǎn)生,前后300秒(600)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?的平均值為12:00的值,如沒有標(biāo)記為:"UNKNOWN".
0:100000000 ? ? ? ? ? ? ? ? ? ? ? ? ? ? DSN 數(shù)有效範(fàn)圍,超出,皆視為 UN, U:U 代表不限範(fàn)圍
[RRA:CF] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Round Robin Archive,數(shù)據(jù)處理
AVERAGE ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CF (consolidation function),共有:AVERAGE, MIN,MAX, LAST 意 ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?即平均值,最大值,最小值,最後一筆.
0.5:1:603 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?11:57:30~12:02:30,若在此時(shí)間點(diǎn)內(nèi)只有一筆記錄的話,其 意即
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?是平均值, 603 是指要存 603 筆超過603筆,最早一筆將被移出.
0.5:6:603 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?6 筆記錄(每筆為 step 值)為平均值( 30 分鐘),存 603 筆
0.5:24:603 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?24 即二小時(shí)
0.5:288:800 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 288 即一天
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
對應(yīng)的python代碼:
數(shù)據(jù)更新shell:
rrdtool update interface.rrd 1391846135:10 rrdtool update interface.rrd 1391846435:15rrdtool update interface.rrd 1391846735:25 rrdtool update interface.rrd 1391847035:40 1391847335:60 1391847635:66 rrdtool update interface.rrd 1391847935:100 1391848135:160 1391848435:166python:
for i in range(20):rrdtool.update('interface2.rrd','%d:%d' %(1391847516+(1+i)*300, i*10+200))展現(xiàn)信息shell:
rrdtool fetch interface.rrd AVERAGE -r 1800 packetsrrdtool fetch interface.rrd AVERAGE packetspython:
for i in rrdtool.fetch('interface.rrd','AVERAGE'): print i繪圖shell :
graph packets.png --start 1391846100 --end 1391848500 --step 300 DEF:packetrate=interface.rrd:packet:AVERAGE LINE2:packetrate#c0c0c0python :
轉(zhuǎn)載于:https://blog.51cto.com/53254/1357357
總結(jié)
以上是生活随笔為你收集整理的Python的系统管理_12_rrdtool的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: css高级教程第一章笔记
- 下一篇: cocos2dx 坐标系统详解