略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: OOP PECL/rrd example

2024-04-28

OOP PECL/rrd example

示例 #1 OO usage of rrd

<?php
$rrdFile 
dirname(__FILE__) . "/speed.rrd";
$outputPngFile dirname(__FILE__) . "/speed.png";

$creator = new RRDCreator($rrdFile"now -10d"500);
$creator->addDataSource("speed:COUNTER:600:U:U");
$creator->addArchive("AVERAGE:0.5:1:24");
$creator->addArchive("AVERAGE:0.5:6:10");
$creator->save();

$updater = new RRDUpdater($rrdFile);
$updater->update(array("speed" => "12345"), "920804700");
$updater->update(array("speed" => "12357"), "920805000");

$graphObj = new RRDGraph($outputPngFile);
$graphObj->setOptions(
    array(
        
"--start" => "920804400",
        
"--end" => 920808000,
        
"--vertical-label" => "m/s",
        
"DEF:myspeed=$rrdFile:speed:AVERAGE",
        
"CDEF:realspeed=myspeed,1000,*",
        
"LINE2:realspeed#FF0000"
    
)
);
$graphObj->save();
?>
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/rrd.examples-oop.php

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