从rrdtool图表中获取可解析的数据

发布于 2025-01-03 18:30:21 字数 998 浏览 4 评论 0原文

我想从 rrdtool 数据库中提取一些每小时数据,以便在仪表板系统中创建一些图表。

这些数据库没有每小时数据源,最接近的是 30 分钟数据源(它们由 munin 生成)

现在,我可以使用 rrdfetch,但这并不能很好地平均 < code>rrdgraph 就可以了,所以像这样的东西

rrdtool fetch xxx-apache_accesses-accesses80-d.rrd AVERAGE \
   --resolution 3600 -s 1328458200 -e 1328544600

可能会给我 30 分钟的数据点,这样

2012-Feb-05 16:30:00 3.5376357135e+00
2012-Feb-05 17:00:00 3.4655067194e+00
2012-Feb-05 17:30:00 4.0483210375e+00
2012-Feb-05 18:00:00 4.3210061422e+00
....

可以平均这些,但似乎 rrdgraph 可以输出可解析的文本,但我无法找出正确的咒语。这是我尝试过的

 rrdtool graph dummy.png -s 1328523300 -e 1328609700 \
     DEF:access=xxx-apache_accesses-accesses80-d.rrd:42:AVERAGE \
     "PRINT:access:AVERAGE: %5.1lf %S"

输出

0x0
   4.7

现在我认为这只是给定时间段的平均值,但是有没有办法让rrdtool吐出特定块或步长的平均值?我尝试了 --step 但这并没有改变输出。

我可以为我需要的每个数据点调用rrdtool graph,但这似乎相当浪费。

I want to extract some hourly data from rrdtool databases in order to create some graphs within a dashboard system.

These databases don't have an hourly datasource, the closest is a 30-min datasource (they are generated by munin)

Now, I can use rrdfetch, but that doesn't do the nice averaging that rrdgraph would do, so something like this

rrdtool fetch xxx-apache_accesses-accesses80-d.rrd AVERAGE \
   --resolution 3600 -s 1328458200 -e 1328544600

Might give me 30 min data points like this

2012-Feb-05 16:30:00 3.5376357135e+00
2012-Feb-05 17:00:00 3.4655067194e+00
2012-Feb-05 17:30:00 4.0483210375e+00
2012-Feb-05 18:00:00 4.3210061422e+00
....

I could average those, but it seems that rrdgraph can output parsable text, but I can't figure out the correct incantation. Here's what I've tried

 rrdtool graph dummy.png -s 1328523300 -e 1328609700 \
     DEF:access=xxx-apache_accesses-accesses80-d.rrd:42:AVERAGE \
     "PRINT:access:AVERAGE: %5.1lf %S"

outputs

0x0
   4.7

Now I think that's simply the average for the period given, but is there any way to get rrdtool to spit out an average for particular chunks or step sizes? I tried --step but this did not change the output.

I could call rrdtool graph for each data point I need, but that seems rather wasteful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞取 2025-01-10 18:30:21

我一发帖就找到了正确的方法!

rrdtool xport -s 1328523300 -e 1328609700 --step 3600 \
    DEF:access=xxx-apache_accesses-accesses80-d.rrd:42:AVERAGE \
    XPORT:access:"average"

这给了我需要的转储......

<?xml version="1.0" encoding="ISO-8859-1"?>

<xport>
  <meta>
    <start>1328526000</start>
    <step>3600</step>
    <end>1328612400</end>
    <rows>25</rows>
    <columns>1</columns>
    <legend>
      <entry>average</entry>
    </legend>
  </meta>
  <data>
    <row><t>1328526000</t><v>2.1949556516e+00</v></row>
    <row><t>1328529600</t><v>2.0074586816e+00</v></row>
    <row><t>1328533200</t><v>2.4574720485e+00</v></row>
    <row><t>1328536800</t><v>3.4861890250e+00</v></row>
    <row><t>1328540400</t><v>4.2725023347e+00</v></row>
    <row><t>1328544000</t><v>6.2119548259e+00</v></row>
    <row><t>1328547600</t><v>5.6709432075e+00</v></row>
    <row><t>1328551200</t><v>6.1214185470e+00</v></row>
    <row><t>1328554800</t><v>8.1137357347e+00</v></row>
    <row><t>1328558400</t><v>5.8345894022e+00</v></row>
    <row><t>1328562000</t><v>6.2264732776e+00</v></row>
    <row><t>1328565600</t><v>6.1652113350e+00</v></row>
    <row><t>1328569200</t><v>5.8851025574e+00</v></row>
    <row><t>1328572800</t><v>5.4612112119e+00</v></row>
    <row><t>1328576400</t><v>6.3908056120e+00</v></row>
    <row><t>1328580000</t><v>6.0361776174e+00</v></row>
    <row><t>1328583600</t><v>6.3164590113e+00</v></row>
    <row><t>1328587200</t><v>6.0902986521e+00</v></row>
    <row><t>1328590800</t><v>4.6756445168e+00</v></row>
    <row><t>1328594400</t><v>3.9461916905e+00</v></row>
    <row><t>1328598000</t><v>2.9449490046e+00</v></row>
    <row><t>1328601600</t><v>2.4011760751e+00</v></row>
    <row><t>1328605200</t><v>2.2187817639e+00</v></row>
    <row><t>1328608800</t><v>2.1775208736e+00</v></row>
    <row><t>1328612400</t><v>NaN</v></row>
  </data>
</xport>

No sooner had I posted than I hit upon the right approach!

rrdtool xport -s 1328523300 -e 1328609700 --step 3600 \
    DEF:access=xxx-apache_accesses-accesses80-d.rrd:42:AVERAGE \
    XPORT:access:"average"

This gives me the dump I need...

<?xml version="1.0" encoding="ISO-8859-1"?>

<xport>
  <meta>
    <start>1328526000</start>
    <step>3600</step>
    <end>1328612400</end>
    <rows>25</rows>
    <columns>1</columns>
    <legend>
      <entry>average</entry>
    </legend>
  </meta>
  <data>
    <row><t>1328526000</t><v>2.1949556516e+00</v></row>
    <row><t>1328529600</t><v>2.0074586816e+00</v></row>
    <row><t>1328533200</t><v>2.4574720485e+00</v></row>
    <row><t>1328536800</t><v>3.4861890250e+00</v></row>
    <row><t>1328540400</t><v>4.2725023347e+00</v></row>
    <row><t>1328544000</t><v>6.2119548259e+00</v></row>
    <row><t>1328547600</t><v>5.6709432075e+00</v></row>
    <row><t>1328551200</t><v>6.1214185470e+00</v></row>
    <row><t>1328554800</t><v>8.1137357347e+00</v></row>
    <row><t>1328558400</t><v>5.8345894022e+00</v></row>
    <row><t>1328562000</t><v>6.2264732776e+00</v></row>
    <row><t>1328565600</t><v>6.1652113350e+00</v></row>
    <row><t>1328569200</t><v>5.8851025574e+00</v></row>
    <row><t>1328572800</t><v>5.4612112119e+00</v></row>
    <row><t>1328576400</t><v>6.3908056120e+00</v></row>
    <row><t>1328580000</t><v>6.0361776174e+00</v></row>
    <row><t>1328583600</t><v>6.3164590113e+00</v></row>
    <row><t>1328587200</t><v>6.0902986521e+00</v></row>
    <row><t>1328590800</t><v>4.6756445168e+00</v></row>
    <row><t>1328594400</t><v>3.9461916905e+00</v></row>
    <row><t>1328598000</t><v>2.9449490046e+00</v></row>
    <row><t>1328601600</t><v>2.4011760751e+00</v></row>
    <row><t>1328605200</t><v>2.2187817639e+00</v></row>
    <row><t>1328608800</t><v>2.1775208736e+00</v></row>
    <row><t>1328612400</t><v>NaN</v></row>
  </data>
</xport>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文