简体   繁体   中英

Munin output in json rather than in graphs

I want to use munin to collect system stats and save it in database. But I could not find any way to get the raw stats munin collects. Is there any way to get that raw data munin collects and with which it creates graph ?

另一种可能性是使用rrdtool命令访问历史数据,例如使用类似rrdtool fetch /var/munin/{domain}/{something}.rrd AVERAGE (这是FreeBSD系统上数据文件的路径,在Linux上它可能是/ var / lib / munin左右)。

You can export munin (or rather the underlying rrdtool) data in xml format using

rrdtool xport \
      --start now-1h --end now \
      DEF:xx=host-inout.lo.rrd:output:AVERAGE \
      DEF:yy=host-inout.lo.rrd:input:AVERAGE \
      CDEF:aa=xx,yy,+,8,* \
      XPORT:xx:"out bytes" \
      XPORT:aa:"in and out bits"

The resulting meta data section is (the values will depend on the RRD characteristics):

<meta>
<start>1020611700</start>
<step>300</step>
<end>1020615600</end>
<rows>14</rows>
<columns>2</columns>
<legend>
  <entry>out bytes</entry>
  <entry>in and out bits</entry>
</legend>

The resulting data section is:

<data>
<row><t>1020611700</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020612000</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020612300</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020612600</t><v>3.4113333333e+00</v><v>5.4581333333e+01</v></row>
<row><t>1020612900</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020613200</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020613500</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020613800</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020614100</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020614400</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020614700</t><v>3.7333333333e+00</v><v>5.9733333333e+01</v></row>
<row><t>1020615000</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020615300</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020615600</t><v>NaN</v><v>NaN</v></row>

I use the xml export to generate charts using JavaScript for my home temperature monitoring at http://pi.tafkas.net/temperatures/

Munin relies on its plugins to gather the stats. Although the plugins can be written in just about any language, the majority are scripts of some sort (shell, Perl, Python, etc.). Take a look at each plugin (that you want to use) to see how the data is gathered. You should be able to write your own, and cron it (just as munin does) so that it grabs a metric every 5 minutes (or however long you want).

You'll probably need to write additional scripts to aggregate data as you graph some of the larger data sets (eg, graphing an entire year's data). That and/or scripts to get rid of data after a certain time period.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM