Vish
Vish

Reputation: 111

How to get max in and max out values from rrd files in single rrd command

We have MRTG set up to monitor the network .So for that we are using RRD tool to fetch an plotting the graph data. Now i have created a script which actually fetch data from RRD files , so from fetched data i need max in and and max out in 24 Hours. Now with these max values , i calculate the badwidth utilization for each customer/link.

Now my question is there, single rrd command to fetch max in , max out, min in and min out values from RRD files.

Since i am newbee to this RRD so i would appreciate if command is also provided with your solution.

Please help.

Upvotes: 0

Views: 2260

Answers (1)

Steve Shipway
Steve Shipway

Reputation: 4072

With an MRTG-created RRD files, the 'in' and 'out' datasources are named 'ds0' and 'ds1' respectively. There exist 8 RRAs; these correspond to granularities of 5min, 30min, 2hr and 1day with both AVG and MAX rollups. By default, these will be of length 400 (older versions of MRTG) or length 800 (newer versions of MRTG) which means that you are likely to have a time window of 2 days, 2 weeks, 2 months and 2 years respectively for these RRAs. (Note that RRDTool 1.5 may omit the 1pdp MAX RRA as this is functionally identical the the 1pdp AVG RRA)

What this means for you is the following:

  • You do not have a MIN type RRA. If working over the most recent 2 days, then this can be calculated from the highest-granularity AVG RRA. Otherwise, your data will be increasingly inaccurate.
  • Your lowest-granularity RRA holds MAX values on a per-day basis. However these days are split at midnight UCT rather than midnight local time. You do not specify which 24hr windows you need to calculate for.

IF you are only interested in claculating for the most recent 24h period, then all calculations can use the highest-granularity RRA.

Note that, because step boundaries are all calculated using UCT, unless you live in that timezone you can't use FETCH or XPORT to obtain the data you need as you need to summarise over a general time window.

To retrieve the data you can use something like this:

rrdtool graph /dev/null -e 00:00 -s "end-1day" --step 300 
  DEF:inrmax=target.rrd:ds0:AVERAGE:step=300:reduce=MAXIMUM 
  DEF:outrmax=target.rrd:ds1:AVERAGE:step=300:reduce=MAXIMUM 
  DEF:inrmin=target.rrd:ds0:AVERAGE:step=300:reduce=MINIMUM 
  DEF:outrmin=target.rrd:ds1:AVERAGE:step=300:reduce=MINIMUM
  VDEF:inmax=inrmax,MAXIMUM 
  VDEF:inmin=inrmin,MINIMUM
  VDEF:outmax=outrmax,MAXIMUM 
  VDEF:outmin=outrmin,MINIMUM 
  LINE:inrmax 
  PRINT:inmax:"In Max=%lf"
  PRINT:inmin:"In Min=%lf"
  PRINT:outmax:"Out Max=%lf"
  PRINT:outmin:"Out Min=%lf"

A few notes on this:

  • We are using 'graph' so that we can use a generic time window, not dependent on a step boundary
  • Use rrdgraph in order to use a generic time window; fetch and xport will work on step boundaries.
  • We are summarising the highest-granularity RRA on the fly
  • We use /dev/null as we dont actually want the graph image
  • We have to define a dummy line in the graph else we get nothing
  • The DEF lines specify the highest-granularity step and a reduction CF. You might be able to skip this part if you're using 5min step
  • We calculate the summary values using VDEF and then print them on stdout using PRINT
  • The first line of the output will be the graph size; you can discard this

When you call rrdtool::graph from your php script, simply pass it the parameters in the same way as you would for commandline operation. If you're not using Linux you might need to use something other than /dev/null.

Upvotes: 0

Related Questions