略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: rrd_xport

2024-12-22

rrd_xport

(PECL rrd >= 0.9.0)

rrd_xportExports the information about RRD database

说明

rrd_xport(array $options): array

Exports the information about RRD database file. This data can be converted to XML file via user space PHP script and then restored back as RRD database file.

参数

options

Array of options for the export, see rrd xport man page.

返回值

Array with information about RRD database file, 或者在失败时返回 false.

add a noteadd a note

User Contributed Notes 1 note

up
3
mrezahamedany
4 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());
        }

    }
}

官方地址:https://www.php.net/manual/en/function.rrd-xport.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3