https://github.com/aldas/rrd-php-reader
Read RRDtool files without rrd extension as ext-rrd does not support reading rrd files generated on different arch
https://github.com/aldas/rrd-php-reader
php rrd rrdtool
Last synced: 7 months ago
JSON representation
Read RRDtool files without rrd extension as ext-rrd does not support reading rrd files generated on different arch
- Host: GitHub
- URL: https://github.com/aldas/rrd-php-reader
- Owner: aldas
- License: mit
- Created: 2018-03-14T15:29:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-27T17:42:07.000Z (over 2 years ago)
- Last Synced: 2025-10-02T22:51:27.579Z (10 months ago)
- Topics: php, rrd, rrdtool
- Language: PHP
- Size: 37.1 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pure PHP RRDtool file reader
[](https://travis-ci.org/aldas/rrd-php-reader)
[](https://codecov.io/gh/aldas/rrd-php-reader)
> Because on windows php ext-rrd can not read rrd files created on unix and vice versa.
> See https://github.com/oetiker/rrdtool-1.x/issues/759
This library supports reading:
* rrds created on 64bit linux from 64bit Windows
* rrds created on 64bit Windows from 64bit Linux
**Only meant to export/dump data out of rrd file.**
This library is based on [javascriptRRD](http://javascriptrrd.sourceforge.net/)
## Example
Convert RRD to CSV: [rrd_to_csv.php](examples/rrd_to_csv.php)
```
$reader = RrdReader::createFromPath('path/to/my_rrd.rrd');
$fp = fopen('output.csv', 'wb');
$reader->outputAsCsv($fp, [
'ds' => 'value'
]);
fclose($fp);
```
Filter rrd: [read_rrd.php](examples/read_rrd.php)
```
$reader = RrdReader::createFromPath('path/to/my_rrd.rrd');
$traversable = $reader->getAll([
'ds' => 'value',
'row_filter_callback' => function (int $timestamp, float $value, RrdDs $ds, RraInfo $rra) {
return $value < 8;
}
]);
/** @var RrdRowValue $value */
foreach ($traversable as $value) {
echo $value . PHP_EOL;
}
```
Output would be:
```
timestamp=1521054891, value=6.000000, cf=AVERAGE, ds=value, step=1
timestamp=1521054892, value=7.000000, cf=AVERAGE, ds=value, step=1
timestamp=1521054891, value=6.000000, cf=MAX, ds=value, step=1
timestamp=1521054892, value=7.000000, cf=MAX, ds=value, step=1
```