cacti、rrd 相關(guān)
cacti是一款網(wǎng)絡(luò)流量監(jiān)控系統(tǒng),非常好用,誰用誰知道!下面講下cacti、rrd 相關(guān)
cacti數(shù)據(jù)庫
1.結(jié)構(gòu)
host 主機(jī)表
data_local 數(shù)據(jù)表
data_template 數(shù)據(jù)模板表
data_template_data 數(shù)據(jù)信息表
2.關(guān)系
`host`.`id` 與 `data_local`.`host_id`關(guān)聯(lián)
`data_local`、`data_tempate_data`.data_template_id 與 `data_template`.id關(guān)聯(lián)
`data_template_data`.local_data_id 和 `data_local`.id 關(guān)聯(lián)
3.作用
基于上述信息可以查到任意一個(gè)給定主機(jī)的所有RRA文件信息
4.范例
select dl.id, dl.data_template_id, dt.name, dl.host_id, host.hostname, dl.snmp_query_id, dl.snmp_index,dtd.data_template_id, dtd.data_input_id, dtd.data_source_path, dtd.name_cache from data_local as dl,host,data_template as dt,data_template_data as dtd where dl.host_id= {$host_id} and dl.host_id=host.id and dt.id=dl.data_template_id and dl.id=dtd.local_data_id;
#p#
rrd 文件格式
1.文件頭
包含一些版本信息和一些于數(shù)據(jù)存儲(chǔ)區(qū)相關(guān)的一些信息。例如:RRD的版本號(hào),DS數(shù)量,DS名稱,DS類型,RRA數(shù)量,RRA類型,PDP數(shù)據(jù)區(qū),CDP數(shù)據(jù)區(qū),最后更新時(shí)間,RRA目前更新到的位置等等信息
2.數(shù)據(jù)區(qū)
該區(qū)域存儲(chǔ)了實(shí)際的數(shù)據(jù)。數(shù)據(jù)的來源是根據(jù)在創(chuàng)建RRD文件時(shí)DS的類型及相關(guān)RRA定義,并通過相關(guān)的計(jì)算得出的(CF,DST)。注意:數(shù)據(jù)源(DS)是存儲(chǔ)的實(shí)體,而RRA是數(shù)據(jù)存儲(chǔ)的載體。在邏輯上,每個(gè)RRA都有所有DS的數(shù)據(jù)(計(jì)算)
3.特點(diǎn)
環(huán)狀數(shù)據(jù)庫,可記錄條數(shù)在創(chuàng)建的時(shí)候就確定,可存儲(chǔ)空間滿了以后舊數(shù)據(jù)覆蓋新數(shù)據(jù),可以實(shí)現(xiàn)簡(jiǎn)單的計(jì)算功能,自定義功能比較豐富,適合對(duì)時(shí)效性要求不高的數(shù)值型存儲(chǔ)。
rrdtool 命令
1.info:查看文件結(jié)構(gòu)
2.lastupdate:最后更新時(shí)間及值
3.last:最后更新值
4.dunp:查看文件內(nèi)容
5.fetch:查看數(shù)據(jù)
rrdtool fetch
CF值通過dump內(nèi)數(shù)據(jù)查看
-s 起始時(shí)間,可以是時(shí)間戳也可以是時(shí)間戳?xí)r差 -1h, -1d 等。默認(rèn)是 -1d
-e 結(jié)束時(shí)間,同上。默認(rèn)是 now
-r 時(shí)間間隔
獲取CF為AVERAGE,時(shí)間間隔為1800秒,過去1小時(shí)到過去10分鐘內(nèi)的數(shù)據(jù)
rrdtool fetch test.rrd AVERAGE -r 1800 -s -1h -e -10m
通過文章的介紹,我們知道了cacti、rrd 相關(guān)有哪些,希望本文對(duì)你們有用!
【編輯推薦】