array(4) { ["start"]=> int(1341834300) ["end"]=> int(1341834600) ["step"]=> int(300) ["data"]=> array(2) { ["ds0"]=> array(1) { [1341834600]=> float(29875732.323333) } ["ds1"]=> array(1) { [1341834600]=> float(139478395.26667) } } }
array(6) { ["start"]=> int(1341834300) ["end"]=> int(1341834600) ["step"]=> int(300) ["ds_cnt"]=> int(2) ["ds_namv"]=> array(2) { [0]=> string(3) "ds0" [1]=> string(3) "ds1" } ["data"]=> array(2) { [0]=> float(1073.00666667) [1]=> float(32.9566666667) } }
[2011-03-02 04:26 UTC] koubel at seznam dot cz thank you, rrd_fetch rewritten, there were a bug in filling the returned array. Nowadays all data sources are supported (trunk code). I made a litte bit BC break, no more ds_cnt, ds_namv keys in result array from fetch. I think these are completely useless.
http://pecl.php.net/package-changelog.php?package=rrd&release=1.1.0
0.10.0 | - fixed all reported bugs - fixed major bug in rrd_fetch #21402 - BC break : rdd_fetch returned array format changed, these items doesn't exist anymore - "ds_cnt", "ds_namv" |
#旧版本的rrd_fetch返回格式与新版本不同,过渡阶段需要用下面的函数将新版本rrd_fetch的返回值,改成旧版本的格式,才能兼容旧版本代码 function my_rrd_fetch($file_path, $opts , $count = 0) { $ret = rrd_fetch($file_path, $opts); if(!$ret) return false; $start = $ret['start']; $end = $ret['end']; $step = $ret['step']; $ds_cnt = 0; $ds_namv = array(); $data = array(); $tmpdata = array(); foreach($ret['data'] as $key => $values) { $ds_namv[] = $key; $ds_cnt++; foreach($values as $time => $value) { $tmpdata[] = $value; } } $count = count($tmpdata); for($i = 0; $i < ($count/2); $i++){ $data[] = $tmpdata[$i]; $data[] = $tmpdata[$i + ($count/2)]; } return array('start' => $start, 'end' => $end, 'step' => $step, 'ds_cnt' => $ds_cnt, 'ds_namv' => $ds_namv, 'data' => $data); }