blar/rrd

dev-master 2016-03-28 02:38 UTC

This package is auto-updated.

Last update: 2024-10-29 05:04:42 UTC


README

License Latest Stable Version Build Status Coverage Status Dependency Status Flattr

blar/rrd

Define a new RRD file

$timestamp = new DateTimeImmutable('2016-01-01 13:37:42');

$creator = new RRDCreator();
$creator->setFileName($rrd->getFileName());
$creator->setStart($timestamp);
$creator->setStep(60);

Add data source for downstream

$dataSource = new RrdDataSource();
$dataSource->setName('downstream');
$dataSource->setType(RrdDataSource::TYPE_COUNTER);
$creator->addDataSource($dataSource);

Add data source for upstream

$dataSource = new RrdDataSource();
$dataSource->setName('upstream');
$dataSource->setType(RrdDataSource::TYPE_COUNTER);
$creator->addDataSource($dataSource);

Add archive

$archive = new RrdArchive();
$archive->setConsolidation(RrdArchive::CONSOLIDATION_AVERAGE);
$archive->setSteps(60);
$archive->setRows(60 * 24);
$creator->addArchive($archive);

Save the new RRD file

$creator->save();

Push data

$rrd->update([
    'downstream' => 1024,
    'upstream' => 768
]);

Get last update

$rrd->getLastUpdate();