©
This document uses PHP Chinese website manual Release
(PECL rrd >= 0.9.0)
rrd_fetch — Fetch the data for graph as array.
$filename
, array $options
)Gets data for graph output from RRD database file as array. This function has same result as rrd_graph() , but fetched data are returned as array, no image file is created.
filename
RRD database file name.
options
Array of options for resolution specification.
Returns information about retrieved graph data.
[#1] stephanecharette at gmail dot com [2013-09-06 05:50:57]
For example, this worked for me:
<?php
$result = rrd_fetch( "mydata.rrd", array( "AVERAGE", "--resolution", "60", "--start", "-1d", "--end", "start+1h" ) );
?>
This will fetch all fields. You then have to use something like this to get to a specified rrd field:
<?php
foreach ( $result["data"]["myfield"] as $key => $value )
{
echo "At timestamp $key, the value for myfield is $value.\n";
}
?>
[#2] ernestas at versme dot net [2013-08-21 12:56:12]
A few years ago, the extension was patched so that it would count options itself. But for me, it's buggy (it does not work with more than 3 arguments) and neither does work.