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

* include/functions_events.php: Truncated agent and module name
	* include/functions_reporting.php: Added functionality to store info of
	General, Top n and Exception reports
	* include/pchart_graph.php: Added function graph_sla_horizontal to print
	sla horizontal graph bar. (Not working properly yet)
	* include/pandora_graph.php: Added prototipe for
	function graph_sla_horizontal
	* include/fgraph.php: Added function graph_sla_pie to print sla pie graph
	* include/functions.php: Added options top n, exception and general for
	the combo box to select report type.
	* pandoradb.sql: added fome fields to treport_content table
	* extras/pandoradb_migrate_v3.2_to_v4.0.sql: added some fields to 
	treport_content table
	* godmode/reporting/reporting_builder.list_items.php: Truncated agent
	and module name
	* godmode/reporting/reporting_builder.preview.php: Added a bottom scroll
	bar to the report table
	* godmode/reporting/reporting_builder.php: Added variables for the new
	kinds of reports, top n, exception and general
	* godmode/reporting/reporting_builder.item_editor.php: Added html
	elements for the new kind of reports


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4111 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
javilanz 2011-03-21 17:20:18 +00:00
parent f301e353e1
commit 27880c6450
13 changed files with 1145 additions and 68 deletions

View File

@ -1,3 +1,27 @@
2011-03-21 Javier Lanz <javier.lanz@artica.es>
* include/functions_events.php: Truncated agent and module name
* include/functions_reporting.php: Added functionality to store info of
General, Top n and Exception reports
* include/pchart_graph.php: Added function graph_sla_horizontal to print
sla horizontal graph bar. (Not working properly yet)
* include/pandora_graph.php: Added prototipe for
function graph_sla_horizontal
* include/fgraph.php: Added function graph_sla_pie to print sla pie graph
* include/functions.php: Added options top n, exception and general for
the combo box to select report type.
* pandoradb.sql: added fome fields to treport_content table
* extras/pandoradb_migrate_v3.2_to_v4.0.sql: added some fields to
treport_content table
* godmode/reporting/reporting_builder.list_items.php: Truncated agent
and module name
* godmode/reporting/reporting_builder.preview.php: Added a bottom scroll
bar to the report table
* godmode/reporting/reporting_builder.php: Added variables for the new
kinds of reports, top n, exception and general
* godmode/reporting/reporting_builder.item_editor.php: Added html
elements for the new kind of reports
2011-03-21 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* pandoradb.oracle.sql

View File

@ -26,12 +26,20 @@ ALTER TABLE `tgrupo` MODIFY `nombre` text;
-- -----------------------------------------------------
-- Table `tnetwork_component`
-- -----------------------------------------------------
ALTER TABLE `tnetwork_component` ADD COLUMN `post_process` double(18,13) default 0;
ALTER TABLE `tnetwork_component` ADD COLUMN `post_process` double(18,13) DEFAULT 0;
-- -----------------------------------------------------
-- Table `treport_content`
-- -----------------------------------------------------
ALTER TABLE treport_content ADD only_display_wrong tinyint(1) unsigned DEFAULT 0 NOT NULL;
ALTER TABLE `treport_content` ADD COLUMN `only_display_wrong` tinyint(1) unsigned NOT NULL DEFAULT 0;
ALTER TABLE `treport_content` ADD COLUMN `top_n` INT NOT NULL DEFAULT 0;
ALTER TABLE `treport_content` ADD COLUMN `top_n_value` INT NOT NULL DEFAULT 10;
ALTER TABLE `treport_content` ADD COLUMN `exception_condition` INT NOT NULL DEFAULT 0;
ALTER TABLE `treport_content` ADD COLUMN `exception_condition_value` DOUBLE (18,6) NOT NULL DEFAULT 0;
ALTER TABLE `treport_content` ADD COLUMN `show_resume` INT NOT NULL DEFAULT 0;
ALTER TABLE `treport_content` ADD COLUMN `order_uptodown` INT NOT NULL DEFAULT 0;
ALTER TABLE `treport_content` ADD COLUMN `show_graph` INT NOT NULL DEFAULT 0;
ALTER TABLE `treport_content` ADD COLUMN `group_by_agent` INT NOT NULL DEFAULT 0
-- -----------------------------------------------------
-- Table `tusuario`

View File

@ -49,6 +49,14 @@ switch ($action) {
$sunday = true;
$time_from = '00:00';
$time_to = '23:59';
$group_by_agent = 0;
$order_uptodown = 0;
$show_resume = 0;
$top_n = 0;
$top_n_value = 10;
$exception_condition = 0;
$exception_condition_value = 10;
$show_graph = 0;
break;
default:
$actionParameter = 'update';
@ -87,6 +95,7 @@ switch ($action) {
$sunday = $item['sunday'];
$time_from = $item['time_from'];
$time_to = $item['time_to'];
$show_graph = $item['show_graph'];
break;
case 'monitor_report':
$description = $item['description'];
@ -212,6 +221,31 @@ switch ($action) {
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$period = $item['period'];
break;
case 'general':
$description = $item['description'];
$group_by_agent = $item['group_by_agent'];
$period = $item['period'];
$order_uptodown = $item['order_uptodown'];
$show_resume = $item['show_resume'];
$show_graph = $item['show_graph'];
break;
case 'top_n':
$description = $item['description'];
$period = $item['period'];
$top_n = $item ['top_n'];
$top_n_value = $item ['top_n_value'];
$show_resume = $item['show_resume'];
$show_graph = $item['show_graph'];
$order_uptodown = $item['order_uptodown'];
break;
case 'exception':
$description = $item['description'];
$period = $item['period'];
$exception_condition = $item['exception_condition'];
$exception_condition_value = $item['exception_condition_value'];
$show_resume = $item['show_resume'];
$show_graph = $item['show_graph'];
$order_uptodown = $item['order_uptodown'];
}
break;
@ -230,7 +264,7 @@ $urlForm = 'index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&ta
echo '<form action="' . $urlForm . '" method="post">';
print_input_hidden('id_item', $idItem);
?>
<table style="" class="databox" id="" border="0" cellpadding="4" cellspacing="4" width="90%">
<table style="" class="databox" id="" border="0" cellpadding="4" cellspacing="4" width="95%">
<tbody>
<tr id="row_type" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Type'); ?></td>
@ -284,7 +318,9 @@ print_input_hidden('id_item', $idItem);
</tr>
<tr id="row_group" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Group');?></td>
<td style=""><?php print_select(get_all_groups(), 'group', $group, '', __('All'), '0'); ?></td>
<td style="">
<?php print_select_groups($config['id_user'], "AR", true, 'combo_group', '', 'extract_group_agents()');?>
</td>
</tr>
<tr id="row_agent" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Agent'); ?></td>
@ -363,11 +399,69 @@ print_input_hidden('id_item', $idItem);
<td style="vertical-align: top;"><?php echo __('Line separator'); ?></td>
<td style=""><?php print_input_text('line', $line, '', 2, 4); ?></td>
</tr>
<tr id="row_group_by_agent" style="" class="datos">
<td><?php echo __('Group by agent');?></td>
<td><?php print_checkbox('checkbox_row_group_by_agent', 1, $group_by_agent);?></td>
</tr>
<tr id="row_order_uptodown" style="" class="datos">
<td><?php echo __('Order');?></td>
<td><?php
echo __('Ascending');
print_radio_button ('radiobutton_order_uptodown', 2, '', $order_uptodown);
echo __('Descending');
print_radio_button ('radiobutton_order_uptodown', 1, '', $order_uptodown);
echo __('By agent name');
print_radio_button ('radiobutton_order_uptodown', 3, '', $order_uptodown);
?></td>
</tr>
<tr id="row_quantity" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Quantity (n)'); ?></td>
<td style=""><?php print_input_text('quantity', $top_n_value, '', 5, 5); ?></td>
</tr>
<tr id="row_max_min_avg" style="" class="datos">
<td><?php echo __('Display');?></td>
<td><?php
echo __('Max');
print_radio_button ('radiobutton_max_min_avg', 1, '', $top_n);
echo __('Min');
print_radio_button ('radiobutton_max_min_avg', 2, '', $top_n);
echo __('Avg');
print_radio_button ('radiobutton_max_min_avg', 3, '', $top_n);
?></td>
</tr>
<tr id="row_exception_condition_value" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Value'); ?></td>
<td style=""><?php print_input_text('exception_condition_value', $exception_condition_value, '', 5, 5); ?></td>
</tr>
<tr id="row_exception_condition" style="" class="datos">
<td><?php echo __('Condition');?></td>
<td><?php
echo __('Everything');
print_radio_button ('radiobutton_exception_condition', 0, '', $exception_condition);
echo __('>=');
print_radio_button ('radiobutton_exception_condition', 1, '', $exception_condition);
echo __('<');
print_radio_button ('radiobutton_exception_condition', 2, '', $exception_condition);
echo __('OK');
print_radio_button ('radiobutton_exception_condition', 3, '', $exception_condition);
echo __('Not OK');
print_radio_button ('radiobutton_exception_condition', 4, '', $exception_condition);
?></td>
</tr>
<tr id="row_show_graph" style="" class="datos">
<td><?php echo __('Show graph');?></td>
<td><?php print_checkbox('checkbox_show_graph', 1, $show_graph);?></td>
</tr>
<tr id="row_show_resume" style="" class="datos">
<td><?php echo __('Show resume');?></td>
<td><?php print_checkbox('checkbox_show_resume', 1, $show_resume);?></td>
</tr>
</tbody>
</table>
<?php
print_SLA_list('90%', $action, $idItem);
echo '<div class="action-buttons" style="width: 90%">';
print_SLA_list('95%', $action, $idItem);
print_General_list('95%', $action, $idItem);
echo '<div class="action-buttons" style="width: 95%">';
if ($action == 'new') {
print_submit_button(__('Create item'), 'create_item', false, 'class="sub wand"');
}
@ -386,7 +480,7 @@ if ($enterpriseEnable) {
function print_SLA_list($width, $action, $idItem = null) {
?>
<table class="databox" id="sla_list" border="0" cellpadding="4" cellspacing="4" width="90%">
<table class="databox" id="sla_list" border="0" cellpadding="4" cellspacing="4" width="95%">
<thead>
<tr>
<th class="header" scope="col"><?php echo __('Agent');?></th>
@ -420,11 +514,11 @@ function print_SLA_list($width, $action, $idItem = null) {
$nameModule = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
echo '<tr id="sla_' . $item['id'] . '" style="" class="datos">
<td>' . $nameAgent . '</td>
<td>' . $nameModule . '</td>
<td>' . $item['sla_min'] . '</td>
<td>' . $item['sla_max'] . '</td>
<td>' . $item['sla_limit'] . '</td>
<td>' . printTruncateText($nameAgent, 20) . '</td>
<td>' . printTruncateText($nameModule, 20) . '</td>
<td>' . print_input_text('input_min', $item['sla_min'], '', 15, 255, true) . '</td>
<td>' . print_input_text('input_max', $item['sla_max'], '', 15, 255, true) . '</td>
<td>' . print_input_text('input_limit', $item['sla_limit'], '', 10, 255, true) . '</td>
<td style="text-align: center;">
<a href="javascript: deleteSLARow(' . $item['id'] . ');">' . print_image("images/cross.png", true) . '</a>
</td>
@ -447,7 +541,7 @@ function print_SLA_list($width, $action, $idItem = null) {
<td>
<input id="hidden-id_agent_sla" name="id_agent_sla" value="" type="hidden">
<input style="background: transparent url(images/lightning.png) no-repeat right;" name="agent_sla" id="text-agent_sla" size="15" maxlength="20" type="text"><a href="#" class="tip">&nbsp;<span>Type at least two characters to search</span></a></td>
<td><select id="id_agent_module_sla" name="id_agente_modulo_sla" disabled="disabled"><option value="0"><?php echo __('Select an Agent first'); ?></option></select></td>
<td><select id="id_agent_module_sla" name="id_agente_modulo_sla" disabled="disabled" style="max-width: 180px"><option value="0"><?php echo __('Select an Agent first'); ?></option></select></td>
<td><input name="sla_min" id="text-sla_min" size="10" maxlength="10" type="text"></td>
<td><input name="sla_max" id="text-sla_max" size="10" maxlength="10" type="text"></td>
<td><input name="sla_limit" id="text-sla_limit" size="10" maxlength="10" type="text"></td>
@ -464,11 +558,82 @@ function print_SLA_list($width, $action, $idItem = null) {
<span style="display: none" id="module_sla_text"><?php echo __('Select an Agent first'); ?></span>
<?php
}
function print_General_list($width, $action, $idItem = null) {
?>
<table class="databox" id="general_list" border="0" cellpadding="4" cellspacing="4" width="95%">
<thead>
<tr>
<th class="header" scope="col"><?php echo __('Agent');?></th>
<th class="header" scope="col"><?php echo __('Module');?></th>
<th class="header" scope="col"><?php echo __('Action');?></th>
</tr>
</thead>
<?php
switch ($action) {
case 'new':
?>
<tr id="general_template" style="" class="datos">
<td colspan="3"><?php echo __('Please save the report to start adding items into the list.');?></td>
</tr>
<?php
break;
case 'save':
case 'update':
case 'edit':
echo '<tbody id="list_general">';
$itemsGeneral = get_db_all_rows_filter('treport_content_item', array('id_report_content' => $idItem));
if ($itemsGeneral === false) {
$itemsGeneral = array();
}
foreach ($itemsGeneral as $item) {
$idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
$nameAgent = get_agent_name ($idAgent);
$nameModule = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
echo '<tr id="general_' . $item['id'] . '" style="" class="datos">
<td>' . printTruncateText($nameAgent, 35) . '</td>
<td>' . printTruncateText($nameModule, 35) . '</td>
<td style="text-align: center;">
<a href="javascript: deleteGeneralRow(' . $item['id'] . ');">' . print_image("images/cross.png", true) . '</a>
</td>
</tr>';
}
echo '</tbody>';
?>
<tbody id="general_template">
<tr id="row" style="display: none;" class="datos">
<td class="agent_name"></td>
<td class="module_name"></td>
<td style="text-align: center;"><a class="delete_button" href="javascript: deleteGeneralRow(0);"><?php print_image("images/cross.png", false); ?></a></td>
</tr>
</tbody>
<tbody>
<tr id="general_form" style="" class="datos">
<td>
<input id="hidden-id_agent_general" name="id_agent_general" value="" type="hidden">
<input style="background: transparent url(images/lightning.png) no-repeat right;" name="agent_general" id="text-agent_general" size="15" maxlength="20" type="text"><a href="#" class="tip">&nbsp;<span>Type at least two characters to search</span></a></td>
<td><select id="id_agent_module_general" name="id_agente_modulo_general" disabled="disabled" style="max-width: 180px"><option value="0"><?php echo __('Select an Agent first'); ?></option></select></td>
<td style="text-align: center;"><a href="javascript: addGeneralRow();"><?php print_image("images/disk.png", false); ?></a></td>
</tr>
</tbody>
<?php
break;
default:
break;
}
?>
</table>
<span style="display: none" id="module_general_text"><?php echo __('Select an Agent first'); ?></span>
<?php
}
?>
<script>
$(document).ready (function () {
agent_module_autocomplete('#text-agent', '#hidden-id_agent', '#id_agent_module');
agent_module_autocomplete('#text-agent_sla', '#hidden-id_agent_sla', '#id_agent_module_sla');
agent_module_autocomplete('#text-agent_general', '#hidden-id_agent_general', '#id_agent_module_general');
chooseType();
chooseSQLquery();
@ -541,6 +706,26 @@ function deleteSLARow(id_row) {
});
}
function deleteGeneralRow(id_row) {
//ajax to delete
var params = [];
params.push("delete_general_item=1");
params.push("id=" + id_row);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
if (data['correct']) {
$("#general_" + id_row).remove();
}
}
});
}
function addSLARow() {
var nameAgent = $("input[name=agent_sla]").val();
var idAgent = $("input[name=id_agent_sla]").val();
@ -552,13 +737,123 @@ function addSLARow() {
if ((idAgent != '') && (slaMin != '') && (slaMax != '')
&& (slaLimit != '')) {
//Truncate nameAgent
var params = [];
params.push("truncate_text=1");
params.push("text=" + nameAgent);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
async: false,
timeout: 10000,
success: function (data) {
nameAgent = data;
}
});
//Truncate nameModule
var params = [];
params.push("truncate_text=1");
params.push("text=" + nameModule);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
async: false,
timeout: 10000,
success: function (data) {
nameModule = data;
}
});
var params = [];
params.push("add_sla=1");
params.push("id=" + $("input[name=id_item]").val());
params.push("id_module=" + idModule);
params.push("sla_min=" + slaMin);
params.push("sla_max=" + slaMax);
params.push("sla_limit=" + slaLimit);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
if (data['correct']) {
row = $("#sla_template").clone();
$("#row", row).css('display', '');
$("#row", row).attr('id', 'sla_' + data['id']);
$(".agent_name", row).html(nameAgent);
$(".module_name", row).html(nameModule);
$(".sla_min", row).html(slaMin);
$(".sla_max", row).html(slaMax);
$(".sla_limit", row).html(slaLimit);
$(".delete_button", row).attr('href', 'javascript: deleteSLARow(' + data['id'] + ');');
$("#list_sla").append($(row).html());
$("input[name=id_agent_sla]").val('');
$("input[name=agent_sla]").val('');
$("#id_agent_module_sla").empty();
$("#id_agent_module_sla").attr('disabled', 'true');
$("#id_agent_module_sla").append(
$("<option></option>")
.attr ("value", 0)
.html ($("#module_sla_text").html()));
$("input[name=sla_min]").val('');
$("input[name=sla_max]").val('');
$("input[name=sla_limit]").val('');
}
}
});
}
}
function addGeneralRow() {
var nameAgent = $("input[name=agent_general]").val();
var idAgent = $("input[name=id_agent_general]").val();
var idModule = $("#id_agent_module_general").val();
var nameModule = $("#id_agent_module_general :selected").text();
if (idAgent != '') {
//Truncate nameAgent
var params = [];
params.push("add_sla=1");
params.push("truncate_text=1");
params.push("text=" + nameAgent);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
async: false,
timeout: 10000,
success: function (data) {
nameAgent = data;
}
});
//Truncate nameModule
var params = [];
params.push("truncate_text=1");
params.push("text=" + nameModule);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
async: false,
timeout: 10000,
success: function (data) {
nameModule = data;
}
});
var params = [];
params.push("add_general=1");
params.push("id=" + $("input[name=id_item]").val());
params.push("id_module=" + idModule);
params.push("sla_min=" + slaMin);
params.push("sla_max=" + slaMax);
params.push("sla_limit=" + slaLimit);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
@ -568,30 +863,24 @@ function addSLARow() {
dataType: 'json',
success: function (data) {
if (data['correct']) {
row = $("#sla_template").clone();
row = $("#general_template").clone();
$("#row", row).css('display', '');
$("#row", row).attr('id', 'sla_' + data['id']);
$("#row", row).attr('id', 'general_' + data['id']);
$(".agent_name", row).html(nameAgent);
$(".module_name", row).html(nameModule);
$(".sla_min", row).html(slaMin);
$(".sla_max", row).html(slaMax);
$(".sla_limit", row).html(slaLimit);
$(".delete_button", row).attr('href', 'javascript: deleteSLARow(' + data['id'] + ');');
$(".delete_button", row).attr('href', 'javascript: deleteGeneralRow(' + data['id'] + ');');
$("#list_sla").append($(row).html());
$("#list_general").append($(row).html());
$("input[name=id_agent_sla]").val('');
$("input[name=agent_sla]").val('');
$("#id_agent_module_sla").empty();
$("#id_agent_module_sla").attr('disabled', 'true');
$("#id_agent_module_sla").append(
$("input[name=id_agent_general]").val('');
$("input[name=agent_general]").val('');
$("#id_agent_module_general").empty();
$("#id_agent_module_general").attr('disabled', 'true');
$("#id_agent_module_general").append(
$("<option></option>")
.attr ("value", 0)
.html ($("#module_sla_text").html()));
$("input[name=sla_min]").val('');
$("input[name=sla_max]").val('');
$("input[name=sla_limit]").val('');
.html ($("#module_general_text").html()));
}
}
});
@ -619,7 +908,18 @@ function chooseType() {
$("#row_group").css('display', 'none');
$("#row_working_time").css('display', 'none');
$("#row_only_display_wrong").css('display', 'none');
$("#row_combo_module").css('display', 'none');
$("#row_only_display_wrong").css('display', 'none');
$("#row_group_by_agent").css('display', 'none');
$("#general_list").css('display', 'none');
$("#row_order_uptodown").css('display', 'none');
$("#row_show_resume").css('display', 'none');
$("#row_show_graph").css('display', 'none');
$("#row_max_min_avg").css('display', 'none');
$("#row_quantity").css('display', 'none');
$("#row_exception_condition_value").css('display', 'none');
$("#row_exception_condition").css('display', 'none');
switch (type) {
case 'event_report_group':
$("#row_description").css('display', '');
@ -644,6 +944,7 @@ function chooseType() {
$("#sla_list").css('display', '');
$("#row_working_time").css('display', '');
$("#row_only_display_wrong").css('display', '');
$("#row_show_graph").css('display', '');
break;
case 'monitor_report':
$("#row_description").css('display', '');
@ -768,6 +1069,35 @@ function chooseType() {
$("#row_module").css('display', '');
$("#row_period").css('display', '');
break;
case 'general':
$("#row_description").css('display', '');
$("#row_group_by_agent").css('display', '');
$("#row_period").css('display', '');
$("#general_list").css('display', '');
$("#row_order_uptodown").css('display', '');
$("#row_show_resume").css('display', '');
$("#row_show_graph").css('display', '');
break;
case 'top_n':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#row_max_min_avg").css('display', '');
$("#row_quantity").css('display', '');
$("#general_list").css('display', '');
$("#row_order_uptodown").css('display', '');
$("#row_show_resume").css('display', '');
$("#row_show_graph").css('display', '');
break;
case 'exception':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#general_list").css('display', '');
$("#row_exception_condition_value").css('display', '');
$("#row_exception_condition").css('display', '');
$("#row_order_uptodown").css('display', '');
$("#row_show_resume").css('display', '');
$("#row_show_graph").css('display', '');
break;
}
}
</script>

View File

@ -214,18 +214,18 @@ foreach ($items as $item) {
$row[3] = '-';
}
else {
$row[2] = get_agent_name(get_agent_module_id($item['id_agent_module']));
$row[3] = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
$row[2] = printTruncateText(get_agent_name(get_agent_module_id($item['id_agent_module'])), 20);
$row[3] = printTruncateText(get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])), 20);
}
}
else {
$row[2] = get_agent_name($item['id_agent']);
$row[2] = printTruncateText(get_agent_name($item['id_agent']), 20);
if ($item['id_agent_module'] == '') {
$row [3] = '-';
}
else {
$row[3] = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
$row[3] = printTruncateText(get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])),20);
}
}

View File

@ -187,6 +187,14 @@ switch ($action) {
$values['sunday'] = get_parameter('sunday', 0);
$values['time_from'] = get_parameter('time_from');
$values['time_to'] = get_parameter('time_to');
$values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent');
$values['show_resume'] = get_parameter ('checkbox_show_resume');
$values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown');
$values['top_n'] = get_parameter('radiobutton_max_min_avg');
$values['top_n_value'] = get_parameter('quantity');
$values['exception_condition'] = get_parameter('radiobutton_exception_condition');
$values['exception_condition_value'] = get_parameter('exception_condition_value');
$values['show_graph'] = get_parameter('checkbox_show_graph');
if (($values['type'] == 'sql') OR ($values['type'] == 'sql_graph_hbar')OR ($values['type'] == 'sql_graph_vbar') OR ($values['type'] == 'sql_graph_pie')) {
$values['treport_custom_sql_id'] = get_parameter('id_custom');
@ -227,6 +235,14 @@ switch ($action) {
$values['sunday'] = get_parameter('sunday', 0);
$values['time_from'] = get_parameter('time_from');
$values['time_to'] = get_parameter('time_to');
$values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent');
$values['show_resume'] = get_parameter ('checkbox_show_resume');
$values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown');
$values['top_n'] = get_parameter('radiobutton_max_min_avg');
$values['top_n_value'] = get_parameter('quantity');
$values['exception_condition'] = get_parameter('radiobutton_exception_condition');
$values['exception_condition_value'] = get_parameter('exception_condition_value');
$values['show_graph'] = get_parameter('checkbox_show_graph');
if (($values['type'] == 'sql') OR ($values['type'] == 'sql_graph_hbar')OR ($values['type'] == 'sql_graph_vbar') OR ($values['type'] == 'sql_graph_pie')) {

View File

@ -144,8 +144,9 @@ foreach ($contents as $content) {
$table->rowstyle = array ();
render_report_html_item ($content, $table, $report);
echo '<div style = "overflow:auto;">';
print_table ($table);
echo "</div>";
flush ();
}
?>

View File

@ -42,7 +42,7 @@ else {
}
enterprise_include ('include/functions_reporting.php');
enterprise_include_once ('include/functions_reporting.php');
set_time_limit (0);
//error_reporting (0);
@ -2321,6 +2321,33 @@ function graph_custom_sql_graph ($id, $width, $height, $type = 1) {
}
function graph_sla_pie ($value1, $value2, $value3, $value4, $width, $height) {
$data_graph = array ();
$data_graph[__('Inside limits')] = $value1;
$data_graph[__('Out of limits')] = $value2;
$data_graph[__('On the edge')] = $value3;
$data_graph[__('Unknown')] = $value4;
generic_pie_graph ($width, $height, $data_graph, array ('show_legend' => true));
}
function graph_sla_horizontal ($progress, $width, $height, $id) {
global $config;
$engine = get_graph_engine ();
$engine->width = $width;
$engine->height = $height;
$engine->fontpath = $config['fontpath'];
$engine->background_color = '#FFFFFF';
$engine->show_title = true;
$engine->title = format_numeric ($progress).' %';
$color = '#2C5196';
$engine->graph_sla_horizontal ($progress, $color);
}
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
@ -2382,6 +2409,7 @@ $draw_alerts = (int) get_parameter ('draw_alerts');
$value1 = get_parameter ('value1');
$value2 = get_parameter ('value2');
$value3 = get_parameter("value3", 0);
$value4 = get_parameter ('value4');
$stacked = get_parameter ("stacked", 0);
$date = get_parameter ("date");
$graphic_type = (string) get_parameter ('tipo');
@ -2514,6 +2542,13 @@ if ($graphic_type) {
case 'sql_graph_pie':
graph_custom_sql_graph ($report_id, $width, $height, 3);
break;
case 'sla_pie_graph':
graph_sla_pie ($value1, $value2, $value3, $value4, $width, $height);
break;
case 'sla_horizontal_graph':
graph_sla_horizontal (20, $width, $height, $id);
break;
case 'graphic_error':
default:

View File

@ -656,6 +656,9 @@ function get_report_types () {
$types['event_report_agent'] = __('Event report agent');
$types['event_report_module'] = __('Event report module');
$types['event_report_group'] = __('Event report group');
$types['general'] = __('General');
$types['top_n'] = __('Top n');
$types['exception'] = __('Exception');
// $types['agent_detailed_event'] = __('Agent detailed event');
// $types['list_events_module'] = __('List events of module');
// $types['list_events_agent'] = __('List events of agent');

View File

@ -405,7 +405,7 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return =
if ($event["id_agente"] > 0) {
// Agent name
$data[4] = print_agent_name ($event["id_agente"], true);
$data[4] = print_agent_name ($event["id_agente"], true, 25, '', true);
// for System or SNMP generated alerts
}
elseif ($event["event_type"] == "system") {

View File

@ -25,6 +25,7 @@
require_once ($config["homedir"]."/include/functions.php");
require_once ($config["homedir"]."/include/functions_db.php");
require_once ($config["homedir"]."/include/functions_agents.php");
include_once ("include/fgraph.php");
/**
@ -1742,6 +1743,7 @@ function get_agent_module_info ($id_agent, $filter = false) {
function render_report_html_item ($content, $table, $report, $mini = false) {
global $config;
global $graphic_type;
if($mini){
$sizh = '';
@ -1779,8 +1781,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[2][0] = 4;
if ($content["description"] != ""){
$table->colspan[2][0] = 4;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -1802,8 +1804,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[2][0] = 4;
if ($content["description"] != "") {
$table->colspan[2][0] = 4;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -1826,8 +1828,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[2][0] = 3;
if ($content["description"] != ""){
$table->colspan[2][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -1855,16 +1857,17 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
break;
case 3:
case 'SLA':
$show_graph = $content['show_graph'];
//RUNNING
$table->style[1] = 'text-align: right';
$data = array ();
$data[0] = $sizh . __('S.L.A.').$sizhfin;
$data[1] = $sizh . human_time_description_raw($content['period']) . $sizhfin;;
$data[1] = $sizh . human_time_description_raw($content['period']) . $sizhfin;
$n = array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -1880,21 +1883,40 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$slas = array ();
}
$data_graph = array ();
$data_graph[__('Inside limits')] = 0;
$data_graph[__('Out of limits')] = 0;
$data_graph[__('On the edge')] = 0;
$data_graph[__('Unknown')] = 0;
$sla_failed = false;
foreach ($slas as $sla) {
//Get the sla_value in % and store it on $sla_value
$sla_value = get_agentmodule_sla ($sla['id_agent_module'], $content['period'],
$sla['sla_min'], $sla['sla_max'], $report["datetime"], $content, $content['time_from'],
$content['time_to']);
if ($sla_value === false) {
$data_graph[__('Unknown')]++;
}
else if ($sla_value <= ($sla['sla_limit']+10) && $sla_value >= ($sla['sla_limit']-10)) {
$data_graph[__('On the edge')]++;
}
else if ($sla_value > ($sla['sla_limit']+10)) {
$data_graph[__('Inside limits')]++;
}
else if ($sla_value < ($sla['sla_limit']-10)) {
$data_graph[__('Out of limits')]++;
}
//Do not show right modules if 'only_display_wrong' is active
if ($content['only_display_wrong'] == 1 && $sla_value >= $sla['sla_limit']) continue;
$data = array ();
$data[0] = '<strong>'.__('Agent')."</strong> : ";
$data[0] .= get_agentmodule_agent_name ($sla['id_agent_module'])."<br />";
$data[0] .= printTruncateText(get_agentmodule_agent_name ($sla['id_agent_module']))."<br />";
$data[0] .= '<strong>'.__('Module')."</strong> : ";
$data[0] .= get_agentmodule_name ($sla['id_agent_module'])."<br />";
$data[0] .= printTruncateText(get_agentmodule_name ($sla['id_agent_module']))."<br />";
$data[0] .= '<strong>'.__('SLA Max. (value)')."</strong> : ";
$data[0] .= $sla['sla_max']."<br />";
$data[0] .= '<strong>'.__('SLA Min. (value)')."</strong> : ";
@ -1928,6 +1950,25 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$table->colspan[$n - 1][0] = 3;
$table->rowstyle[$n - 1] = 'text-align: right';
}
if ($show_graph && !empty($slas)) {
if($config['flash_charts']) {
echo fs_3d_pie_chart ($data_graph, 370, 180);
}
else {
//Display pie graph
echo '<img src="include/fgraph.php?tipo=sla_pie_graph&value1='.$data_graph[__('Inside limits')].
'&value2='.$data_graph[__('Out of limits')].'&value3='.$data_graph[__('On the edge')].
'&value4='.$data_graph[__('Unknown')].'&height=150&width=500">';
}
//Display horizontal bar graphs
/*
foreach ($slas as $sla) {
echo '<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">';
}
*/
}
break;
case 6:
@ -1940,8 +1981,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -1969,13 +2010,13 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
//RUNNING
$data = array ();
$data[0] = $sizh.__('Avg. Value').$sizhfin;
$data[1] = $sizh.$agent_name.' - '.$module_name.$sizhfin;
$data[1] = $sizh.printTruncateText($agent_name).' - '.printTruncateText($module_name).$sizhfin;
$data[2] = $sizh.human_time_description_raw ($content['period']).$sizhfin;
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2003,8 +2044,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2027,8 +2068,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[0][0] = 2;
if ($content["description"] != ""){
$table->colspan[0][0] = 2;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2056,8 +2097,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[0][0] = 2;
if ($content["description"] != ""){
$table->colspan[0][0] = 2;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2085,8 +2126,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2104,8 +2145,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$table->colspan[0][0] = 2;
// Put description at the end of the module (if exists)
$table->colspan[0][0] = 2;
if ($content["description"] != ""){
$table->colspan[0][0] = 2;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2121,8 +2162,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$table->colspan[0][0] = 2;
// Put description at the end of the module (if exists)
$table->colspan[0][0] = 2;
if ($content["description"] != ""){
$table->colspan[0][0] = 2;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2191,8 +2232,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$table->colspan[0][0] = 2;
// Put description at the end of the module (if exists)
$table->colspan[0][0] = 2;
if ($content["description"] != ""){
$table->colspan[0][0] = 2;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2220,8 +2261,9 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data[1] = $sizh . get_group_name($content['id_agent']) . $sizhfin;
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2240,8 +2282,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2259,8 +2301,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2278,8 +2320,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2297,8 +2339,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2321,8 +2363,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2372,8 +2414,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2400,8 +2442,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2428,8 +2470,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2456,8 +2498,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$table->colspan[1][0] = 3;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
@ -2477,6 +2519,556 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$mttr.'</p>';
array_push ($table->data, $data);
break;
case 'general':
$group_by_agent = $content['group_by_agent'];
$order_uptodown = $content['order_uptodown'];
$table->style[1] = 'text-align: right';
$data = array ();
$data[0] = $sizh.__('General').$sizhfin;
$data[1] = $sizh.human_time_description ($content['period']).$sizhfin;
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
}
switch ($group_by_agent) {
//0 means not group by agent
case 0:
$sql = sprintf("select a.id_agent_module, b.nombre as agent_name,
c.nombre as module_name from treport_content_item as a, tagente as b,
tagente_modulo as c where a.id_agent_module = c.id_agente_modulo and
c.id_agente = b.id_agente and id_report_content = %d", $content['id_rc']);
$generals = process_sql ($sql);
if ($generals === false) {
$data = array ();
$table->colspan[2][0] = 3;
$data[0] = __('There are no Agent/Modules defined');
array_push ($table->data, $data);
break;
}
$table1->width = '99%';
$table1->data = array ();
$table1->head = array ();
$table1->head[0] = __('Agent');
$table1->head[1] = __('Module');
$table1->head[2] = __('Value');
$table1->style[0] = 'text-align: center';
$table1->style[1] = 'text-align: center';
$table1->style[2] = 'text-align: center';
$data_avg = array();
foreach ($generals as $key => $row) {
$data_avg[$key] = get_agentmodule_data_average ($row['id_agent_module'], $content['period']);
$id_agent_module[$key] = $row['id_agent_module'];
$agent_name[$key] = $row['agent_name'];
$module_name[$key] = $row['module_name'];
}
if ($order_uptodown == 0 || $order_uptodown == 1 || $order_uptodown == 2) {
switch ($order_uptodown) {
//Descending
case 1:
array_multisort($data_avg, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
//Ascending
case 2:
array_multisort($data_avg, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
}
$i=0;
foreach ($data_avg as $d) {
$data = array();
$data[0] = printTruncateText($agent_name[$i], 30);
$data[1] = printTruncateText($module_name[$i], 30);
$d === false ? $data[2] = '--':$data[2] = $d;
array_push ($table1->data, $data);
$i++;
}
}
elseif ($order_uptodown == 3) {
array_multisort($agent_name, SORT_ASC, $data_avg, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
$i=0;
foreach ($agent_name as $a) {
$data = array();
$data[0] = printTruncateText($agent_name[$i], 30);
$data[1] = printTruncateText($module_name[$i], 30);
$data_avg[$i] === false ? $data[2] = '--':$data[2] = $data_avg[$i];
array_push ($table1->data, $data);
$i++;
}
}
$table->colspan[2][0] = 3;
$data = array();
$data[0] = print_table($table1, true);
array_push ($table->data, $data);
break;
//1 means group by agent
case 1:
//Get the list of agents
$sql_agents = sprintf ("select distinct ta.nombre from tagente as ta,
tagente_modulo as tam, treport_content_item as trci
where ta.id_agente = tam.id_agente and tam.id_agente_modulo = trci.id_agent_module
and trci.id_report_content = %d", $content['id_rc']);
$agent_list = process_sql ($sql_agents);
//Get the list of modules
$sql_modules = sprintf ("select distinct tam.nombre from tagente_modulo as tam,
treport_content_item as trci where tam.id_agente_modulo = trci.id_agent_module
and trci.id_report_content = %d", $content['id_rc']);
$modules_list = process_sql ($sql_modules);
//Get the data
$sql_data = sprintf("select trci.id_agent_module, ta.nombre as agent_name,
tam.nombre as module_name from treport_content_item as trci, tagente as ta,
tagente_modulo as tam where ta.id_agente = tam.id_agente and
tam.id_agente_modulo = trci.id_agent_module
and id_report_content = %d", $content['id_rc']);
$generals = process_sql ($sql_data);
if ($generals === false) {
$data = array ();
$table->colspan[2][0] = 3;
$data[0] = __('There are no Agent/Modules defined');
array_push ($table->data, $data);
break;
}
$table2->width = '99%';
$table2->data = array ();
$table2->head = array ();
$table2->head[0] = __('Agent');
$table2->style[0] = 'text-align: center';
$i = 1;
foreach ($modules_list as $m) {
$table2->head[$i] = printTruncateText($m['nombre'], 20);
$table2->style[$i] = 'text-align: center';
$i++;
}
foreach ($agent_list as $a) {
$data = array();
$data[0] = printTruncateText($a['nombre'], 20);
$i = 1;
foreach ($modules_list as $m) {
foreach ($generals as $g) {
$agent_name = $g['agent_name'];
$module_name = $g['module_name'];
$found = false;
if (strcmp($a['nombre'], $agent_name) == 0 && strcmp($m['nombre'], $module_name) == 0) {
if (get_agentmodule_data_average($g['id_agent_module'], $content['period']) === false)
$data[$i] = '--';
else {
$data[$i] = get_agentmodule_data_average($g['id_agent_module'], $content['period']);
}
$found = true;
}
else {
$data[$i] = '--';
}
if ($found == true) break;
}
$i++;
}
array_push($table2->data, $data);
}
$table->colspan[2][0] = 3;
$data = array();
$data[0] = print_table($table2, true);
array_push ($table->data, $data);
break;
}
if ($content['show_resume'] && count($generals) > 0) {
//Get the first valid value and assign it to $min & $max
$min = false;
$i=0;
do {
$min = get_agentmodule_data_average($generals[$i]['id_agent_module'], $content['period']);
$i++;
} while ($min === false && $i < count($generals));
$max = $min;
$avg = 0;
$length = 0;
foreach ($generals as $g) {
$value = get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
if ($value !== false) {
if ($value > $max) {
$max = $value;
}
if ($value < $min ) {
$min = $value;
}
$avg += $value;
$length++;
}
}
$avg = $avg / $length;
$data_resume = array();
$data_resume[0] = "Max Value: ".$max;
array_push ($table->data, $data_resume);
$data_resume[0] = "Min Value: ".$min;
array_push ($table->data, $data_resume);
$data_resume[0] = "Average Value: ".$avg;
array_push ($table->data, $data_resume);
}
break;
case 'top_n':
$order_uptodown = $content['order_uptodown'];
$top_n = $content['top_n'];
$top_n_value = $content['top_n_value'];
$table->style[1] = 'text-align: right';
$data = array ();
$data[0] = $sizh.__('Top').' '.$content['top_n_value'].$sizhfin;
$data[1] = $sizh.human_time_description ($content['period']).$sizhfin;
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
}
//Get all the related data
$sql = sprintf("select a.id_agent_module, b.nombre as agent_name,
c.nombre as module_name from treport_content_item as a, tagente as b,
tagente_modulo as c where a.id_agent_module = c.id_agente_modulo and
c.id_agente = b.id_agente and id_report_content = %d", $content['id_rc']);
$tops = process_sql ($sql);
if ($tops === false) {
$data = array ();
$table->colspan[2][0] = 3;
$data[0] = __('There are no Agent/Modules defined');
array_push ($table->data, $data);
break;
}
$table1->width = '99%';
$table1->data = array ();
$table1->head = array ();
$table1->head[0] = __('Agent');
$table1->head[1] = __('Module');
$table1->head[2] = __('Value');
$table1->style[0] = 'text-align: center';
$table1->style[1] = 'text-align: center';
$table1->style[2] = 'text-align: center';
$data_top = array();
foreach ($tops as $key => $row) {
switch ($top_n) {
//Max
case 1:
$value = get_agentmodule_data_max ($row['id_agent_module'], $content['period']);
break;
//Min
case 2:
$value = get_agentmodule_data_min ($row['id_agent_module'], $content['period']);
break;
//Nothing or Average
case 0: //If nothing is selected then it will be shown the average data
case 3:
$value = get_agentmodule_data_average ($row['id_agent_module'], $content['period']);
break;
}
//If the returned value from get_agentmodule_data... is false it won't be stored.
if ($value !== false) {
$data_top[$key] = $value;
$id_agent_module[$key] = $row['id_agent_module'];
$agent_name[$key] = $row['agent_name'];
$module_name[$key] = $row['module_name'];
}
}
switch ($top_n) {
//Max
case 1:
array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
//Min
case 2:
array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
//By agent name or without selection
case 0:
case 3:
array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
}
$data_top_values = array ();
$data_top_values['data_top'] = $data_top;
$data_top_values['agent_name'] = $agent_name;
$data_top_values['module_name'] = $module_name;
$data_top_values['id_agent_module'] = $id_agent_module;
array_splice ($data_top, $top_n_value);
array_splice ($agent_name, $top_n_value);
array_splice ($module_name, $top_n_value);
array_splice ($id_agent_module, $top_n_value);
switch ($order_uptodown) {
//Descending
case 1:
array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
//Ascending
case 2:
array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
//By agent name or without selection
case 0:
case 3:
array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
}
if ($order_uptodown == 1 || $order_uptodown == 2) {
$i = 0;
foreach ($data_top as $dt) {
$data = array();
$data[0] = printTruncateText($agent_name[$i], 30);
$data[1] = printTruncateText($module_name[$i], 30);
$data[2] = $dt;
array_push ($table1->data, $data);
$i++;
if ($i >= $top_n_value) break;
}
}
else if ($order_uptodown == 0 || $order_uptodown == 3) {
$i = 0;
foreach ($agent_name as $an) {
$data = array();
$data[0] = printTruncateText($an, 30);
$data[1] = printTruncateText($module_name[$i], 30);
$data[2] = $data_top[$i];
array_push ($table1->data, $data);
$i++;
if ($i >= $top_n_value) break;
}
}
$table->colspan[2][0] = 3;
$data = array();
$data[0] = print_table($table1, true);
array_push ($table->data, $data);
if ($content['show_resume'] && count($data_top_values) > 0) {
//Get the very first not null value
$i=0;
do {
$min = $data_top_values['data_top'][$i];
$i++;
} while ($min === false && $i < count($data_top_values));
$max = $min;
$avg = 0;
$i=0;
foreach ($data_top_values['data_top'] as $key => $dtv) {
if ($dtv < $min) $min = $dtv;
if ($dtv > $max) $max = $dtv;
$avg += $dtv;
$i++;
}
$avg = $avg / $i;
$data_resume = array();
$data_resume[0] = __('Max Value').': '.$max;
array_push ($table->data, $data_resume);
$data_resume[0] = __('Min Value').': '.$min;
array_push ($table->data, $data_resume);
$data_resume[0] = __('Average Value').': '.$avg;
array_push ($table->data, $data_resume);
}
break;
case 'exception':
$order_uptodown = $content['order_uptodown'];
$exception_condition = $content['exception_condition'];
$exception_condition_value = $content['exception_condition_value'];
$table->style[1] = 'text-align: right';
$data = array ();
$data[0] = $sizh.__('Exception');
switch ($exception_condition) {
case 0:
$data[0] .= ' - '.__('Everything');
break;
case 1:
$data[0] .= ' - '.__('Modules over or equal to').' '.$exception_condition_value;
break;
case 2:
$data[0] .= ' - '.__('Modules under').' '.$exception_condition_value;
break;
case 3:
$data[0] .= ' - '.__('Modules at normal status');
break;
case 4:
$data[0] .= ' - '.__('Modules at critial or warning status');
break;
}
$data[0].=$sizhfin;
$data[1] = $sizh.human_time_description ($content['period']).$sizhfin;
array_push ($table->data, $data);
// Put description at the end of the module (if exists)
$table->colspan[1][0] = 3;
if ($content["description"] != ""){
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
}
//Get all the related data
$sql = sprintf("select a.id_agent_module, b.nombre as agent_name,
c.nombre as module_name from treport_content_item as a, tagente as b,
tagente_modulo as c where a.id_agent_module = c.id_agente_modulo and
c.id_agente = b.id_agente and id_report_content = %d", $content['id_rc']);
$exceptions = process_sql ($sql);
if ($exceptions === false) {
$data = array ();
$table->colspan[2][0] = 3;
$data[0] = __('There are no Agent/Modules defined');
array_push ($table->data, $data);
break;
}
$table1->width = '99%';
$table1->data = array ();
$table1->head = array ();
$table1->head[0] = __('Agent');
$table1->head[1] = __('Module');
$table1->head[2] = __('Value');
$table1->style[0] = 'text-align: center';
$table1->style[1] = 'text-align: center';
$table1->style[2] = 'text-align: center';
//Get the very first not null value
$i=0;
do {
$min = get_agentmodule_data_average ($exceptions[$i]['id_agent_module'], $content['period']);
$i++;
} while ($min === false && $i < count($exceptions));
$max = $min;
$avg = 0;
$i=0;
foreach ($exceptions as $exc) {
$value = get_agentmodule_data_average ($exc['id_agent_module'], $content['period']);
if ($value !== false) {
if ($value > $max) $max = $value;
if ($value < $min) $min = $value;
$avg += $value;
$i++;
switch ($exception_condition) {
//Display everything
case 0:
break;
//Display modules over or equal to certain value
case 1:
//Skip modules under 'value'
if ($value < $exception_condition_value) {
continue 2;
}
break;
//Display modules under a certain value
case 2:
//Skip modules over or equal to 'value'
if ($value >= $exception_condition_value) {
continue 2;
}
break;
//Display modules at Normal status
case 3:
//Skip modules without normal status
if (get_agentmodule_status($exc['id_agent_module']) != 0) {
continue 2;
}
break;
//Display modules at critical, warning or unknown status
case 4:
//Skip modules at normal status
if (get_agentmodule_status($exc['id_agent_module']) == 0) {
continue 2;
}
break;
}
$data_exceptions[] = $value;
$id_agent_module[] = $exc['id_agent_module'];
$agent_name[] = $exc['agent_name'];
$module_name[] = $exc['module_name'];
}
}
//$i > 0 means that there is at least one row on the table
if ($i > 0) {
$avg = $avg / $i;
switch ($order_uptodown) {
//Descending
case 1:
array_multisort($data_exceptions, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
//Ascending
case 2:
array_multisort($data_exceptions, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
//By agent name or without selection
case 0:
case 3:
array_multisort($agent_name, SORT_ASC, $data_exceptions, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC);
break;
}
if ($order_uptodown == 1 || $order_uptodown == 2) {
$j=0;
foreach ($data_exceptions as $dex) {
$data = array();
$data[0] = printTruncateText($agent_name[$j], 30);
$data[1] = printTruncateText($module_name[$j], 30);
$data[2] = $dex;
array_push ($table1->data, $data);
$j++;
}
}
else if ($order_uptodown == 0 || $order_uptodown == 3) {
$j=0;
foreach ($agent_name as $an) {
$data = array();
$data[0] = printTruncateText($an, 30);
$data[1] = printTruncateText($module_name[$j], 30);
$data[2] = $data_exceptions[$j];
array_push ($table1->data, $data);
$j++;
}
}
}
$table->colspan[2][0] = 3;
$data = array();
$data[0] = print_table($table1, true);
array_push ($table->data, $data);
if ($content['show_resume'] && $i>0) {
$data_resume = array();
$data_resume[0] = __('Max Value').': '.$max;
array_push ($table->data, $data_resume);
$data_resume[0] = __('Min Value').': '.$min;
array_push ($table->data, $data_resume);
$data_resume[0] = __('Average Value').': '.$avg;
array_push ($table->data, $data_resume);
}
break;
}
}

View File

@ -60,6 +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);
}
function get_graph_engine ($period = 3600) {

View File

@ -651,5 +651,64 @@ class PchartGraph extends PandoraGraphAbstract {
$this->graph->setColorPalette ($a, $color['r'], $color['g'], $color['b']);
}
}
public function graph_sla_horizontal ($value, $color) {
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);
// Round corners defined in global setup
global $config;
if ($config["round_corner"] != 0)
$radius = ($this->height > 18) ? 8 : 0;
else
$radius = 0;
$ratio = 200;
//$ratio = (int) $value / 100 * $this->width;
/* 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));
/* 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']);
}
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 */
for ($i = 0; $i < 7; $i++) {
$this->graph->drawLine (0, $i, 6 - $i, $i, 255, 255, 255);
}
$end = $this->height - 1;
for ($i = 0; $i < 7; $i++) {
$this->graph->drawLine (0, $end - $i, 5 - $i, $end - $i, 255, 255, 255);
}
}
}
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->Stroke ();
}
}
?>

View File

@ -815,6 +815,14 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`saturday` tinyint(1) default 1,
`sunday` tinyint(1) default 1,
`only_display_wrong` tinyint (1) unsigned default 0 not null,
`top_n` INT NOT NULL default 0,
`top_n_value` INT NOT NULL default 10,
`exception_condition` INT NOT NULL default 0,
`exception_condition_value` DOUBLE (18,6) NOT NULL default 0,
`show_resume` INT NOT NULL default 0,
`order_uptodown` INT NOT NULL default 0,
`show_graph` INT NOT NULL default 0,
`group_by_agent` INT NOT NULL default 0,
PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE