【发布时间】:2017-05-31 02:56:03
【问题描述】:
我一直在尝试通过反复试验和研究来让它发挥作用
rrdtool create attempt_db.rrd --start 1435125034 --step=10 DS:attempts:GAUGE:600:0:1000 RRA:AVERAGE:0.5:1:24
rrdtool update attempt_db.rrd <time unixtime>:<number>
rrdtool graph latency.png -a PNG -w 7850 -h 240 --slope-mode -u 2000
--vertical-label "attempts" DEF:attempts=attempt_db.rrd:attempts:MAX LINE1:attempts
数据样本:
rrdtool update attempt_db.rrd 1495170017.8874:1
rrdtool update attempt_db.rrd 1495170248.3469:1
rrdtool update attempt_db.rrd 1495170307.1935:2
rrdtool update attempt_db.rrd 1495170323.2595:1
rrdtool update attempt_db.rrd 1495170391.3133:1
rrdtool update attempt_db.rrd 1495170396.5190:1
rrdtool update attempt_db.rrd 1495170433.3954:1
rrdtool update attempt_db.rrd 1495170433.3983:1
rrdtool update attempt_db.rrd 1495170446.6604:1
rrdtool update attempt_db.rrd 1495170447.1263:1
rrdtool update attempt_db.rrd 1495170450.4443:1
rrdtool update attempt_db.rrd 1495170479.7533:1
必须将 1、2 等相加才能得到每小时费率。它们表示恰好在那个时间发生的事件数量。
我有一个 70 万条记录的 mysql 数据库。平均流量为每小时 35 次。 我希望将每小时的事件汇总为一个数据点并绘制图表。有时每秒有多个事件,因此必须总计。
我还希望能够将每个月绘制为图表上的单独线条和颜色。
尽管尝试了数百次,但我得到的只是一张空白图表。
更新:
rrdtool create attempt_db.rrd --step=60 --start 1435727683 DS:attempts:ABSOLUTE:600:0:1000 RRA:AVERAGE:0.5:1:1440 RRA:AVERAGE:0.5:60:2000
rrdtool graph latency.png -a PNG -w 7850 -h 240 --slope-mode -u 200 --vertical-label "attempts" DEF:attempts=attempt_db.rrd:attempts:MAX LINE1:attempts
插入数据:
mysql -u user -ppassword db -e "select concat(oob_time_sec,\":\",count(*)) from ulog2 where oob_time_sec between unix_timestamp(\"2015-07-01 00:00:00\") and unix_timestamp(\"2015-07-14 23:59:59\") group by oob_time_sec order by oob_time_sec " |xargs -n1 rrdtool update attempt_db.rrd
这里可以访问 2 周的数据。 https://drive.google.com/file/d/0ByhxkwJBdusDUnBMTFI4bFlFTFE/view?usp=sharing
【问题讨论】: