MRTG Implementation Manual
Table of Contents

 

7. Exporting the database records into plain text / XML format
 

The database records can be accessed by the “rrdtool” executable, which is able to export them in an XML/ASCII file for further processing. 

The export functions are: 

1. DUMP function 

rrdtool dump filename.rrd > filename.xml

This function exports the whole database in XML format. For a large database, the XML result will be a very large file. 

A dump excerpt looks as follows: 

<!-- 2002-10-05 03:10:00 Eastern Daylight Time / 1033801800 --> <row><v> 1.3837724444e+003 </v><v> 2.3811982222e+002 </v></row> 
<!-- 2002-10-05 03:15:00 Eastern Daylight Time / 1033802100 --> <row><v> 1.4081976000e+003 </v><v> 2.6190866667e+002 </v></row> 
<!-- 2002-10-05 03:20:00 Eastern Daylight Time / 1033802400 --> <row><v> 1.3597713301e+003 </v><v> 2.5264724650e+002 </v></row> 
<!-- 2002-10-05 03:25:00 Eastern Daylight Time / 1033802700 --> <row><v> 1.4397478255e+003 </v><v> 2.4997519794e+002 </v></row> 
<!-- 2002-10-05 03:30:00 Eastern Daylight Time / 1033803000 --> <row><v> 1.3969684222e+003 </v><v> 2.4970408889e+002 </v></row> 
<!-- 2002-10-05 03:35:00 Eastern Daylight Time / 1033803300 --> <row><v> 1.4300162899e+003 </v><v> 2.4545897350e+002 </v></row> 
<!-- 2002-10-05 03:40:00 Eastern Daylight Time / 1033803600 --> <row><v> 1.4308223434e+003 </v><v> 2.6211339317e+002 </v></row> 

2. XPORT function 

rrdtool xport              [-s|--start seconds]      [-e|--end seconds]     [-m|--maxrows rows]     --step value 
                                   [DEF:vname=rrd:ds-name: CF] 
                                   [CDEF:vname=rpn-expression] 
                                   [XPORT:vname[:legend]]
 

Where: 
  


  

--start = start time in EpochTime 

--end = end time in EpochTime 

-m = max number of rows to be listed 

--step = SNMP reading frequency in seconds 

DEF:vname = a virtual name (user defined) for a data which corresponds to DS within an RRD and a CF function. Multiple DEFs can be defined here. 

VDEF:vname = a new virtual variable which can be actually the exported value. It can be a calculation between multiple DEF:vname variables. The calculations are expressed in RPN-expresions. RPN-expression  example: a,b,+,8,/ is (a+b)/8 

XPORT: vname = is the name of the virtual variable that will be exported. It could be a DEF or a CDEF variable.

Note: This function performs a selective export for a specific period of time and with a specific frequency. Note that the start and end time values are expressed in Epoch Time values (the time in seconds since 1/1/1970). You need to converse the current time in EpochTime.

Sample: 

rrdtool xport          --start 1034259600     --end 1034260300     –step 300
                            DEF:my_bandwidth=10.0.0.1_po1.rrd:ds0:AVERAGE
                            CDEF:my_bit_bandwidth= my_bandwidth,8,* 
                            XPORT:my_new_bandwidth

An export looks as follows: 
 
  


  

<xport> 
  <meta> 
    <start>1034259600</start> 
    <step>300</step> 
    <end>1034260500</end> 
    <rows>4</rows> 
    <columns>1</columns> 
    <legend> 
      <entry></entry> 
    </legend> 
  </meta> 
  <data> 
    <row><t>1034259600</t><v>1.8206442886e+005</v></row> 
    <row><t>1034259900</t><v>3.0814951893e+005</v></row> 
    <row><t>1034260200</t><v>2.0108738560e+005</v></row> 
    <row><t>1034260500</t><v>3.6460060800e+004</v></row> 
  </data> 
</xport>
Note: For more details on all XPORT options go to http://www.rrdtool.com/
 
 

<Next Chapter>