Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Latest commit

 

History

History
91 lines (56 loc) · 1.54 KB

README.md

File metadata and controls

91 lines (56 loc) · 1.54 KB

Deprecated

This repository is no longer being actively maintained. We encourage you to not use this code. If you rely on this code you might want to fork the repository to keep your systems from breaking, if we remove this repository in the future.

RRD

The Leaseweb\RRD package provides functionality to work with [RRD](http://oss.oetiker.ch/rrdtool/ rrdtool) files. At the moment, It provides a Fetcher class to access data from rrd files in a easier way.

Requirements

  • PHP 5.3+
  • php-rrdtool extension

Installation

In order to work with the library, you need to have the PHP extension enabled. In Ubuntu you can type:

    sudo apt-get install php5-rrd

Using composer

Add Leaseweb\RRD in your composer.json:

{
    "require": {
        "leaseweb/rrd": "*",
        ...
    }
}

Usage

Fluent API

<?php

require 'vendor/autoload.php';

$rrdFetcher = new \RRD\Fetcher("database.rrd");
$data = $rrdFetcher->end('now')
                   ->start('end-1h')
                   ->fetch(\RRD\Fetcher::CF_AVERAGE)

From arguments

<?php

require 'vendor/autoload.php';

$rrdFetcher = new \RRD\Fetcher("database.rrd");
$data = $rrdFetcher->fetchFromArgs('AVERAGE', 300, '-1d', 'start+4h');

Percentile calculation

<?php

require 'vendor/autoload.php';

$rrdFetcher = new \RRD\Fetcher("database.rrd");
$data = $rrdFetcher->end('now')
                   ->start('end-1h')
                   ->percentile('network_in', 95)

Tests

    phpunit