downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

rrd_last> <rrd_graph
[edit] Last updated: Fri, 17 May 2013

view this page in

rrd_info

(PECL rrd >= 0.9.0)

rrd_infoObtiene información sobre el archivo rrd

Descripción

array rrd_info ( string $filename )

Devuelve información acerca sobre determinado archivo de base de datos RRD.

Parámetros

file

Nombre del archivo de base de datos RRD.

Valores devueltos

Array con información sobre el archivo RRD solicitado, FALSE cuando ocurra un error.



add a note add a note User Contributed Notes rrd_info - [1 notes]
up
0
cfsalguero at gmail dot com
1 year ago
rrd_info will return an array where the keys are all strings that represents another arrays like in this example:
Array
(
    [filename] => /var/www/cacti/rra/localhost_mem_swap_26.rrd
    [rrd_version] => 0003
    [step] => 300
    [last_update] => 1329924661
    [header_size] => 1892
    [ds[mem_swap].index] => 0
    [ds[mem_swap].type] => GAUGE
    [ds[mem_swap].minimal_heartbeat] => 600
    [ds[mem_swap].min] => 0
    [ds[mem_swap].max] => NAN
    [ds[mem_swap].last_ds] => 2084332
    [ds[mem_swap].value] => 127144252
    [ds[mem_swap].unknown_sec] => 0
    [rra[0].cf] => AVERAGE
    [rra[0].rows] => 600
    [rra[0].cur_row] => 266
    [rra[0].pdp_per_row] => 1
    [rra[0].xff] => 0.5
    [rra[0].cdp_prep[0].value] => NAN
    [rra[0].cdp_prep[0].unknown_datapoints] => 0
)
I made a function that converts that into a real array structure:
<?php

function rrdinfo($filename) {

   
/*
       Inner functions to make them inaccesible from the outside of the main function
    */
   
function add($key, $value, &$main_table) {
        if (
is_array($value)) {
            foreach (
$value as $k => $v) {
               
add($k, $v, $main_table[$key]);
            }
        } else {
           
$main_table[$key] = $value;
        }
    }

    function
toobj($key, $value) {
       
$matches = array();
        if (
preg_match('/^\\[(.*)\\]$/', $key, $matches)) {
           
$key = $matches[1];
        }
        if (
preg_match('/(.*?)\\[(.*?)\\]\\.(.*)/', $key, $matches)) {
           
$matches2 = array();
            if (
preg_match('/(.*?)\\[(.*?)\\]\\.(.*)/', $matches[3], $matches2)) {
               
$ret_key = $matches[1];                                
                list(
$k, $v) = toobj($matches[3], $value);
               
$ret_val = array($matches[2] => array($k => $v));
            } else {
               
$ret_key = $matches[1];                                
               
$ret_val = array($matches[2] => array ($matches[3] => $value));
            }
        } else {
           
$ret_key = $key;
           
$ret_val = $value;
        }
        return array(
$ret_key, $ret_val);
    }

   
/*
       Main program code
    */
   
$main_table = array();
   
$info = rrd_info($filename);
    foreach (
$info as $ds_key => $ds_value) {
        list (
$key, $value) = toobj($ds_key, $ds_value);
        
add($key, $value, $main_table);
    }
    return
$main_table;
}
?>

And this is the way to use it:

<?php
$filename
= "/path/to/your/rrd/file/localhost_mem_swap_26.rrd";
$info = rrdinfo($filename);
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites