2011-03-28 Javier Lanz <javier.lanz@artica.es>

* include/functions_reporting.php: Added get_agentmodule_sla_array
	function and fixed some SLA graph details
	* include/pchart_graph.php: Deleted some "debugPrint" calls found
	* include/pandora_graph.php: Changed function 'graph_sla_horizontal'
	prototype



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4137 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
javilanz 2011-03-28 09:26:49 +00:00
parent 983e2de256
commit 6380b17a06
4 changed files with 79 additions and 32 deletions

View File

@ -1,3 +1,11 @@
2011-03-28 Javier Lanz <javier.lanz@artica.es>
* include/functions_reporting.php: Added get_agentmodule_sla_array
function and fixed some SLA graph details
* include/pchart_graph.php: Deleted some "debugPrint" calls found
* include/pandora_graph.php: Changed function 'graph_sla_horizontal'
prototype
2011-03-25 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* godmode/modules/module_list.php: Fixed wrong variable call.

View File

@ -507,6 +507,30 @@ function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $ma
return (float) (100 - ($bad_period / $period) * 100);
}
function get_agentmodule_sla_array ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $daysWeek = null, $timeFrom = null, $timeTo = null) {
global $config;
// Get date
$date = (string) get_parameter ('date', date ('Y-m-j'));
$time = (string) get_parameter ('time', date ('h:iA'));
$datetime = strtotime ($date.' '.$time);
$k=10;
$slices = $config["graph_res"] * $k;
$sub_period = $period / ($config["graph_res"] * 10);
$final_time = $datetime - $period + $sub_period;
$data = array();
$i = 0;
while ($final_time <= $datetime) {
$sla_value = get_agentmodule_sla ($id_agent_module, $sub_period, $min_value, $max_value, $final_time,
$daysWeek, $timeFrom, $timeTo);
$data[$i] = $sla_value;
$final_time += $sub_period;
$i++;
}
return $data;
}
/**
* Get general statistical info on a group
*
@ -1876,7 +1900,7 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
}
$slas = get_db_all_rows_field_filter ('treport_content_sla_combined',
'id_report_content', $content['id_rc']);
'id_report_content', $content['id_rc']);
if ($slas === false) {
$data = array ();
$table->colspan[2][0] = 3;
@ -1939,11 +1963,10 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data[2] = $sla['sla_max'].' / ';
$data[2] .= $sla['sla_min'];
$data[3] = $sla['sla_limit'];
//$data[4] .= $sla_value;
if ($sla_value === false) {
$data[4] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #0000FF;">';
$data[5] .= __('Unknown');
$data[5] = __('Unknown');
} else {
if ($sla_value >= $sla['sla_limit']) {
$data[4] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">';
@ -1967,8 +1990,6 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$table->colspan[3][0] = 3;
$data = array();
//$data[0] = $content["description"];
//array_push ($table->data, $data_desc);
if ($show_graph && !empty($slas)) {
if($config['flash_charts']) {
@ -1980,18 +2001,28 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
'&value2='.$data_graph[__('Out of limits')].'&value3='.$data_graph[__('On the edge')].
'&value4='.$data_graph[__('Unknown')].'&height=150&width=500">';
}
$table->style[0] = 'text-align: center';
array_push ($table->data, $data);
//Display horizontal bar graphs
/*
$table2->width = '99%';
$table2->data = array ();
foreach ($slas as $sla) {
echo '<img src="include/fgraph.php?tipo=sla_horizontal_graph&id='.$sla['id_agent_module'].
$data = array();
$data[0] =
$data[0] = get_agentmodule_agent_name ($sla['id_agent_module']);
$data[0] .= '/';
$data[0] .= get_agentmodule_name ($sla['id_agent_module']);
$data[1] = '<img src="include/fgraph.php?tipo=sla_horizontal_graph&id='.$sla['id_agent_module'].
'&period='.$content['period'].'&value1='.$sla['sla_min'].'&value2='.$sla['sla_max'].
'&value3='.$content['time_from'].'&value4='.$content['time_to'].'&height=25&width=600">';
'&value3='.$content['time_from'].'&value4='.$content['time_to'].'&percent='.$sla['sla_limit'].
'&height=15&width=550">';
array_push ($table2->data, $data);
}
*/
$table->colspan[4][0] = 3;
$data = array();
$data[0] = print_table($table2, true);
array_push ($table->data, $data);
}
break;
case 6:
case 'monitor_report':

View File

@ -60,7 +60,7 @@ abstract class PandoraGraphAbstract {
abstract protected function single_graph ();
abstract protected function combined_graph ($values, $events, $alerts, $unit_name, $max_value, $stacked);
abstract protected function progress_bar ($value, $color);
abstract protected function graph_sla_horizontal ($value, $color);
abstract protected function graph_sla_horizontal ($data, $sla_limit);
}
function get_graph_engine ($period = 3600) {

View File

@ -652,11 +652,8 @@ class PchartGraph extends PandoraGraphAbstract {
}
}
public function graph_sla_horizontal ($value, $color) {
public function graph_sla_horizontal ($data, $sla_limit) {
set_time_limit (0);
$date = (string) get_parameter ('date', date ('Y-m-j'));
$time = (string) get_parameter ('time', date ('h:iA'));
$datetime = strtotime ($date.' '.$time);
// Dataset definition
$this->graph = new pChart ($this->width, $this->height);
$this->graph->setFontProperties ($this->fontpath, 8);
@ -667,27 +664,40 @@ class PchartGraph extends PandoraGraphAbstract {
$radius = ($this->height > 18) ? 8 : 0;
else
$radius = 0;
$ratio = 200;
//$ratio = (int) $value / 100 * $this->width;
$ratio = $this->width / count($data);
/* Color stuff */
$bgcolor = $this->get_rgb_values ($this->background_color);
$r = hexdec (substr ($this->background_color, 1, 2));
$g = hexdec (substr ($this->background_color, 3, 2));
$b = hexdec (substr ($this->background_color, 5, 2));
$black = '#FFFFFF';
$colorOK = '#38B800';
$colorEdge = '#FFFF00';
$colorWrong = '#FF0000';
$colorUnknown = '#C3C3C3';
$color_black = $this->get_rgb_values ($black);
/* Actual percentage */
if (! $this->show_title || $value > 0) {
debugPrint("entra en el if show title or value > 0", "/tmp/prueba.txt");
$color = $this->get_rgb_values ($color);
$this->graph->drawFilledRoundedRectangle (50, 0, $ratio+50,
$this->height, $radius, $color['r'], $color['g'], $color['b']);
$this->graph->drawFilledRoundedRectangle (300, 0, $ratio+300,
$this->height, $radius, $color['r'], $color['g'], $color['b']);
$i = 0;
foreach ($data as $d) {
if ($d === false) {
$color = $this->get_rgb_values ($colorUnknown);
} elseif ($d <= $sla_limit+10 && $d >= $sla_limit-10) {
$color = $this->get_rgb_values ($colorEdge);
} elseif ($d > $sla_limit+10) {
$color = $this->get_rgb_values ($colorOK);
} elseif ($d < $sla_limit-10) {
$color = $this->get_rgb_values ($colorWrong);
}
$this->graph->drawFilledRoundedRectangle ($i, 0, $ratio+$i,
$this->height, $radius, $color['r'], $color['g'], $color['b']);
$i+=$ratio;
}
if ($config["round_corner"]) {
debugPrint("entra en el if de round_corner", "/tmp/prueba.txt");
/* Under this value, the rounded rectangle is painted great */
if ($ratio <= 16) {
/* Clean a bit of pixels */
@ -702,10 +712,8 @@ class PchartGraph extends PandoraGraphAbstract {
}
if ($this->border) {
debugPrint("entra en el último if, el de border", "/tmp/prueba.txt");
$this->graph->drawRoundedRectangle (0, 0, $this->width + 50,
$this->height - 1,
$radius, 157, 157, 157);
$this->graph->drawRoundedRectangle (0, 0, $this->width,
$this->height - 1, $radius, 157, 157, 157);
}
$this->graph->Stroke ();