blar / rrd
RRD for PHP
dev-master
2016-03-28 02:38 UTC
Requires
- php: ^7.0
- ext-rrd: *
Requires (Dev)
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2024-10-29 05:04:42 UTC
README
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();