mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
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:
@@ -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>';
|
||||
|
||||
@@ -29,7 +29,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($id))
|
||||
}
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
|
||||
if (is_file($rrd_filename) && $ignore != 1)
|
||||
if ($ignore != 1 && is_file($rrd_filename))
|
||||
{
|
||||
$rrd_filenames[] = $rrd_filename;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
|
||||
@@ -88,7 +88,8 @@ function graph_error($string)
|
||||
|
||||
#$rrd_options .= " HRULE:0#cc0000";
|
||||
#$rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches;
|
||||
$rrd_cmd = $config['rrdtool'] . " graph $graphfile --title='".$string."' -l 0 -u 100 -E --start -10y --end now --width $width --height $height -c BACK#ff9999cc -c SHADEA#EEEEEE00 -c SHADEB#EEEEEE00 -c FONT#000000 -c CANVAS#FFFFFF00 -c GRID#a5a5a5 -c MGRID#FF9999 -c FRAME#5e5e5e -c ARROW#5e5e5e -R normal --font LEGEND:8:DejaVuSansMono --font AXIS:7:DejaVuSansMono --font-render-mode normal HRULE:0#cc0000" . $rrd_switches;
|
||||
|
||||
echo(rrdtool_graph($graphfile, " --title='".$string."' -l 0 -u 100 -E --start -10y --end now --width $width --height $height -c BACK#ff9999cc -c SHADEA#EEEEEE00 -c SHADEB#EEEEEE00 -c FONT#000000 -c CANVAS#FFFFFF00 -c GRID#a5a5a5 -c MGRID#FF9999 -c FRAME#5e5e5e -c ARROW#5e5e5e -R normal --font LEGEND:8:DejaVuSansMono --font AXIS:7:DejaVuSansMono --font-render-mode normal HRULE:0#cc0000"));
|
||||
|
||||
if ($height > "99") {
|
||||
#$rrd_cmd .= " --only-graph"; }
|
||||
@@ -140,8 +141,7 @@ if ($error_msg) {
|
||||
if ($rrd_options)
|
||||
{
|
||||
if ($config['rrdcached']) { $rrd_switches = " --daemon ".$config['rrdcached'] . " "; }
|
||||
$rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches;
|
||||
$woo = shell_exec($rrd_cmd);
|
||||
rrdtool_graph($graphfile, " $rrd_options");
|
||||
if ($debug) { echo("<pre>".$rrd_cmd."</pre>"); }
|
||||
if (is_file($graphfile) && !$debug)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user