rrd_xport

(PECL rrd >= 0.9.0)

rrd_xport导出 RRD 数据库的相关信息

说明

rrd_xport(array $options): array

导出 RRD 数据库文件的相关信息。这些数据可以通过用户空间的 PHP 脚本转换为 XML 文件,然后再恢复为 RRD 数据库文件。

参数

options

导出的数组选项,可以通过 rrd xport 手册查看。

返回值

有关 RRD 数据库文件信息的数组, 或者在失败时返回 false

add a note add a note

User Contributed Notes 1 note

up
3
mrezahamedany
6 years ago
an example that shows the usage of this method ( tested in php version 5.6.30 )

class Rrd{
    public function getData($id , $start , $end)
    {
        $step = 300 ;
        $rrdFile ="/path/to/file/'.$id.rrd";

        try{
            $options = ["--start", $start , "--end", $end ,"-- step",$step,"DEF:out=$rrdFile:name:AVERAGE", "XPORT:out:test"];
            $result = rrd_xport($options);
            $datas = $result['data'][0]['data'];
            foreach($datas as $data => $value){

                if( is_nan($value) === true ) $value = 0 ;
                    $output[] = [$data=>$value] ;
            }
            return json_encode($output);

        }catch (Exception $e){

            dd($e->getMessage());
        }

    }
}
To Top