2011-04-18 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_graph.php, include/graphs/functions_pchart.php, include/graphs/fgraph.php, operation/agentes/estado_generalagente.php: some fixes and changes in the new graph engine. * operation/agentes/stat_win.php: fixed the tittle of popup window. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4236 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c4a543ceaa
commit
da3cf30d16
|
@ -1,3 +1,11 @@
|
||||||
|
2011-04-18 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_graph.php, include/graphs/functions_pchart.php,
|
||||||
|
include/graphs/fgraph.php, operation/agentes/estado_generalagente.php: some
|
||||||
|
fixes and changes in the new graph engine.
|
||||||
|
|
||||||
|
* operation/agentes/stat_win.php: fixed the tittle of popup window.
|
||||||
|
|
||||||
2011-04-18 Miguel de Dios <miguel.dedios@artica.es>
|
2011-04-18 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* include/functions_reporting.php: changed to use new engine.
|
* include/functions_reporting.php: changed to use new engine.
|
||||||
|
|
|
@ -30,6 +30,8 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events,
|
||||||
global $config;
|
global $config;
|
||||||
global $graphic_type;
|
global $graphic_type;
|
||||||
|
|
||||||
|
//include_flash_chart_script();
|
||||||
|
|
||||||
// Set variables
|
// Set variables
|
||||||
if ($date == 0) $date = get_system_time();
|
if ($date == 0) $date = get_system_time();
|
||||||
$datelimit = $date - $period;
|
$datelimit = $date - $period;
|
||||||
|
@ -74,7 +76,8 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events,
|
||||||
$min_necessary = 1;
|
$min_necessary = 1;
|
||||||
|
|
||||||
// Compressed module data
|
// Compressed module data
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Get previous data
|
// Get previous data
|
||||||
$previous_data = get_previous_data ($agent_module_id, $datelimit);
|
$previous_data = get_previous_data ($agent_module_id, $datelimit);
|
||||||
if ($previous_data !== false) {
|
if ($previous_data !== false) {
|
||||||
|
@ -86,7 +89,8 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events,
|
||||||
$nextData = get_next_data ($agent_module_id, $date);
|
$nextData = get_next_data ($agent_module_id, $date);
|
||||||
if ($nextData !== false) {
|
if ($nextData !== false) {
|
||||||
array_push ($data, $nextData);
|
array_push ($data, $nextData);
|
||||||
} else if (count ($data) > 0) {
|
}
|
||||||
|
else if (count ($data) > 0) {
|
||||||
// Propagate the last known data to the end of the interval
|
// Propagate the last known data to the end of the interval
|
||||||
$nextData = array_pop ($data);
|
$nextData = array_pop ($data);
|
||||||
array_push ($data, $nextData);
|
array_push ($data, $nextData);
|
||||||
|
@ -658,6 +662,8 @@ function graphic_agentaccess2 ($id_agent, $width, $height, $period = 0) {
|
||||||
global $config;
|
global $config;
|
||||||
global $graphic_type;
|
global $graphic_type;
|
||||||
|
|
||||||
|
include_flash_chart_script();
|
||||||
|
|
||||||
$data = array ();
|
$data = array ();
|
||||||
|
|
||||||
$resolution = $config["graph_res"] * ($period * 2 / $width); // Number of "slices" we want in graph
|
$resolution = $config["graph_res"] * ($period * 2 / $width); // Number of "slices" we want in graph
|
||||||
|
@ -729,7 +735,7 @@ function graph_event_module2 ($width = 300, $height = 200, $id_agent) {
|
||||||
}
|
}
|
||||||
asort ($data);
|
asort ($data);
|
||||||
|
|
||||||
return pie3d_graph(0, $data, $width, $height, __("other"));
|
return pie3d_graph($config['flash_charts'], $data, $width, $height, __("other"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function progress_bar2($progress, $width, $height, $title = '', $mode = 1) {
|
function progress_bar2($progress, $width, $height, $title = '', $mode = 1) {
|
||||||
|
@ -1289,4 +1295,123 @@ function graph_custom_sql_graph2 ($id, $width, $height, $type = 'sql_graph_vbar'
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a graph with event data of agents
|
||||||
|
*
|
||||||
|
* @param integer id_agent Agent ID
|
||||||
|
* @param integer width pie graph width
|
||||||
|
* @param integer height pie graph height
|
||||||
|
* @param integer period time period
|
||||||
|
*/
|
||||||
|
function graphic_agentevents2 ($id_agent, $width, $height, $period = 0) {
|
||||||
|
global $config;
|
||||||
|
global $graphic_type;
|
||||||
|
|
||||||
|
include_flash_chart_script();
|
||||||
|
|
||||||
|
$data = array ();
|
||||||
|
|
||||||
|
$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
|
||||||
|
|
||||||
|
$interval = (int) ($period / $resolution);
|
||||||
|
$date = get_system_time ();
|
||||||
|
$datelimit = $date - $period;
|
||||||
|
$periodtime = floor ($period / $interval);
|
||||||
|
$time = array ();
|
||||||
|
$data = array ();
|
||||||
|
|
||||||
|
for ($i = 0; $i < $interval; $i++) {
|
||||||
|
$bottom = $datelimit + ($periodtime * $i);
|
||||||
|
if (! $graphic_type) {
|
||||||
|
$name = date('H\h', $bottom);
|
||||||
|
} else {
|
||||||
|
$name = $bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
$top = $datelimit + ($periodtime * ($i + 1));
|
||||||
|
$criticity = (int) get_db_value_filter ('criticity',
|
||||||
|
'tevento',
|
||||||
|
array ('id_agente' => $id_agent,
|
||||||
|
'utimestamp > '.$bottom,
|
||||||
|
'utimestamp < '.$top));
|
||||||
|
|
||||||
|
switch ($criticity) {
|
||||||
|
case 3: $data[$name] = 'E5DF63';
|
||||||
|
break;
|
||||||
|
case 4: $data[$name] = 'FF3C4B';
|
||||||
|
break;
|
||||||
|
default: $data[$name] = '9ABD18';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $graphic_type) {
|
||||||
|
return fs_agent_event_chart2 ($data, $width, $height, $resolution / 750);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean FLASH string strips non-valid characters for flashchart
|
||||||
|
function clean_flash_string ($string) {
|
||||||
|
$string = html_entity_decode ($string, ENT_QUOTES, "UTF-8");
|
||||||
|
$string = str_replace('&', '', $string);
|
||||||
|
$string = str_replace(' ', '', $string);
|
||||||
|
$string = str_replace ('"', '', $string);
|
||||||
|
return substr ($string, 0, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a Pandora FMS agent event chart
|
||||||
|
function fs_agent_event_chart2 ($data, $width, $height, $step = 1) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
if (sizeof ($data) == 0) {
|
||||||
|
return fs_error_image ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the XML
|
||||||
|
$chart = new FusionCharts('Area2D', $width, $height);
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
$num_vlines = 0;
|
||||||
|
foreach ($data as $name => $value) {
|
||||||
|
if ($count++ % $step == 0) {
|
||||||
|
$show_name = '1';
|
||||||
|
$num_vlines++;
|
||||||
|
} else {
|
||||||
|
$show_name = '0';
|
||||||
|
}
|
||||||
|
$chart->addChartData(1, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=' . $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$chart->setChartParams('numDivLines=0;numVDivLines=0;showNames=1;rotateNames=0;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=0;areaBorderThickness=1;canvasBgColor=9ABD18');
|
||||||
|
|
||||||
|
// Return the code
|
||||||
|
return get_chart_code ($chart, $width, $height, 'include/FusionCharts/FCF_Area2D.swf');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the code needed to display the chart
|
||||||
|
function get_chart_code ($chart, $width, $height, $swf) {
|
||||||
|
$random_number = rand ();
|
||||||
|
$div_id = 'chart_div_' . $random_number;
|
||||||
|
$chart_id = 'chart_' . $random_number;
|
||||||
|
$output = '<div id="' . $div_id. '"></div>';
|
||||||
|
$output .= '<script type="text/javascript">
|
||||||
|
<!--
|
||||||
|
$(document).ready(function pie_' . $chart_id . ' () {
|
||||||
|
var myChart = new FusionCharts("' . $swf . '", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
|
||||||
|
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
|
||||||
|
myChart.addParam("WMode", "Transparent");
|
||||||
|
myChart.render("' . $div_id . '");
|
||||||
|
})
|
||||||
|
-->
|
||||||
|
</script>';
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prints an error image
|
||||||
|
function fs_error_image () {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
return print_image("images/image_problem.png", true, array("border" => '0'));
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -10,6 +10,7 @@
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
|
||||||
// If is called from index
|
// If is called from index
|
||||||
if(file_exists('include/functions.php')) {
|
if(file_exists('include/functions.php')) {
|
||||||
include_once('include/functions.php');
|
include_once('include/functions.php');
|
||||||
|
|
|
@ -60,15 +60,17 @@ if (!isset($graph)) {
|
||||||
$data = $graph['data'];
|
$data = $graph['data'];
|
||||||
$width = $graph['width'];
|
$width = $graph['width'];
|
||||||
$height = $graph['height'];
|
$height = $graph['height'];
|
||||||
if (isset($graph['color'])) {
|
$colors = null;
|
||||||
|
if (isset($graph['color']))
|
||||||
$colors = $graph['color'];
|
$colors = $graph['color'];
|
||||||
}
|
$legend = null;
|
||||||
if (isset($graph['legend'])) {
|
if (isset($graph['legend']))
|
||||||
$legend = $graph['legend'];
|
$legend = $graph['legend'];
|
||||||
}
|
$xaxisname = '';
|
||||||
if(isset($graph['xaxisname'])) {
|
if(isset($graph['xaxisname'])) {
|
||||||
$xaxisname = $graph['xaxisname'];
|
$xaxisname = $graph['xaxisname'];
|
||||||
}
|
}
|
||||||
|
$yaxisname = '';
|
||||||
if(isset($graph['yaxisname'])) {
|
if(isset($graph['yaxisname'])) {
|
||||||
$yaxisname = $graph['yaxisname'];
|
$yaxisname = $graph['yaxisname'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ echo '<div style="height:25px"> </div>';
|
||||||
echo '<b>'.__('Events generated -by module-').'</b><br />';
|
echo '<b>'.__('Events generated -by module-').'</b><br />';
|
||||||
echo graph_event_module2 (290, 120, $id_agente);
|
echo graph_event_module2 (290, 120, $id_agente);
|
||||||
if ($config['flash_charts']) {
|
if ($config['flash_charts']) {
|
||||||
echo graphic_agentevents ($id_agente, 290, 60, 86400);
|
echo graphic_agentevents2 ($id_agente, 290, 60, 86400);
|
||||||
}
|
}
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@ require_once ($config["homedir"] . '/include/functions_reporting.php');
|
||||||
require_once ($config["homedir"] . '/include/functions_graph.php');
|
require_once ($config["homedir"] . '/include/functions_graph.php');
|
||||||
|
|
||||||
check_login ();
|
check_login ();
|
||||||
|
|
||||||
|
$id = get_parameter('id');
|
||||||
|
$label = base64_decode(get_parameter('label', ''));
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
@ -134,14 +137,27 @@ if ($start_date != $current)
|
||||||
else
|
else
|
||||||
$date = $utime;
|
$date = $utime;
|
||||||
|
|
||||||
|
$urlImage = 'http://';
|
||||||
|
if ($config['https']) {
|
||||||
|
$urlImage = 'https://';
|
||||||
|
}
|
||||||
|
$urlImage .= $config['dbhost'] . $config['homeurl'] . '/';
|
||||||
|
|
||||||
// log4x doesnt support flash yet
|
// log4x doesnt support flash yet
|
||||||
//
|
//
|
||||||
|
switch ($graph_type) {
|
||||||
|
case 'sparse':
|
||||||
|
echo grafico_modulo_sparse2 ($id, $period, $draw_events, $width, $height,
|
||||||
|
$label, null, $draw_alerts, $avg_only, false, $date, $baseline,
|
||||||
|
0, true, false, $urlImage);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo fs_error_image ('../images');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ($config['flash_charts'] && $graph_type != "log4x") {
|
if ($config['flash_charts'] && $graph_type != "log4x") {
|
||||||
switch ($graph_type) {
|
switch ($graph_type) {
|
||||||
case 'sparse':
|
|
||||||
echo grafico_modulo_sparse2 ($id, $period, $draw_events, $width, $height,
|
|
||||||
$label, $unit_name, $draw_alerts, $avg_only, $pure, $date, $baseline);
|
|
||||||
break;
|
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
|
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
|
||||||
$label, $unit_name, $draw_alerts, 1, $pure, $date);
|
$label, $unit_name, $draw_alerts, 1, $pure, $date);
|
||||||
|
@ -154,17 +170,10 @@ if ($config['flash_charts'] && $graph_type != "log4x") {
|
||||||
echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height,
|
echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height,
|
||||||
$label, $unit_name, $draw_alerts, 1, $pure, $date, 1);
|
$label, $unit_name, $draw_alerts, 1, $pure, $date, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
echo fs_error_image ('../images');
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch ($graph_type) {
|
switch ($graph_type) {
|
||||||
case 'sparse':
|
|
||||||
echo grafico_modulo_sparse2 ($id, $period, $draw_events, $width, $height,
|
|
||||||
$label, $unit_name, $draw_alerts, $avg_only, $pure, $date, $baseline);
|
|
||||||
break;
|
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
|
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
|
||||||
$label, $unit_name, $draw_alerts, 1, $pure, $date);
|
$label, $unit_name, $draw_alerts, 1, $pure, $date);
|
||||||
|
@ -177,9 +186,6 @@ else {
|
||||||
echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height,
|
echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height,
|
||||||
$label, $unit_name, $draw_alerts, 1, $pure, $date, 1);
|
$label, $unit_name, $draw_alerts, 1, $pure, $date, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
echo fs_error_image ('../images');
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue