2013-01-03 Miguel de Dios <miguel.dedios@artica.es>

* extensions/resource_registration.php,
	extensions/resource_exportation.php,
	operation/events/event_statistics.php,
	operation/events/events_list.php,
	operation/reporting/reporting_viewer.php,
	godmode/reporting/reporting_builder.php,
	godmode/reporting/reporting_builder.item_editor.php,
	include/functions_alerts.php, include/functions_reports.php,
	include/functions_events.php, include/graphs/fgraph.php,
	include/functions_graph.php, include/styles/pandora.css,
	include/functions_reporting.php, include/functions_agents.php: a lot
	of changes and fixes from the branch for the reports.
	
	MERGED FROM PANDORA_4.0




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7351 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-01-03 18:52:21 +00:00
parent 6007bf45ea
commit d99abb39bb
16 changed files with 1630 additions and 451 deletions

View File

@ -1,3 +1,20 @@
2013-01-03 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php,
extensions/resource_exportation.php,
operation/events/event_statistics.php,
operation/events/events_list.php,
operation/reporting/reporting_viewer.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_alerts.php, include/functions_reports.php,
include/functions_events.php, include/graphs/fgraph.php,
include/functions_graph.php, include/styles/pandora.css,
include/functions_reporting.php, include/functions_agents.php: a lot
of changes and fixes from the branch for the reports.
MERGED FROM PANDORA_4.0
2013-01-02 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2013-01-02 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql * extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql

View File

@ -209,6 +209,8 @@ function output_xml_report($id) {
break; break;
case 'alert_report_agent': case 'alert_report_agent':
break; break;
case 'alert_report_group':
break;
case 'url': case 'url':
echo "<url><![CDATA[" . io_safe_output($values["external_source"]) . "]]></url>"; echo "<url><![CDATA[" . io_safe_output($values["external_source"]) . "]]></url>";
break; break;

View File

@ -173,7 +173,7 @@ function process_upload_xml_report($xml, $group_filter = 0) {
case 'simple_baseline_graph': case 'simple_baseline_graph':
break; break;
case 2: case 2:
case 'custom_graph': case 'custom_graph':
case 'automatic_custom_graph': case 'automatic_custom_graph':
$group = db_get_value('id_grupo', 'tgrupo', 'nombre', io_safe_input($item['graph'])); $group = db_get_value('id_grupo', 'tgrupo', 'nombre', io_safe_input($item['graph']));
$values['id_gs'] = $group; $values['id_gs'] = $group;
@ -301,6 +301,8 @@ function process_upload_xml_report($xml, $group_filter = 0) {
break; break;
case 'alert_report_agent': case 'alert_report_agent':
break; break;
case 'alert_report_group':
break;
case 'url': case 'url':
$values["external_source"] = io_safe_input($item['url']); $values["external_source"] = io_safe_input($item['url']);
break; break;

View File

@ -78,6 +78,16 @@ $sla_sorted_by = 0;
$id_agents = ''; $id_agents = '';
$inventory_modules = array(); $inventory_modules = array();
$date = null; $date = null;
//Added for events items
$filter_event_validated = false;
$filter_event_critical = false;
$filter_event_warning = false;
$event_graph_by_agent = false;
$event_graph_by_user_validator = false;
$event_graph_by_criticity = false;
$event_graph_validated_vs_unvalidated = false;
$netflow_filter = 0; $netflow_filter = 0;
$max_values = 0; $max_values = 0;
$resolution = 0; $resolution = 0;
@ -85,7 +95,6 @@ $resolution = 0;
switch ($action) { switch ($action) {
case 'new': case 'new':
$actionParameter = 'save'; $actionParameter = 'save';
$type = get_parameter('type', 'SLA'); $type = get_parameter('type', 'SLA');
$description = null; $description = null;
$sql = null; $sql = null;
@ -93,10 +102,10 @@ switch ($action) {
$show_in_landscape = 0; $show_in_landscape = 0;
$server_name = ''; $server_name = '';
break; break;
case 'save': case 'save':
default: default:
$actionParameter = 'update'; $actionParameter = 'update';
// If we are creating a new report item then clean interface and display creation view // If we are creating a new report item then clean interface and display creation view
$type = get_parameter('type', 'SLA'); $type = get_parameter('type', 'SLA');
switch ($type) { switch ($type) {
@ -118,11 +127,11 @@ switch ($action) {
$server_name = ''; $server_name = '';
$get_data_editor = false; $get_data_editor = false;
break; break;
} }
// Get data to fill editor if type is not SLA, top_n, exception, general // Get data to fill editor if type is not SLA, top_n, exception, general
if ($get_data_editor) { if ($get_data_editor) {
$item = db_get_row_filter('treport_content', array('id_rc' => $idItem)); $item = db_get_row_filter('treport_content', array('id_rc' => $idItem));
$server_name = $item ['server_name']; $server_name = $item ['server_name'];
@ -308,15 +317,40 @@ switch ($action) {
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente' => $item['id_agent'])); $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente' => $item['id_agent']));
$period = $item['period']; $period = $item['period'];
break; break;
case 'alert_report_group':
$description = $item['description'];
$period = $item['period'];
$group = $item['id_group'];
break;
case 'event_report_agent': case 'event_report_agent':
$description = $item['description']; $description = $item['description'];
$idAgent = $item['id_agent']; $idAgent = $item['id_agent'];
$period = $item['period']; $period = $item['period'];
//Added for events items
$filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning'];
$event_graph_by_agent = $style['event_graph_by_agent'];
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
break; break;
case 'event_report_group': case 'event_report_group':
$description = $item['description']; $description = $item['description'];
$period = $item['period']; $period = $item['period'];
$group = $item['id_group']; $group = $item['id_group'];
//Added for events items
$filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning'];
$event_graph_by_agent = $style['event_graph_by_agent'];
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
break; break;
case 'event_report_module': case 'event_report_module':
$description = $item['description']; $description = $item['description'];
@ -333,6 +367,7 @@ switch ($action) {
$show_graph = $item['show_graph']; $show_graph = $item['show_graph'];
break; break;
case 'group_report': case 'group_report':
$description = $item['description'];
$group = $item['id_group']; $group = $item['id_group'];
break; break;
case 'top_n': case 'top_n':
@ -364,6 +399,9 @@ switch ($action) {
$date = $es['date']; $date = $es['date'];
$inventory_modules = $es['inventory_modules']; $inventory_modules = $es['inventory_modules'];
$id_agents = $es['id_agents']; $id_agents = $es['id_agents'];
$idAgent = $es['id_agents'];
$idAgentModule = $inventory_modules;
break; break;
case 'inventory_changes': case 'inventory_changes':
$period = $item['period']; $period = $item['period'];
@ -511,7 +549,7 @@ html_print_input_hidden('id_item', $idItem);
html_print_input_text('max_interval', $max_interval, '', 5, 10); html_print_input_text('max_interval', $max_interval, '', 5, 10);
echo "&nbsp;" . __('Min') . "&nbsp;"; echo "&nbsp;" . __('Min') . "&nbsp;";
html_print_input_text('min_interval', $min_interval, '', 5, 10); html_print_input_text('min_interval', $min_interval, '', 5, 10);
?></td> ?></td>
</tr> </tr>
<tr id="row_only_display_wrong" style="" class="datos"> <tr id="row_only_display_wrong" style="" class="datos">
<td><?php echo __('Only display wrong SLAs');?></td> <td><?php echo __('Only display wrong SLAs');?></td>
@ -548,7 +586,8 @@ html_print_input_hidden('id_item', $idItem);
<tr id="row_group" style="" class="datos"> <tr id="row_group" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Group');?></td> <td style="vertical-align: top;"><?php echo __('Group');?></td>
<td style=""> <td style="">
<?php html_print_select_groups($config['id_user'], "AR", true, 'combo_group', $group, '');?> <?php html_print_select_groups($config['id_user'],
"AR", true, 'combo_group', $group, '');?>
</td> </td>
</tr> </tr>
<tr id="row_module_group" style="" class="datos"> <tr id="row_module_group" style="" class="datos">
@ -618,7 +657,7 @@ html_print_input_hidden('id_item', $idItem);
if ($agent_name_temp === false) if ($agent_name_temp === false)
$agent_name_temp = array(); $agent_name_temp = array();
$result_select = array(); $result_select = array();
foreach ($agent_name_temp as $module_element) { foreach ($agent_name_temp as $module_element) {
$result_select[$module_element['id_agente_modulo']] = $module_element['nombre']; $result_select[$module_element['id_agente_modulo']] = $module_element['nombre'];
@ -652,7 +691,7 @@ html_print_input_hidden('id_item', $idItem);
if ((empty($agents)) || $agents == -1) $agents = array(); if ((empty($agents)) || $agents == -1) $agents = array();
$agents_select = array(); $agents_select = array();
foreach($agents as $a) { foreach ($agents as $a) {
$agents_select[$a['id_agente']] = $a['nombre']; $agents_select[$a['id_agente']] = $a['nombre'];
} }
html_print_select($agents_select, 'id_agents[]', $id_agents, $script = '', __('All'), -1, false, true, true, '', false, "min-width: 180px"); html_print_select($agents_select, 'id_agents[]', $id_agents, $script = '', __('All'), -1, false, true, true, '', false, "min-width: 180px");
@ -664,7 +703,13 @@ html_print_input_hidden('id_item', $idItem);
<td> <td>
<?php <?php
html_print_select(array(), 'inventory_modules[]', '', $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px"); html_print_select(array(), 'inventory_modules[]', '', $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px");
html_print_input_hidden('inventory_modules_selected',implode(',',$inventory_modules)); if (empty($inventory_modules)) {
$array_inventory_modules = array(0 => 0);
}
else {
$array_inventory_modules = implode(',', $inventory_modules);
}
html_print_input_hidden('inventory_modules_selected', $array_inventory_modules);
?> ?>
</td> </td>
</tr> </tr>
@ -672,8 +717,11 @@ html_print_input_hidden('id_item', $idItem);
<td style="vertical-align: top;"><?php echo __('Date'); ?></td> <td style="vertical-align: top;"><?php echo __('Date'); ?></td>
<td style="max-width: 180px"> <td style="max-width: 180px">
<?php <?php
$dates = enterprise_hook('inventory_get_dates',array($idAgentModule, $idAgent, $group)); $dates = enterprise_hook(
if($dates === ENTERPRISE_NOT_HOOK) { 'inventory_get_dates',
array($idAgentModule, $idAgent, $group));
if ($dates === ENTERPRISE_NOT_HOOK) {
$dates = array(); $dates = array();
} }
@ -852,6 +900,35 @@ html_print_input_hidden('id_item', $idItem);
<td><?php echo __('Show resume') . ui_print_help_tip(__('Show a resume table with max, min, average of total modules on the report bottom'), true);?></td> <td><?php echo __('Show resume') . ui_print_help_tip(__('Show a resume table with max, min, average of total modules on the report bottom'), true);?></td>
<td><?php html_print_checkbox('checkbox_show_resume', 1, $show_resume);?></td> <td><?php html_print_checkbox('checkbox_show_resume', 1, $show_resume);?></td>
</tr> </tr>
<tr id="row_event_filter" style="" class="datos">
<td><?php echo __('Event filter'); ?></td>
<td>
<?php
echo __('Validated');
html_print_checkbox ('filter_event_validated', true, $filter_event_validated);
echo __('Critical');
html_print_checkbox ('filter_event_critical', true, $filter_event_critical);
echo __('Warning');
html_print_checkbox ('filter_event_warning', true, $filter_event_warning);
?>
</td>
</tr>
</tr>
<tr id="row_event_graphs" style="" class="datos">
<td><?php echo __('Event graphs'); ?></td>
<td>
<?php
echo __('By agent');
html_print_checkbox ('event_graph_by_agent', true, $event_graph_by_agent);
echo __('By user validator');
html_print_checkbox ('event_graph_by_user_validator', true, $event_graph_by_user_validator);
echo __('By criticity');
html_print_checkbox ('event_graph_by_criticity', true, $event_graph_by_criticity);
echo __('Validated vs unvalidated');
html_print_checkbox ('event_graph_validated_vs_unvalidated', true, $event_graph_validated_vs_unvalidated);
?>
</td>
</tr>
<tr id="row_show_in_two_columns" style="" class="datos"> <tr id="row_show_in_two_columns" style="" class="datos">
<td><?php echo __('Show in two columns');?></td> <td><?php echo __('Show in two columns');?></td>
<td><?php html_print_checkbox('show_in_two_columns', 1, $show_in_two_columns, false, <td><?php html_print_checkbox('show_in_two_columns', 1, $show_in_two_columns, false,
@ -863,8 +940,13 @@ html_print_input_hidden('id_item', $idItem);
</tr> </tr>
<tr id="row_show_in_landscape" style="" class="datos"> <tr id="row_show_in_landscape" style="" class="datos">
<td><?php echo __('Show in landscape');?></td> <td><?php echo __('Show in landscape');?></td>
<td><?php html_print_checkbox('show_in_landscape', 1, $show_in_landscape, false, false, <td>
'if ($(\'input[name=show_in_landscape]\').is(\':checked\')) $(\'input[name=show_in_two_columns]\').attr(\'checked\', false);');?></td> <?php
html_print_checkbox('show_in_landscape', 1,
$show_in_landscape, false, false,
'if ($(\'input[name=show_in_landscape]\').is(\':checked\')) $(\'input[name=show_in_two_columns]\').attr(\'checked\', false);');
?>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -1527,7 +1609,7 @@ function addGeneralRow() {
$(".delete_button", row).attr('href', 'javascript: deleteGeneralRow(' + data['id'] + ');'); $(".delete_button", row).attr('href', 'javascript: deleteGeneralRow(' + data['id'] + ');');
$("#list_general").append($(row).html()); $("#list_general").append($(row).html());
$("input[name=id_agent_general]").val(''); $("input[name=id_agent_general]").val('');
$("input[name=server_name_general]").val(''); $("input[name=server_name_general]").val('');
$("input[name=agent_general]").val(''); $("input[name=agent_general]").val('');
@ -1584,6 +1666,8 @@ function chooseType() {
$("#row_date").hide(); $("#row_date").hide();
$("#row_agent_multi").hide(); $("#row_agent_multi").hide();
$("#row_module_multi").hide(); $("#row_module_multi").hide();
$("#row_event_filter").hide();
$("#row_event_graphs").hide();
$("#row_netflow_filter").hide(); $("#row_netflow_filter").hide();
$("#row_max_values").hide(); $("#row_max_values").hide();
$("#row_resolution").hide(); $("#row_resolution").hide();
@ -1595,6 +1679,8 @@ function chooseType() {
$("#row_servers").show(); $("#row_servers").show();
$("#row_group").show(); $("#row_group").show();
$("#row_show_in_two_columns").show(); $("#row_show_in_two_columns").show();
$("#row_event_filter").show();
$("#row_event_graphs").show();
break; break;
case 'simple_graph': case 'simple_graph':
case 'simple_baseline_graph': case 'simple_baseline_graph':
@ -1622,7 +1708,7 @@ function chooseType() {
$("#row_interval").show(); $("#row_interval").show();
$("#row_show_in_two_columns").show(); $("#row_show_in_two_columns").show();
break; break;
case 'custom_graph': case 'custom_graph':
case 'automatic_custom_graph': case 'automatic_custom_graph':
$("#row_description").show(); $("#row_description").show();
$("#row_period").show(); $("#row_period").show();
@ -1772,6 +1858,12 @@ function chooseType() {
$("#row_period").show(); $("#row_period").show();
$("#row_show_in_two_columns").show(); $("#row_show_in_two_columns").show();
break; break;
case 'alert_report_group':
$("#row_description").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
$("#row_group").show();
break;
case 'alert_report_agent': case 'alert_report_agent':
$("#row_description").show(); $("#row_description").show();
$("#row_agent").show(); $("#row_agent").show();
@ -1783,6 +1875,8 @@ function chooseType() {
$("#row_agent").show(); $("#row_agent").show();
$("#row_period").show(); $("#row_period").show();
$("#row_show_in_two_columns").show(); $("#row_show_in_two_columns").show();
$("#row_event_filter").show();
$("#row_event_graphs").show();
break; break;
case 'event_report_module': case 'event_report_module':
$("#row_description").show(); $("#row_description").show();
@ -1803,6 +1897,7 @@ function chooseType() {
case 'group_report': case 'group_report':
$("#row_group").show(); $("#row_group").show();
$("#row_servers").show(); $("#row_servers").show();
$("#row_description").show();
break; break;
case 'top_n': case 'top_n':
$("#row_description").show(); $("#row_description").show();
@ -1874,7 +1969,8 @@ function chooseType() {
updateInventoryDates(); updateInventoryDates();
}); });
updateInventoryDates(); if (!$("#hidden-date_selected").val())
updateInventoryDates();
break; break;
case 'inventory_changes': case 'inventory_changes':
break; break;

View File

@ -382,6 +382,7 @@ switch ($action) {
} }
foreach ($reports as $report) { foreach ($reports as $report) {
if (!is_user_admin ($config["id_user"])){ if (!is_user_admin ($config["id_user"])){
if ($report["private"] && $report["id_user"] != $config['id_user']) if ($report["private"] && $report["id_user"] != $config['id_user'])
if (!check_acl ($config["id_user"], $report["id_group"], "RR")) if (!check_acl ($config["id_user"], $report["id_group"], "RR"))
@ -414,7 +415,7 @@ switch ($action) {
$next = 6; $next = 6;
} }
if ($report["private"] == 1) if ($report["private"] == 1)
$data[$next] = __('Yes'); $data[$next] = __('Yes');
else else
@ -462,10 +463,10 @@ switch ($action) {
} }
html_print_table ($table); html_print_table ($table);
} }
if (check_acl ($config['id_user'], 0, "RW")) { if (check_acl ($config['id_user'], 0, "RW")) {
echo '<form method="post" action="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=main&action=new&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=main&action=new&pure='.$pure.'">';
echo '<div class="action-buttons" style="width: 98%;">'; echo '<div class="action-buttons" style="width: 98%; margin-top: 5px;">';
html_print_submit_button (__('Create report'), 'create', false, 'class="sub next"'); html_print_submit_button (__('Create report'), 'create', false, 'class="sub next"');
echo "</div>"; echo "</div>";
echo "</form>"; echo "</form>";
@ -485,7 +486,8 @@ switch ($action) {
break; break;
case 'item_editor': case 'item_editor':
$resultOperationDB = null; $resultOperationDB = null;
$report = db_get_row_filter('treport', array('id_report' => $idReport)); $report = db_get_row_filter('treport',
array('id_report' => $idReport));
$reportName = $report['name']; $reportName = $report['name'];
$idGroupReport = $report['id_group']; $idGroupReport = $report['id_group'];
@ -658,7 +660,7 @@ switch ($action) {
$values['top_n_value'] = get_parameter('max_values'); $values['top_n_value'] = get_parameter('max_values');
$good_format = true; $good_format = true;
break; break;
default: default:
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('radiobutton_max_min_avg',0); $values['top_n'] = get_parameter('radiobutton_max_min_avg',0);
$values['top_n_value'] = get_parameter('quantity'); $values['top_n_value'] = get_parameter('quantity');
@ -705,6 +707,14 @@ switch ($action) {
$resultOperationDB = false; $resultOperationDB = false;
break; break;
} }
$filter_event_validated = get_parameter('filter_event_validated', 0);
$filter_event_critical = get_parameter('filter_event_critical', 0);
$filter_event_warning = get_parameter('filter_event_warning', 0);
$event_graph_by_agent = get_parameter('event_graph_by_agent', 0);
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0);
// If metaconsole is activated // If metaconsole is activated
if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { if ($config['metaconsole'] == 1 && defined('METACONSOLE')) {
@ -732,8 +742,9 @@ switch ($action) {
// Will update server_name variable // Will update server_name variable
$values['server_name'] = trim($server_name); $values['server_name'] = trim($server_name);
$agent_name = substr($agent_name_server, 0, $separator_pos); $agent_name = substr($agent_name_server, 0, $separator_pos);
} }
} }
} }
@ -757,9 +768,25 @@ switch ($action) {
$style = array(); $style = array();
$style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0);
$style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0);
switch ($values['type']) {
case 'event_report_agent':
case 'event_report_group':
//Added for events items
$style['filter_event_validated'] = $filter_event_validated;
$style['filter_event_critical'] = $filter_event_critical;
$style['filter_event_warning'] = $filter_event_warning;
$style['event_graph_by_agent'] = $event_graph_by_agent;
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
break;
}
$values['style'] = io_safe_input(json_encode($style)); $values['style'] = io_safe_input(json_encode($style));
if ($good_format){ if ($good_format) {
$resultOperationDB = db_process_sql_update('treport_content', $values, array('id_rc' => $idItem)); $resultOperationDB = db_process_sql_update('treport_content', $values, array('id_rc' => $idItem));
} }
else{ else{
@ -856,7 +883,7 @@ switch ($action) {
break; break;
case "oracle": case "oracle":
$only_display_wrong_tmp = get_parameter('checkbox_only_display_wrong'); $only_display_wrong_tmp = get_parameter('checkbox_only_display_wrong');
if (empty($only_display_wrong_tmp)){ if (empty($only_display_wrong_tmp)) {
$values['only_display_wrong'] = 0; $values['only_display_wrong'] = 0;
} }
else{ else{
@ -932,10 +959,35 @@ switch ($action) {
$style = array(); $style = array();
$style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0);
$style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0);
switch ($values['type']) {
case 'event_report_agent':
case 'event_report_group':
$filter_event_validated = get_parameter('filter_event_validated', 0);
$filter_event_critical = get_parameter('filter_event_critical', 0);
$filter_event_warning = get_parameter('filter_event_warning', 0);
$event_graph_by_agent = get_parameter('event_graph_by_agent', 0);
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0);
//Added for events items
$style['filter_event_validated'] = $filter_event_validated;
$style['filter_event_critical'] = $filter_event_critical;
$style['filter_event_warning'] = $filter_event_warning;
$style['event_graph_by_agent'] = $event_graph_by_agent;
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
break;
}
$values['style'] = io_safe_input(json_encode($style)); $values['style'] = io_safe_input(json_encode($style));
if ($good_format) { if ($good_format) {
$result = db_process_sql_insert('treport_content', $values); $result = db_process_sql_insert(
'treport_content', $values);
if ($result === false) { if ($result === false) {
$resultOperationDB = false; $resultOperationDB = false;
@ -945,13 +997,17 @@ switch ($action) {
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$max = db_get_all_rows_sql('SELECT max(`order`) AS max $max = db_get_all_rows_sql(
FROM treport_content WHERE id_report = ' . $idReport . ';'); 'SELECT max(`order`) AS max
FROM treport_content
WHERE id_report = ' . $idReport . ';');
break; break;
case "postgresql": case "postgresql":
case "oracle": case "oracle":
$max = db_get_all_rows_sql('SELECT max("order") AS max $max = db_get_all_rows_sql(
FROM treport_content WHERE id_report = ' . $idReport); 'SELECT max("order") AS max
FROM treport_content
WHERE id_report = ' . $idReport);
break; break;
} }
if ($max === false) { if ($max === false) {
@ -980,7 +1036,6 @@ switch ($action) {
} }
break; break;
default: default:
if ($enterpriseEnable and $activeTab != 'advanced') { if ($enterpriseEnable and $activeTab != 'advanced') {
$resultOperationDB = reporting_enterprise_update_action(); $resultOperationDB = reporting_enterprise_update_action();
} }

View File

@ -42,6 +42,17 @@ function agents_check_agent_exists($id_agent, $show_disabled = true) {
} }
} }
/**
* Get agent id from a module id that it has.
*
* @param int $id_module Id module is list modules this agent.
*
* @return int Id from the agent of the given id module.
*/
function agents_get_agent_id_by_module_id ($id_agente_modulo) {
return (int) db_get_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_agente_modulo);
}
/** /**
* Creates an agent * Creates an agent
* *

View File

@ -1699,6 +1699,7 @@ function get_agent_alert_fired ($id_agent, $id_alert, $period, $date = 0) {
* @return array An array with all the events happened. * @return array An array with all the events happened.
*/ */
function get_module_alert_fired ($id_agent_module, $id_alert, $period, $date = 0) { function get_module_alert_fired ($id_agent_module, $id_alert, $period, $date = 0) {
if (!is_numeric ($date)) { if (!is_numeric ($date)) {
$date = strtotime ($date); $date = strtotime ($date);
} }

File diff suppressed because it is too large Load Diff

View File

@ -118,54 +118,62 @@ function get_statwin_graph_statistics ($chart_array, $series_suffix = '') {
//Get minimum //Get minimum
if ($stats['sum']['min'] == null) { if ($stats['sum']['min'] == null) {
$stats['sum']['min'] = $item['sum']; $stats['sum']['min'] = $item['sum'];
} else if ($item['sum'] < $stats['sum']['min']) { }
else if ($item['sum'] < $stats['sum']['min']) {
$stats['sum']['min'] = $item['sum']; $stats['sum']['min'] = $item['sum'];
} }
//Get maximum //Get maximum
if ($stats['sum']['max'] == null) { if ($stats['sum']['max'] == null) {
$stats['sum']['max'] = $item['sum']; $stats['sum']['max'] = $item['sum'];
} else if ($item['sum'] > $stats['sum']['max']) { }
else if ($item['sum'] > $stats['sum']['max']) {
$stats['sum']['max'] = $item['sum']; $stats['sum']['max'] = $item['sum'];
} }
} }
//Get stats for min graph //Get stats for min graph
if (isset($item['min']) && $item['min']) { if (isset($item['min']) && $item['min']) {
//Sum all values later divide by the number of elements //Sum all values later divide by the number of elements
$stats['min']['avg'] = $stats['min']['avg'] + $item['min']; $stats['min']['avg'] = $stats['min']['avg'] + $item['min'];
//Get minimum //Get minimum
if ($stats['min']['min'] == null) { if ($stats['min']['min'] == null) {
$stats['min']['min'] = $item['min']; $stats['min']['min'] = $item['min'];
} else if ($item['min'] < $stats['min']['min']) { }
else if ($item['min'] < $stats['min']['min']) {
$stats['min']['min'] = $item['min']; $stats['min']['min'] = $item['min'];
} }
//Get maximum //Get maximum
if ($stats['min']['max'] == null) { if ($stats['min']['max'] == null) {
$stats['min']['max'] = $item['min']; $stats['min']['max'] = $item['min'];
} else if ($item['min'] > $stats['min']['max']) { }
else if ($item['min'] > $stats['min']['max']) {
$stats['min']['max'] = $item['min']; $stats['min']['max'] = $item['min'];
} }
} }
//Get stats for max graph //Get stats for max graph
if (isset($item['max']) && $item['max']) { if (isset($item['max']) && $item['max']) {
//Sum all values later divide by the number of elements //Sum all values later divide by the number of elements
$stats['max']['avg'] = $stats['max']['avg'] + $item['max']; $stats['max']['avg'] = $stats['max']['avg'] + $item['max'];
//Get minimum //Get minimum
if ($stats['max']['min'] == null) { if ($stats['max']['min'] == null) {
$stats['max']['min'] = $item['max']; $stats['max']['min'] = $item['max'];
} else if ($item['max'] < $stats['max']['min']) { }
else if ($item['max'] < $stats['max']['min']) {
$stats['max']['min'] = $item['max']; $stats['max']['min'] = $item['max'];
} }
//Get maximum //Get maximum
if ($stats['max']['max'] == null) { if ($stats['max']['max'] == null) {
$stats['max']['max'] = $item['max']; $stats['max']['max'] = $item['max'];
} else if ($item['max'] > $stats['max']['max']) { }
else if ($item['max'] > $stats['max']['max']) {
$stats['max']['max'] = $item['max']; $stats['max']['max'] = $item['max'];
} }
} }
@ -192,7 +200,7 @@ function get_statwin_graph_statistics ($chart_array, $series_suffix = '') {
//End the calculus for average //End the calculus for average
if ($count > 0) { if ($count > 0) {
$stats['sum']['avg'] = $stats['sum']['avg'] / $count; $stats['sum']['avg'] = $stats['sum']['avg'] / $count;
$stats['min']['avg'] = $stats['min']['avg'] / $count; $stats['min']['avg'] = $stats['min']['avg'] / $count;
$stats['max']['avg'] = $stats['max']['avg'] / $count; $stats['max']['avg'] = $stats['max']['avg'] / $count;
@ -445,7 +453,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$baseline = 0, $return_data = 0, $show_title = true, $projection = false, $baseline = 0, $return_data = 0, $show_title = true, $projection = false,
$adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '', $adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '',
$show_unknown = false) { $show_unknown = false) {
global $config; global $config;
global $chart; global $chart;
global $color; global $color;
@ -465,7 +473,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$warning_min = 0; $warning_min = 0;
$critical_min = 0; $critical_min = 0;
$start_unknown = false; $start_unknown = false;
// Set variables // Set variables
if ($date == 0) $date = get_system_time(); if ($date == 0) $date = get_system_time();
$datelimit = $date - $period; $datelimit = $date - $period;
@ -626,19 +634,19 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
// Only show caption if graph is not small // Only show caption if graph is not small
if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT) if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT)
//Flash chart //Flash chart
$caption = __('Max. Value').$series_suffix_str . ': ' . $graph_stats['sum']['max'] . ' ' . __('Avg. Value').$series_suffix_str . ': ' . $graph_stats['sum']['avg'] . ' ' . __('Min. Value').$series_suffix_str . ': ' . $graph_stats['sum']['min'] . ' ' . __('Units. Value').$series_suffix_str . ': ' . $unit; $caption = __('Max. Value') . $series_suffix_str . ': ' . $graph_stats['sum']['max'] . ' ' . __('Avg. Value').$series_suffix_str . ': ' . $graph_stats['sum']['avg'] . ' ' . __('Min. Value').$series_suffix_str . ': ' . $graph_stats['sum']['min'] . ' ' . __('Units. Value').$series_suffix_str . ': ' . $unit;
else else
$caption = array(); $caption = array();
/////// ///////
// Color commented not to restrict serie colors // Color commented not to restrict serie colors
if($show_events) { if ($show_events) {
$color['event'.$series_suffix] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50); $color['event'.$series_suffix] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
} }
if($show_alerts) { if ($show_alerts) {
$color['alert'.$series_suffix] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50); $color['alert'.$series_suffix] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
} }
if($show_unknown) { if ($show_unknown) {
$color['unknown'.$series_suffix] = array('border' => '#999999', 'color' => '#999999', 'alpha' => 50); $color['unknown'.$series_suffix] = array('border' => '#999999', 'color' => '#999999', 'alpha' => 50);
} }
$color['max'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50); $color['max'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
@ -652,7 +660,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$legend['event'.$series_suffix_str] = __('Events').$series_suffix_str; $legend['event'.$series_suffix_str] = __('Events').$series_suffix_str;
$chart_extra_data['legend_events'] = $legend['event'].$series_suffix_str; $chart_extra_data['legend_events'] = $legend['event'].$series_suffix_str;
} }
if($show_alerts) { if ($show_alerts) {
$legend['alert'.$series_suffix] = __('Alerts').$series_suffix_str; $legend['alert'.$series_suffix] = __('Alerts').$series_suffix_str;
$chart_extra_data['legend_alerts'] = $legend['alert'.$series_suffix_str]; $chart_extra_data['legend_alerts'] = $legend['alert'.$series_suffix_str];
} }
@ -677,10 +685,10 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
function grafico_modulo_sparse ($agent_module_id, $period, $show_events, function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$width, $height , $title = '', $unit_name = null, $width, $height , $title = '', $unit_name = null,
$show_alerts = false, $avg_only = 0, $pure = false, $show_alerts = false, $avg_only = 0, $pure = false,
$date = 0, $unit = '', $baseline = 0, $return_data = 0, $date = 0, $unit = '', $baseline = 0, $return_data = 0,
$show_title = true, $only_image = false, $homeurl = '', $ttl = 1, $show_title = true, $only_image = false, $homeurl = '', $ttl = 1,
$projection = false, $adapt_key = '', $compare = false, $show_unknown = false) { $projection = false, $adapt_key = '', $compare = false, $show_unknown = false) {
global $config; global $config;
global $graphic_type; global $graphic_type;
@ -705,8 +713,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$width, $height, $title, $unit_name, $width, $height, $title, $unit_name,
$show_alerts, $avg_only, $date-$period, $unit, $baseline, $return_data, $show_alerts, $avg_only,
$show_title, $projection, $adapt_key, $compare, $date-$period, $unit, $baseline, $return_data, $show_title,
$projection, $adapt_key, $compare,
$series_suffix, $series_suffix_str, $show_unknown); $series_suffix, $series_suffix_str, $show_unknown);
switch($compare) { switch($compare) {
@ -730,8 +739,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
// Build the data of the current period // Build the data of the current period
$data_returned = grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $data_returned = grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$width, $height , $title, $unit_name, $width, $height , $title, $unit_name,
$show_alerts, $avg_only, $date, $unit, $baseline, $show_alerts, $avg_only,
$return_data, $show_title, $projection, $adapt_key, $compare, '', '', $show_unknown); $date, $unit, $baseline, $return_data, $show_title,
$projection, $adapt_key, $compare, '', '', $show_unknown);
if ($return_data) { if ($return_data) {
return $data_returned; return $data_returned;
@ -762,8 +772,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$long_index, ui_get_full_url("images/image_problem.opaque.png"), "", $unit, $homeurl, $long_index, ui_get_full_url("images/image_problem.opaque.png"), "", $unit, $homeurl,
$water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl,
$series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false, $series_suffix_str). $series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false, $series_suffix_str).
'<br>'. '<br>'.
area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev, area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev,
$long_index_prev, ui_get_full_url("images/image_problem.opaque.png"), "", $unit, $homeurl, $long_index_prev, ui_get_full_url("images/image_problem.opaque.png"), "", $unit, $homeurl,
$water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl,
$series_type_prev, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false, $series_suffix_str); $series_type_prev, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false, $series_suffix_str);
@ -1200,7 +1210,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
//Work around for fixed the agents name with huge size chars. //Work around for fixed the agents name with huge size chars.
$fixed_font_size = $config['font_size'] - 1; $fixed_font_size = $config['font_size'] - 1;
//Set graph color //Set graph color
$color = array(); $color = array();
@ -1479,12 +1489,16 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
// All data (now) // All data (now)
$time["all"] = get_system_time (); $time["all"] = get_system_time ();
// 1 day ago // 1 day ago
$time["1day"] = $time["all"] - SECONDS_1DAY; $time["1day"] = $time["all"] - SECONDS_1DAY;
// 1 week ago // 1 week ago
$time["1week"] = $time["all"] - SECONDS_1WEEK; $time["1week"] = $time["all"] - SECONDS_1WEEK;
// 1 month ago // 1 month ago
$time["1month"] = $time["all"] - SECONDS_1MONTH; $time["1month"] = $time["all"] - SECONDS_1MONTH;
// Three months ago // Three months ago
$time["3month"] = $time["all"] - SECONDS_3MONTHS; $time["3month"] = $time["all"] - SECONDS_3MONTHS;
@ -1856,15 +1870,16 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
global $config; global $config;
global $graphic_type; global $graphic_type;
$url = html_entity_decode (rawurldecode ($url), ENT_QUOTES); //It was urlencoded, so we urldecode it //It was urlencoded, so we urldecode it
$url = html_entity_decode (rawurldecode ($url), ENT_QUOTES);
$data = array (); $data = array ();
$loop = 0; $loop = 0;
define ('NUM_PIECES_PIE', 6); define ('NUM_PIECES_PIE', 6);
$badstrings = array (";", "SELECT ", "DELETE ", "UPDATE ", "INSERT ", "EXEC"); $badstrings = array (";", "SELECT ", "DELETE ", "UPDATE ", "INSERT ", "EXEC");
//remove bad strings from the query so queries like ; DELETE FROM don't pass //remove bad strings from the query so queries like ; DELETE FROM don't pass
$url = str_ireplace ($badstrings, "", $url); $url = str_ireplace ($badstrings, "", $url);
// Choose the table where search if metaconsole or not // Choose the table where search if metaconsole or not
if($meta) { if($meta) {
$event_table = 'tmetaconsole_event'; $event_table = 'tmetaconsole_event';
@ -1912,15 +1927,15 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
if (!check_acl ($config["id_user"], $row["id_grupo"], "ER") == 1) if (!check_acl ($config["id_user"], $row["id_grupo"], "ER") == 1)
continue; continue;
if ($loop >= NUM_PIECES_PIE) { if ($loop >= NUM_PIECES_PIE) {
$other_events += $row["count"]; $other_events += $row["count"];
} }
else { else {
if ($row["id_agente"] == 0) { if ($row["id_agente"] == 0) {
$system_events += $row["count"]; $system_events += $row["count"];
} }
else { else {
if($meta) { if ($meta) {
$name = mb_substr (io_safe_output($row['agent_name']), 0, 14)." (".$row["count"].")"; $name = mb_substr (io_safe_output($row['agent_name']), 0, 14)." (".$row["count"].")";
} }
else { else {
@ -1932,12 +1947,12 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
$loop++; $loop++;
} }
if($system_events > 0) { if ($system_events > 0) {
$name = __('SYSTEM')." (".$system_events.")"; $name = __('SYSTEM')." (".$system_events.")";
$data[$name] = $system_events; $data[$name] = $system_events;
} }
if($other_events > 0) { if ($other_events > 0) {
$name = __('Other')." (".$other_events.")"; $name = __('Other')." (".$other_events.")";
$data[$name] = $other_events; $data[$name] = $other_events;
} }
@ -1967,31 +1982,36 @@ function grafico_eventos_total($filter = "") {
$legend = array (); $legend = array ();
$total = 0; $total = 0;
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE criticity = 0 $filter"; $sql = "SELECT COUNT(id_evento)
FROM tevento WHERE criticity = 0 $filter";
$data[__('Maintenance')] = db_get_sql ($sql); $data[__('Maintenance')] = db_get_sql ($sql);
if ($data[__('Maintenance')] == 0) { if ($data[__('Maintenance')] == 0) {
unset($data[__('Maintenance')]); unset($data[__('Maintenance')]);
} }
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE criticity = 1 $filter"; $sql = "SELECT COUNT(id_evento)
FROM tevento WHERE criticity = 1 $filter";
$data[__('Informational')] = db_get_sql ($sql); $data[__('Informational')] = db_get_sql ($sql);
if ($data[__('Informational')] == 0) { if ($data[__('Informational')] == 0) {
unset($data[__('Informational')]); unset($data[__('Informational')]);
} }
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE criticity = 2 $filter"; $sql = "SELECT COUNT(id_evento)
FROM tevento WHERE criticity = 2 $filter";
$data[__('Normal')] = db_get_sql ($sql); $data[__('Normal')] = db_get_sql ($sql);
if ($data[__('Normal')] == 0) { if ($data[__('Normal')] == 0) {
unset($data[__('Normal')]); unset($data[__('Normal')]);
} }
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE criticity = 3 $filter"; $sql = "SELECT COUNT(id_evento)
FROM tevento WHERE criticity = 3 $filter";
$data[__('Warning')] = db_get_sql ($sql); $data[__('Warning')] = db_get_sql ($sql);
if ($data[__('Warning')] == 0) { if ($data[__('Warning')] == 0) {
unset($data[__('Warning')]); unset($data[__('Warning')]);
} }
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE criticity = 4 $filter"; $sql = "SELECT COUNT(id_evento)
FROM tevento WHERE criticity = 4 $filter";
$data[__('Critical')] = db_get_sql ($sql); $data[__('Critical')] = db_get_sql ($sql);
if ($data[__('Critical')] == 0) { if ($data[__('Critical')] == 0) {
unset($data[__('Critical')]); unset($data[__('Critical')]);
@ -2187,7 +2207,7 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho
$full_legend[$name] = $name;; $full_legend[$name] = $name;;
$top = $datelimit + ($periodtime * ($i + 1)); $top = $datelimit + ($periodtime * ($i + 1));
$event = db_get_row_filter ('tevento', $event = db_get_row_filter ('tevento',
array ('id_agente' => $id_agent, array ('id_agente' => $id_agent,
'utimestamp > '.$bottom, 'utimestamp > '.$bottom,
'utimestamp < '.$top), 'criticity, utimestamp'); 'utimestamp < '.$top), 'criticity, utimestamp');
@ -2240,8 +2260,8 @@ function fs_error_image () {
} }
function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
$unit_name, $show_alerts, $avg_only = 0, $date = 0, $series_suffix = '', $unit_name, $show_alerts, $avg_only = 0,
$series_suffix_str = '', $show_unknown = false) { $date = 0, $series_suffix = '', $series_suffix_str = '', $show_unknown = false) {
global $config; global $config;
global $chart; global $chart;
@ -2280,7 +2300,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
"utimestamp < $date", "utimestamp < $date",
'order' => 'utimestamp ASC'), 'order' => 'utimestamp ASC'),
array ('evento', 'utimestamp', 'event_type', 'id_evento')); array ('evento', 'utimestamp', 'event_type', 'id_evento'));
// Get the last event after inverval to know if graph start on unknown // Get the last event after inverval to know if graph start on unknown
$prev_event = db_get_row_filter ('tevento', $prev_event = db_get_row_filter ('tevento',
array ('id_agentmodule' => $agent_module_id, array ('id_agentmodule' => $agent_module_id,
@ -2532,9 +2552,9 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
if(!empty($alert_ids)) { if(!empty($alert_ids)) {
$chart_extra_data[count($chart)-1]['alerts'] = implode(',',$alert_ids); $chart_extra_data[count($chart)-1]['alerts'] = implode(',',$alert_ids);
} }
}
}
// Get min, max and avg (less efficient but centralized for all modules and reports) // Get min, max and avg (less efficient but centralized for all modules and reports)
$graph_stats = get_statwin_graph_statistics($chart, $series_suffix); $graph_stats = get_statwin_graph_statistics($chart, $series_suffix);
@ -2599,7 +2619,8 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
$legend['sum'.$series_suffix] = __('Data').$series_suffix_str.': '.__('Last').': '.$graph_stats['sum']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['sum']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['sum']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['sum']['min'].' '.$unit; $legend['sum'.$series_suffix] = __('Data').$series_suffix_str.': '.__('Last').': '.$graph_stats['sum']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['sum']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['sum']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['sum']['min'].' '.$unit;
//Boolean graph doesn't have min!!! //Boolean graph doesn't have min!!!
//$legend['min'.$series_suffix] = __('Min').$series_suffix_str .': '.__('Last').': '.$graph_stats['min']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['min']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['min']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['min']['min'].' '.$unit; //$legend['min'.$series_suffix] = __('Min').$series_suffix_str .': '.__('Last').': '.$graph_stats['min']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['min']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['min']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['min']['min'].' '.$unit;
} else { }
else {
$legend['sum'.$series_suffix] = __('Data').$series_suffix_str.': '.__('Last').': '.$graph_stats['sum']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['sum']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['sum']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['sum']['min'].' '.$unit; $legend['sum'.$series_suffix] = __('Data').$series_suffix_str.': '.__('Last').': '.$graph_stats['sum']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['sum']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['sum']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['sum']['min'].' '.$unit;
} }
@ -2732,7 +2753,7 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $unit =
elseif ($period < SECONDS_1MONTH) { elseif ($period < SECONDS_1MONTH) {
$chart_time_format = 'M d H\h'; $chart_time_format = 'M d H\h';
} }
else { else {
$chart_time_format = 'M d H\h'; $chart_time_format = 'M d H\h';
} }
@ -2887,8 +2908,8 @@ function graph_netflow_aggregate_pie ($data, $aggregate, $ttl = 1, $only_image =
* @param integer date date * @param integer date date
*/ */
function grafico_modulo_string ($agent_module_id, $period, $show_events, function grafico_modulo_string ($agent_module_id, $period, $show_events,
$width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0, $width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0,
$date = 0, $only_image = false, $homeurl = '', $adapt_key) { $date = 0, $only_image = false, $homeurl = '', $adapt_key) {
global $config; global $config;
global $graphic_type; global $graphic_type;
@ -3029,7 +3050,7 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
elseif ($period < SECONDS_1MONTH) { elseif ($period < SECONDS_1MONTH) {
$time_format = 'M d H\h'; $time_format = 'M d H\h';
} }
else { else {
$time_format = 'M d H\h'; $time_format = 'M d H\h';
} }
@ -3078,16 +3099,16 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
$color = array(); $color = array();
if($show_events) { if($show_events) {
$color['event'.$series_suffix] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50); $color['event'.$series_suffix] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
} }
if($show_alerts) { if($show_alerts) {
$color['alert'.$series_suffix] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50); $color['alert'.$series_suffix] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
} }
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50); $color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50); $color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50); $color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
//$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10); //$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
@ -3099,7 +3120,7 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$legend = array(); $legend = array();
if($show_events) { if($show_events) {
$legend['event'] = __('Events'); $legend['event'] = __('Events');
} }
@ -3244,7 +3265,7 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu
$pixels_between_xdata = 25; $pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata); $max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($data); $ndata = count($data);
if($max_xdata_display > $ndata) { if ($max_xdata_display > $ndata) {
$xdata_display = $ndata; $xdata_display = $ndata;
} }
else { else {
@ -3253,10 +3274,10 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu
$step = round($ndata/$xdata_display); $step = round($ndata/$xdata_display);
$colors = array(1 => '#38B800', 2 => '#FFFF00', 3 => '#FF0000', 4 => '#C3C3C3'); $colors = array(1 => '#38B800', 2 => '#FFFF00', 3 => '#FF0000', 4 => '#C3C3C3');
// Draw slicebar graph // Draw slicebar graph
if($config['flash_charts']) { if ($config['flash_charts']) {
echo flot_slicesbar_graph($data, $period, $width, 15, $legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', $adapt_key); echo flot_slicesbar_graph($data, $period, $width, 15, $legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', $adapt_key);
} }
else { else {
@ -3610,6 +3631,7 @@ function grafico_modulo_log4x_format_y_axis ( $number , $decimals=2, $dec_point=
break; break;
default: default:
return ""; return "";
break;
} }
} }
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -454,7 +454,7 @@ function get_report_type_data_source ($type) {
return 'module'; return 'module';
break; break;
case 2: case 2:
case 'custom_graph': case 'custom_graph':
case 'automatic_custom_graph': case 'automatic_custom_graph':
return 'custom-graph'; return 'custom-graph';
break; break;
@ -583,6 +583,8 @@ function reports_get_report_types ($template = false, $not_editor = false) {
'name' => __('Alert report module')); 'name' => __('Alert report module'));
$types['alert_report_agent'] = array('optgroup' => __('Alerts'), $types['alert_report_agent'] = array('optgroup' => __('Alerts'),
'name' => __('Alert report agent')); 'name' => __('Alert report agent'));
$types['alert_report_group'] = array('optgroup' => __('Alerts'),
'name' => __('Alert report group'));

View File

@ -248,7 +248,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
} }
if (empty($chart_data)) { if (empty($chart_data)) {
return '<img src="'.$no_data_image.'">'; return '<img src="' . $no_data_image . '" />';
} }
if ($flash_chart) { if ($flash_chart) {
@ -268,7 +268,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$graph['font_size'] = $font_size; $graph['font_size'] = $font_size;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . ui_get_full_url (false, false, false, false) . "include/graphs/functions_pchart.php?static_graph=1&graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>"; return "<img src='" . ui_get_full_url (false, false, false, false) . "include/graphs/functions_pchart.php?static_graph=1&graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
} }
} }
@ -280,7 +280,7 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) { if (empty($chart_data)) {
return '<img src="'.$no_data_image.'">'; return '<img src="' . $no_data_image . '" />';
} }
if($flash_chart) { if($flash_chart) {
@ -315,7 +315,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) { if (empty($chart_data)) {
return '<img src="'.$no_data_image.'">'; return '<img src="' . $no_data_image . '" />';
} }
if($flash_chart) { if($flash_chart) {
@ -350,7 +350,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) { if (empty($chart_data)) {
return '<img src="'.$no_data_image.'">'; return '<img src="' . $no_data_image . '" />';
} }
if($flash_chart) { if($flash_chart) {
@ -377,7 +377,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
function kiviat_graph($graph_type, $flash_chart, $chart_data, $width, $height, $no_data_image, $ttl = 1, $homedir="") { function kiviat_graph($graph_type, $flash_chart, $chart_data, $width, $height, $no_data_image, $ttl = 1, $homedir="") {
if (empty($chart_data)) { if (empty($chart_data)) {
return '<img src="'.$no_data_image.'">'; return '<img src="' . $no_data_image . '" />';
} }
$graph = array(); $graph = array();
@ -447,7 +447,7 @@ function pie2d_graph($flash_chart, $chart_data, $width, $height,
function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height, function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
$others_str = "other", $homedir="", $water_mark = "", $font = '', $font_size = '', $ttl = 1) { $others_str = "other", $homedir="", $water_mark = "", $font = '', $font_size = '', $ttl = 1) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
// This library allows only 8 colors // This library allows only 8 colors
@ -471,7 +471,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
$chart_data = $chart_data_trunc; $chart_data = $chart_data_trunc;
} }
if($flash_chart) { if ($flash_chart) {
return flot_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height, $water_mark_url, $font, $font_size); return flot_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height, $water_mark_url, $font, $font_size);
} }
else { else {
@ -482,14 +482,14 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
$graph['water_mark'] = $water_mark_file; $graph['water_mark'] = $water_mark_file;
$graph['font'] = $font; $graph['font'] = $font;
$graph['font_size'] = $font_size; $graph['font_size'] = $font_size;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
switch($graph_type) { switch($graph_type) {
case "2d": case "2d":
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=pie2d&ttl=".$ttl."&id_graph=".$id_graph."'>"; return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=pie2d&ttl=".$ttl."&id_graph=".$id_graph."'>";
break; break;
case "3d": case "3d":
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=pie3d&ttl=".$ttl."&id_graph=".$id_graph."'>"; return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=pie3d&ttl=".$ttl."&id_graph=".$id_graph."'>";
break; break;
} }

View File

@ -62,7 +62,7 @@ div#main {
} }
@media screen and (max-width: 1024px) { /* Specific to this particular image */ @media screen and (max-width: 1024px) { /* Specific to this particular image */
#login_body { #login_body {
left: 50%; left: 50%;
margin-left: -512px; /* 50% */ margin-left: -512px; /* 50% */
} }
@ -1482,11 +1482,17 @@ tfoot.scwFoot {
/* Cells divs to set individual styles with the table objects */ /* Cells divs to set individual styles with the table objects */
div.cellBold { div.cellBold {
width:100%; width: 100%;
height:100%; height: 100%;
font-weight: bold; font-weight: bold;
} }
div.cellRight {
width: 100%;
height: 100%;
text-align: right;
}
div.cellCenter { div.cellCenter {
width:100%; width:100%;
height:100%; height:100%;
@ -1494,63 +1500,63 @@ div.cellCenter {
} }
div.cellWhite { div.cellWhite {
width:100%; width: 100%;
height:100%; height: 100%;
background: #fff; background: #fff;
color: #000; color: #000;
} }
div.cellNormal { div.cellNormal {
width:100%; width: 100%;
height:100%; height: 100%;
background: #008e00; background: #008e00;
color: #fff; color: #fff;
} }
div.cellCritical { div.cellCritical {
width:100%; width: 100%;
height:100%; height: 100%;
background: #cc0000; background: #cc0000;
color: #fff; color: #fff;
} }
div.cellWarning { div.cellWarning {
width:100%; width: 100%;
height:100%; height: 100%;
background: #fce94f; background: #fce94f;
color: #000; color: #000;
} }
div.cellUnknown { div.cellUnknown {
width:100%; width: 100%;
height:100%; height: 100%;
background: #babdb6; background: #babdb6;
color: #000; color: #000;
} }
div.cellNotInit { div.cellNotInit {
width:100%; width: 100%;
height:100%; height: 100%;
background: #729fcf; background: #729fcf;
color: #000; color: #000;
} }
div.cellAlert { div.cellAlert {
width:100%; width: 100%;
height:100%; height: 100%;
background: #ffa300; background: #ffa300;
color: #000; color: #000;
} }
div.cellBorder1 { div.cellBorder1 {
width:100%; width: 100%;
height:100%; height: 100%;
border: 1px solid black; border: 1px solid black;
} }
div.cellBig { div.cellBig {
width:100%; width: 100%;
height:100%; height: 100%;
font-size: 18px; font-size: 18px;
} }

View File

@ -31,19 +31,32 @@ if (! check_acl ($config['id_user'], 0, "ER")) {
//header //header
ui_print_page_header (__('Statistics'), "images/lightning_go.png",false, false); ui_print_page_header (__('Statistics'), "images/lightning_go.png",false, false);
echo "<table width=95%>"; echo "<table width=95%>";
echo "<tr><td valign='top'>"; echo "<tr>";
echo "<h3>".__('Event graph')."</h3>";
echo "<td valign='top'>";
echo "<h3>" . __('Event graph') . "</h3>";
echo grafico_eventos_total(); echo grafico_eventos_total();
echo "</td>";
echo "</td><td valign='top'>"; echo "<td valign='top'>";
echo "<h3>".__('Event graph by user')."</h3>"; echo "<h3>" . __('Event graph by user') . "</h3>";
echo grafico_eventos_usuario(300, 200); echo grafico_eventos_usuario(300, 200);
echo "</td>";
echo "</td></tr>"; echo "</tr>";
echo "<tr><td>";
echo "<h3>".__('Event graph by group')."</h3>"; echo "<tr>";
echo "<td>";
echo "<h3>" . __('Event graph by group') . "</h3>";
echo grafico_eventos_grupo(300, 200); echo grafico_eventos_grupo(300, 200);
echo "</td>";
echo '</td></tr>'; echo "<td>";
echo "<h3>" . __('Amount events validated') . "</h3>";
echo graph_events_validated(300, 200);
echo "</td>";
echo "</tr>";
echo "</table>"; echo "</table>";
?> ?>

View File

@ -168,7 +168,8 @@ else {
} }
else { else {
//Otherwise select all groups the user has rights to. //Otherwise select all groups the user has rights to.
$sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")"; $sql_post = " AND id_grupo IN (" .
implode (",", array_keys ($groups)) . ")";
} }
} }
@ -181,7 +182,7 @@ switch ($status) {
case 0: case 0:
case 1: case 1:
case 2: case 2:
$sql_post .= " AND estado = ".$status; $sql_post .= " AND estado = " . $status;
break; break;
case 3: case 3:
$sql_post .= " AND (estado = 0 OR estado = 2)"; $sql_post .= " AND (estado = 0 OR estado = 2)";
@ -189,7 +190,7 @@ switch ($status) {
} }
if ($search != "") { if ($search != "") {
$sql_post .= " AND evento LIKE '%".io_safe_input($search)."%'"; $sql_post .= " AND evento LIKE '%" . io_safe_input($search) . "%'";
} }
if ($event_type != "") { if ($event_type != "") {
@ -568,13 +569,13 @@ else {
if ($group_rep == 0) { if ($group_rep == 0) {
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$sql = "SELECT * $sql = "SELECT *, 1 event_rep
FROM $event_table FROM $event_table
WHERE 1=1 ".$sql_post." WHERE 1=1 ".$sql_post."
ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination;
break; break;
case "postgresql": case "postgresql":
$sql = "SELECT * $sql = "SELECT *, 1 event_rep
FROM $event_table FROM $event_table
WHERE 1=1 ".$sql_post." WHERE 1=1 ".$sql_post."
ORDER BY utimestamp DESC LIMIT ".$pagination." OFFSET ".$offset; ORDER BY utimestamp DESC LIMIT ".$pagination." OFFSET ".$offset;
@ -583,7 +584,7 @@ if ($group_rep == 0) {
$set = array(); $set = array();
$set['limit'] = $pagination; $set['limit'] = $pagination;
$set['offset'] = $offset; $set['offset'] = $offset;
$sql = "SELECT * $sql = "SELECT *, 1 event_rep
FROM $event_table FROM $event_table
WHERE 1=1 ".$sql_post." WHERE 1=1 ".$sql_post."
ORDER BY utimestamp DESC"; ORDER BY utimestamp DESC";

View File

@ -221,7 +221,7 @@ $(document).ready (function () {
<?php <?php
if ($datetime === false || $datetime == -1) { if ($datetime === false || $datetime == -1) {
echo '<h3 class="error">'.__('Invalid date selected').'</h3>'; echo '<h3 class="error">' . __('Invalid date selected') . '</h3>';
return; return;
} }
@ -239,13 +239,16 @@ $report["group_name"] = groups_get_name ($report['id_group']);
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$contents = db_get_all_rows_field_filter ("treport_content", "id_report", $id_report, "`order`"); $contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, "`order`");
break; break;
case "postgresql": case "postgresql":
$contents = db_get_all_rows_field_filter ("treport_content", "id_report", $id_report, '"order"'); $contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break; break;
case "oracle": case "oracle":
$contents = db_get_all_rows_field_filter ("treport_content", "id_report", $id_report, '"order"'); $contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break; break;
} }
if ($contents === false) { if ($contents === false) {
@ -272,7 +275,7 @@ foreach ($contents as $content) {
if ($content['type'] == 'agent_module') if ($content['type'] == 'agent_module')
echo '<div style="width: 99%; overflow: auto;">'; echo '<div style="width: 99%; overflow: auto;">';
html_print_table ($table); html_print_table ($table);
if ($content['type'] == 'agent_module') if ($content['type'] == 'agent_module')