<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage update * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ echo 'Converting FDB count RRD ds fdb->value: '; include_once 'includes/rrdtool.inc.php'; global $rrd_pipes; rrdtool_pipe_open($rrd_process, $rrd_pipes); foreach (dbFetchRows("SELECT hostname FROM `device_graphs`,`devices` WHERE `devices`.device_id=`device_graphs`.device_id AND graph='fdb_count';") as $entry) { $rrd = $config['rrd_dir'] . '/' . $entry['hostname'] . '/fdb_count.rrd'; rrdtool('tune', $rrd, '--data-source-rename fdb:value'); echo '.'; } rrdtool_pipe_close($rrd_process, $rrd_pipes); // EOF
function rrdtool_lastupdate($filename, $options) { return rrdtool('lastupdate', $filename, $options); }
function rrdtool_tune($type, $filename, $max) { $fields = array(); if ($type === 'port') { if ($max < 10000000) { return false; } $max = $max / 8; $fields = array('INOCTETS', 'OUTOCTETS', 'INERRORS', 'OUTERRORS', 'INUCASTPKTS', 'OUTUCASTPKTS', 'INNUCASTPKTS', 'OUTNUCASTPKTS', 'INDISCARDS', 'OUTDISCARDS', 'INUNKNOWNPROTOS', 'INBROADCASTPKTS', 'OUTBROADCASTPKTS', 'INMULTICASTPKTS', 'OUTMULTICASTPKTS'); } if (count($fields) > 0) { $options = "--maximum " . implode(":{$max} --maximum ", $fields) . ":{$max}"; rrdtool('tune', $filename, $options); } }
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage update * @copyright (C) 2006-2014 Adam Armstrong * */ include_once 'includes/rrdtool.inc.php'; global $rrd_pipes; $netstat_tcp_array = dbFetchRows("SELECT `hostname` FROM `device_graphs`,`devices` WHERE `devices`.`device_id` = `device_graphs`.`device_id` AND `graph` LIKE 'netstat_tcp%';"); if (count($netstat_tcp_array)) { echo ' Converting RRD ds type for tcpCurrEstab COUNTER->GAUGE: '; rrdtool_pipe_open($rrd_process, $rrd_pipes); foreach ($netstat_tcp_array as $entry) { $rrd = $config['rrd_dir'] . '/' . $entry['hostname'] . '/netstats-tcp.rrd'; rrdtool('tune', $rrd, '--data-source-type tcpCurrEstab:GAUGE'); echo '.'; } rrdtool_pipe_close($rrd_process, $rrd_pipes); } echo PHP_EOL; // EOF
/** * 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); }
function rrdtool_lastupdate($rrdfile, $rrdupdate) { return rrdtool("lastupdate", $rrdfile, $rrdupdate); }