fix discovery to remove include_dir function. ignore -32768 values returned for sensors. build rrd graphs via pipe.

git-svn-id: http://www.observium.org/svn/observer/trunk@2493 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-09-18 15:38:05 +00:00
parent 7584bba741
commit fa8f834a89
28 changed files with 102 additions and 49 deletions

View File

@ -1,5 +1,45 @@
<?php
function rrdtool_graph($rrdfile, $options)
{
global $config;
if ($config['rrdcached'])
{
$command = $config['rrdtool'] . " --daemon " . $config['rrdcached'] . " -";
} else {
$command = $config['rrdtool'] . " -";
}
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);
$cwd = $config['rrd_dir'];
$env = array();
$process = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
// $pipes now looks like this:
// 0 => writeable handle connected to child stdin
// 1 => readable handle connected to child stdout
// Any error output will be appended to /tmp/error-output.txt
fwrite($pipes[0], "graph $rrdfile $options");
fclose($pipes[0]);
fclose($pipes[1]);
// It is important that you close any pipes before calling
// proc_close in order to avoid a deadlock
$return_value = proc_close($process);
# echo "command returned $return_value\n";
}
}
function generate_link($text, $vars, $new_vars = array())
{
return '<a href="'.generate_url($vars, $new_vars).'">'.$text.'</a>';