acsw change, and improve debugging for rrdtool graphing

git-svn-id: http://www.observium.org/svn/observer/trunk@2816 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-01-12 12:51:21 +00:00
parent bf09e5844f
commit f22f4b12a6
6 changed files with 93 additions and 61 deletions
+40 -1
View File
@@ -1,5 +1,44 @@
<?php
include_once("Net/IPv4.php");
if (isset($_GET['debug']))
{
$debug = TRUE;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('error_reporting', E_ALL);
}
else
{
$debug = FALSE;
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('error_reporting', 0);
}
include_once("../includes/defaults.inc.php");
include_once("../config.php");
include_once("../includes/common.php");
include_once("../includes/dbFacile.php");
include_once("../includes/rewrites.php");
include_once("includes/functions.inc.php");
include_once("../includes/rrdtool.inc.php");
include_once("includes/authenticate.inc.php");
if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs'])
{
$auth = "1"; ## hardcode auth for all with config function
} else {
if (!$_SESSION['authenticated'])
{
graph_error("Session not authenticated");
exit;
}
}
include("includes/graphs/graph.inc.php");
?>
?>
+11 -47
View File
@@ -1,33 +1,5 @@
<?php
include_once("Net/IPv4.php");
if (isset($_GET['debug']))
{
$debug = TRUE;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('error_reporting', E_ALL);
}
else
{
$debug = FALSE;
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('error_reporting', 0);
}
include_once("../includes/defaults.inc.php");
include_once("../config.php");
include_once("../includes/common.php");
include_once("../includes/dbFacile.php");
include_once("../includes/rewrites.php");
include_once("includes/functions.inc.php");
include_once("../includes/rrdtool.inc.php");
include_once("includes/authenticate.inc.php");
$from = mres($_GET['from']);
$to = mres($_GET['to']);
$width = mres($_GET['width']);
@@ -39,17 +11,6 @@ $id = mres($_GET['id']);
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs'])
{
$auth = "1"; ## hardcode auth for all with config function
} else {
if (!$_SESSION['authenticated'])
{
graph_error("Session not authenticated");
exit;
}
}
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', mres($_GET['type']), $graphtype);
$type = $graphtype['type'];
@@ -113,20 +74,17 @@ function graph_error($string)
imagedestroy($im);
exit();
}
}
if ($error_msg) {
graph_error($graph_error);
} elseif (!$auth) {
if ($width < 200)
{
graph_error("No Auth");
} else {
graph_error("No Authorisation");
}
} else {
#$rrd_options .= " HRULE:0#999999";
if ($no_file)
@@ -137,15 +95,21 @@ if ($error_msg) {
} else {
graph_error("Missing RRD Datafile");
}
} elseif($command_only) {
echo("<div class='infobox'>");
echo("<p style='font-size: 16px; font-weight: bold;'>RRDTool Command</p>");
echo("rrdtool graph $graphfile $rrd_options");
echo("</span>");
$return = rrdtool_graph($graphfile, $rrd_options);
echo("<br /><br />");
echo("<p style='font-size: 16px; font-weight: bold;'>RRDTool Output</p>$return");
unlink($graphfile);
echo("</div>");
} else {
if ($rrd_options)
{
#rrdtool_graph($filename, $options)
rrdtool_graph($graphfile, $rrd_options);
if ($debug) { echo("<pre>".$rrd_cmd."</pre>"); }
if ($debug) { echo($rrd_cmd); }
if (is_file($graphfile))
{
if (!$debug)
+18
View File
@@ -89,6 +89,17 @@ if (!$auth)
echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no")));
}
echo('<div style="float: right;">');
if ($vars['showcommand'] == "yes")
{
echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL)));
} else {
echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes")));
}
echo('</div>');
print_optionbar_end();
echo generate_graph_js_state($graph_array);
@@ -96,6 +107,13 @@ if (!$auth)
echo('<div style="width: '.$graph_array['width'].'; margin: auto;">');
echo(generate_graph_tag($graph_array));
echo("</div>");
if($vars['showcommand'])
{
$_GET = $graph_array;
$command_only = 1;
include("includes/graphs/graph.inc.php");
}
}
?>
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
if ($device['os_group'] == "cisco")
if ($device['os_group'] == "cisco" || $device['os'] == "acsw")
{
echo("CISCO-PROCESS-MIB : ");
$processors_array = snmpwalk_cache_oid($device, "cpmCPU", NULL, "CISCO-PROCESS-MIB");
+19 -8
View File
@@ -45,8 +45,8 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes)
$rrd_process = proc_open($command, $descriptorspec, $rrd_pipes, $cwd, $env);
stream_set_blocking($rrd_pipes[1], 0);
stream_set_blocking($rrd_pipes[2], 0);
# stream_set_blocking($rrd_pipes[1], 0);
# stream_set_blocking($rrd_pipes[2], 0);
if (is_resource($rrd_process))
{
@@ -68,6 +68,8 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes)
function rrdtool_pipe_close(&$rrd_process, &$rrd_pipes)
{
global $debug;
if ($debug)
{
echo stream_get_contents($rrd_pipes[1]);
@@ -82,10 +84,9 @@ function rrdtool_pipe_close(&$rrd_process, &$rrd_pipes)
// proc_close in order to avoid a deadlock
$return_value = proc_close($rrd_process);
if ($debug)
{
echo $return_value;
}
return $return_value;
}
/**
@@ -117,16 +118,26 @@ function rrdtool_graph($graph_file, $options)
fwrite($rrd_pipes[0], "graph $graph_file $options");
}
rrdtool_pipe_close($rrd_process, $rrd_pipes);
fclose($rrd_pipes[0]);
while (strlen($line) < 1) {
$line = fgets($rrd_pipes[1],1024);
$data .= $line;
}
$return_value = rrdtool_pipe_close($rrd_process, $rrd_pipes);
if ($debug)
{
echo("<p>");
if ($debug) { echo("graph $graph_file $options"); }
echo("</p><p>");
echo "command returned $return_value\n";
echo "command returned $return_value ($data)\n";
echo("</p>");
}
return $data;
} else {
return 0;
}
}
+4 -4
View File
@@ -162,7 +162,7 @@ $config['os'][$os]['over'][2]['text'] = "Memory Usage";
$config['os'][$os]['icon'] = "cisco";
$os = "acsw";
$config['os'][$os]['group'] = "cisco";
#$config['os'][$os]['group'] = "cisco";
$config['os'][$os]['text'] = "Cisco ACE";
$config['os'][$os]['ifname'] = 1;
$config['os'][$os]['type'] = "network";
@@ -492,11 +492,11 @@ $os = "powerware";
$config['os'][$os]['text'] = "Powerware UPS";
$config['os'][$os]['type'] = "power";
$config['os'][$os]['icon'] = "eaton";
$config['os'][$os]['over'][0]['graph'] = "device_voltages";
$config['os'][$os]['over'][0]['text'] = "Voltages";
$config['os'][$os]['over'][0]['graph'] = "device_voltage";
$config['os'][$os]['over'][0]['text'] = "Voltage";
$config['os'][$os]['over'][1]['graph'] = "device_current";
$config['os'][$os]['over'][1]['text'] = "Current";
$config['os'][$os]['over'][2]['graph'] = "device_frequencies";
$config['os'][$os]['over'][2]['graph'] = "device_frequency";
$config['os'][$os]['over'][2]['text'] = "Frequencies";
$os = "deltaups";