RRDtool

目录

简介

Class for creation of RRD database file.

类摘要

RRDCreator

class RRDCreator {

/* 方法 */

public void addArchive ( string $description )

public void addDataSource ( string $description )

public __construct ( string $path [, string $startTime [, int $step = 0 ]] )

public bool save ( void )

}

RRDCreator::addArchive

Adds RRA - archive of data values for each data source

说明

public void RRDCreator::addArchive ( string $description )

Adds RRA definition by description of archive. Archive consists of a number of data values or statistics for each of the defined data-sources (DS). Data sources are defined by method RRDCreator::addDataSource. You need call this method for each requested archive.

参数

description
Definition of archive - RRA. This has same format as RRA definition in rrd create command. See man page of rrd create for more details.

返回值

没有返回值。

RRDCreator::addDataSource

Adds data source definition for RRD database

说明

public void RRDCreator::addDataSource ( string $description )

RRD can accept input from several data sources (DS), e.g incoming and outgoing traffic. This method adds data source by description. You need call this method for each data source.

参数

description
Definition of data source - DS. This has same format as DS definition in rrd create command. See man page of rrd create for more details.

返回值

没有返回值。

RRDCreator::__construct

Creates new RRDCreator instance

说明

public RRDCreator::__construct ( string $path [, string $startTime [, int $step = 0 ]] )

Creates new RRDCreator instance.

参数

path
Path for newly created RRD database file.

startTime
Time for the first value in RRD database. Parameter supports all formats which are supported by rrd create call.

intstep
Base interval in seconds with which data will be fed into the RRD database.

返回值

没有返回值。

RRDCreator::save

Saves the RRD database to a file

说明

public bool RRDCreator::save ( void )

Saves the RRD database into file, which name is defined by RRDCreator::__construct.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

简介

Class for exporting data from RRD database to image file.

类摘要

RRDGraph

class RRDGraph {

/* 方法 */

public __construct ( string $path )

public array save ( void )

public array saveVerbose ( void )

public void setOptions ( array $options )

}

RRDGraph::__construct

Creates new RRDGraph instance

说明

public RRDGraph::__construct ( string $path )

Creates new RRDGraph instance. This instance is responsible for rendering the result of RRD database query into image.

参数

path
Full path for the newly created image.

返回值

没有返回值。

RRDGraph::save

Saves the result of query into image

说明

public array RRDGraph::save ( void )

Saves the result of RRD database query into image defined by RRDGraph::__construct.

参数

此函数没有参数。

返回值

Array with information about generated image is returned, FALSE if error occurs.

RRDGraph::saveVerbose

Saves the RRD database query into image and returns the verbose information about generated graph

说明

public array RRDGraph::saveVerbose ( void )

Saves the RRD database query into image file defined by method RRDGraph::__construct and returns the verbose information about generated graph, if "-" is used as image filename, image data are also returned in result array.

参数

此函数没有参数。

返回值

Array with detailed information about generated image is returned, optionally with image data, FALSE if error occurs.

RRDGraph::setOptions

Sets the options for rrd graph export

说明

public void RRDGraph::setOptions ( array $options )

参数

options
List of options for the image generation from the RRD database file. It can be list of strings or list of strings with keys for better readability. Read the rrd graph man pages for list of available options.

返回值

没有返回值。

范例

示例 #1 RRDGraph::setOptions example

<?php
$graphObj->setOptions(array(
    "--start" => "920804400",
    "--end" => 920808000,
    "--vertical-label" => "m/s",
    "DEF:myspeed=$rrdFile:speed:AVERAGE",
    "CDEF:realspeed=myspeed,1000,*",
    "LINE2:realspeed#FF0000"
));
?>

示例 #2 Set multiple color options

<?php
$graphObj->setOptions(array(
    "--start" => "920804400",
    "--end" => 920808000,
    "--vertical-label" => "m/s",
    "--color=BACK#00000000",
    "--color=GRID#00000000",
    "--color=MGRID#00000000",
    "DEF:myspeed=$rrdFile:speed:AVERAGE",
    "CDEF:realspeed=myspeed,1000,*",
    "LINE2:realspeed#FF0000"
));
?>

Don't use key value syntax for same rrd option. It looks more readable, but it doesn't work.

<?php
$graphObj->setOptions(array(
    "--color" => "BACK#00000000",
    "--color" => "GRID#00000000",
    "--color" => "MGRID#00000000"
));
?>

In nature of php it's same as

<?php
$graphObj->setOptions(array(
    "--color" => "MGRID#00000000"
));
?>

简介

Class for updating RDD database file.

类摘要

RRDUpdater

class RRDUpdater {

/* 方法 */

public __construct ( string $path )

public bool update ( array $values [, string $time = time() ] )

}

RRDUpdater::__construct

Creates new RRDUpdater instance

说明

public RRDUpdater::__construct ( string $path )

Creates new RRDUpdater instance. This instance is responsible for updating the RRD database file.

参数

path
Filesystem path for RRD database file, which will be updated.

返回值

没有返回值。

RRDUpdater::update

Update the RRD database file

说明

public bool RRDUpdater::update ( array $values [, string $time = time() ] )

Updates the RRD file defined via RRDUpdater::__construct. The file is updated with a specific values.

参数

values
Data for update. Key is data source name.

time
Time value for updating the RRD with a particulat data. Default value is current time.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

错误/异常

Throws a Exception on error.

范例

示例 #1 RRDUpdater::update examples

<?php
$updator = new RRDUpdater("speed.rrd");
//updates the data source "speed" with value "12411"
//for time defined by timestamp "920807700"
$updator->update(array("speed" => "12411"), "920807700");
?>