Esempio n. 1
0
/**
 * rrdtool backend implementation of data_update
 *
 * Tags:
 *   rrd_def     array|string: (required) an array of rrd field definitions example: "DS:dataName:COUNTER:600:U:100000000000"
 *   rrd_name    array|string: the rrd filename, will be processed with rrd_name()
 *   rrd_oldname array|string: old rrd filename to rename, will be processed with rrd_name()
 *   rrd_step             int: rrd step, defaults to 300
 *
 * @param array $device device array
 * @param string $measurement the name of this measurement (if no rrd_name tag is given, this will be used to name the file)
 * @param array $tags tags to pass additional info to rrdtool
 * @param array $fields data values to update
 */
function rrdtool_data_update($device, $measurement, $tags, $fields)
{
    global $config;
    $rrd_name = $tags['rrd_name'] ?: $measurement;
    $step = $tags['rrd_step'] ?: 300;
    $oldname = $tags['rrd_oldname'];
    if (!empty($oldname)) {
        rrd_file_rename($device, $oldname, $rrd_name);
    }
    if (isset($tags['rrd_proxmox_name'])) {
        $pmxvars = $tags['rrd_proxmox_name'];
        $rrd = proxmox_rrd_name($pmxvars['pmxcluster'], $pmxvars['vmid'], $pmxvars['vmport']);
    } else {
        $rrd = rrd_name($device['hostname'], $rrd_name);
    }
    if ($tags['rrd_def'] && !rrdtool_check_rrd_exists($rrd)) {
        $rrd_def = is_array($tags['rrd_def']) ? $tags['rrd_def'] : array($tags['rrd_def']);
        // add the --step and the rra definitions to the command
        $newdef = "--step {$step} " . implode(' ', $rrd_def) . $config['rrd_rra'];
        rrdtool('create', $rrd, $newdef);
    }
    rrdtool_update($rrd, $fields);
}
Esempio n. 2
0
<?php

/*
 * Copyright (C) 2015 Mark Schouten <*****@*****.**>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2 dated June,
 * 1991.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * See http://www.gnu.org/licenses/gpl.txt for the full license
 */
require 'includes/graphs/common.inc.php';
$proxmox_rrd = proxmox_rrd_name($vars['cluster'], $vars['vmid'], $vars['port']);
if (rrdtool_check_rrd_exists($proxmox_rrd)) {
    $rrd_filename = $proxmox_rrd;
}
$ds_in = 'INOCTETS';
$ds_out = 'OUTOCTETS';
require 'includes/graphs/generic_data.inc.php';