rrdtune code

This commit is contained in:
laf
2015-11-17 02:20:23 -08:00
parent a6f34fdf7e
commit 84863586b5
4 changed files with 50 additions and 11 deletions

View File

@@ -166,7 +166,7 @@ function rrdtool_graph($graph_file, $options) {
function rrdtool($command, $filename, $options) {
global $config, $debug, $rrd_pipes, $console_color;
if ($config['rrdcached'] && ($config['rrdtool_version'] >= 1.5 || $command != "create")) {
if ($config['rrdcached'] && ($config['rrdtool_version'] >= 1.5 || ($command != "create" && $command != 'tune'))) {
if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) {
$filename = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $filename);
$filename = str_replace($config['rrd_dir'], './'.$config['rrdcached_dir'].'/', $filename);
@@ -294,3 +294,17 @@ function rrdtool_escape($string, $maxlength=null){
return $result.' ';
}
function rrdtool_tune($type, $filename, $max) {
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'
);
$options = "--maxium " . implode(":$max --maximum ", $fields). ":$max";
rrdtool('tune', $filename, $options);
}
}