Rrdtool的安装:
Rrdtool-1.
Rrdtool-devel-1.
Rrdtool-perl-1.
收集数据的数据库:
Rrdtoll create test.rrd --step 5 --start -1DS:testds:GAUGE:8:0:U RRA:AVERGE:0.5:1:17280 RRA:AVERGE:.5:10:3456 RRA:AVERGE:.5:100:1210
create test.rrd:创建
--step 5:时间s
--start -1:什么时候开始s默认10
DS:testds:GAUGE:8:0:U:名字:类型:最大等待时间:最小数:最大数
RRA:AVERGE:0.5:1:17280 :平均:求百分几标未知:求几个平均:保存多少(5s一次一天可以收集86400个)
获取数据:
Rrdtool update
绘图:
Rrdtool graph/graphv filename
接下来以mysql 为例
收集数据的数据库:
Rrdtoll create mysql.rrd --step 3DS:myselect:COUNTER:5:0:U RRA:AVERGE:0.5:1:28800 RRA:MAX:0.5:10:2880 RRA:LAST:0.5:1:28800
收集数据的脚本:vim getselect.sh
#!/bin/bash
While true;do
SELECT=”Mysql –batch –e ‘SHOW GLOBAL STATUSLIKE ‘com_select’ | awk ‘/Com_select/[print $2]’”
Rrdtool update mysql.rrd N:$SELECT
Sleep 3
Done
向mysql发起查询数据:
建图:
Rrdtool graph mysql.pn –s 某个时点-t ‘mysqlselect’ –v ‘selects/3‘ DEF:select3=mysql.rrd:myselect:AVERAGE:step=3 DEF:MAX30=mysql.rrd:myselect:MAX:step=30LINE1:select3#FF0000:’SELECT’ GPRINT:MAX:”MAXIMUM\:%6.21f”