From 5d1088dfa919a4c70fc1d889e6ef1f617c5dd57d Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Wed, 15 Mar 2017 17:18:53 +0100 Subject: [PATCH 001/121] Fixed problems with backgrounds when add visual console in dashboards. Gitlab: #533 --- .../include/functions_visual_map.php | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index ad38e4a4e9..6941e435ba 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -2434,12 +2434,9 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $proportion_height = 0; $proportion_width = 0; - - if (!is_null($height) && !is_null($width)) { $resizedMap = true; - if ($keep_aspect_ratio) { $ratio = min($width / $layout['width'], $height / $layout['height']); $mapWidth = $ratio * $layout['width']; @@ -2453,49 +2450,48 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $dif_height = $layout["height"] - $mapHeight; $dif_width = $layout["width"] - $mapWidth; - $proportion_height = $mapHeight / $layout["height"]; $proportion_width = $mapWidth / $layout["width"]; - - if (is_metaconsole()) { - $backgroundImage = - '/include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . - $config['homeurl'] . 'images/console/background/' . - $layout["background"]; - } - else { - $backgroundImage = - '/include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . - $config['homedir'] . '/images/console/background/' . - ($layout["background"]); + if ($layout["background"] != 'None.png' ) { + if (is_metaconsole()) { + $backgroundImage = + '/include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . + $config['homeurl'] . 'images/console/background/' . + $layout["background"]; + } + else { + $backgroundImage = + '/include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . + $config['homedir'] . '/images/console/background/' . + ($layout["background"]); + } } } else { $mapWidth = $layout["width"]; $mapHeight = $layout["height"]; - $backgroundImage = $metaconsole_hack . 'images/console/background/' . - $layout["background"]; + $backgroundImage = ''; + if ($layout["background"] != 'None.png' ) + $backgroundImage = $metaconsole_hack . 'images/console/background/' . + $layout["background"]; } if (defined('METACONSOLE')) { echo "
"; } - echo '
'; - echo ""; + height:' . $mapHeight . 'px; + background-color:'.$layout["background_color"].';">'; + + if ($layout["background"] != 'None.png' ) + echo ""; $layout_datas = db_get_all_rows_field_filter('tlayout_data', From d7dcd7f339bdd1ab71cdb8e9b1e7d4bc6c638bb7 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 16 Mar 2017 12:23:43 +0100 Subject: [PATCH 002/121] Modified Zombie processes local_component --- pandora_console/pandoradb_data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 711f72cd67..f02d94197a 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1086,7 +1086,7 @@ INSERT INTO `tlocal_component` (`id`, `name`, `data`, `description`, `id_os`, `o INSERT INTO `tlocal_component` (`id`, `name`, `data`, `description`, `id_os`, `os_version`, `id_network_component_group`, `type`, `max`, `min`, `module_interval`, `id_module_group`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `post_process`, `unit`, `wizard_level`, `macros`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `critical_inverse`, `warning_inverse`, `id_category`, `tags`, `disabled_types_event`, `min_ff_event_normal`, `min_ff_event_warning`, `min_ff_event_critical`, `each_ff`, `ff_timeout`, `dynamic_interval`, `dynamic_max`, `dynamic_min`, `prediction_sample_window`, `prediction_samples`, `prediction_threshold`) VALUES (54,'InetdDaemon','module_begin module_name InetdDaemon module_type generic_proc module_exec ps -Af | grep inetd | grep -v "grep" | wc -l | awk '{ print $1 }' module_end ','Check inetddaemon running in system',3,'',46,2,0,0,0,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,0.000000000000000,NULL,'basic',NULL,'','','',0,0,0,'','',0,0,0,0,0,0,0,0,0,0,0); INSERT INTO `tlocal_component` (`id`, `name`, `data`, `description`, `id_os`, `os_version`, `id_network_component_group`, `type`, `max`, `min`, `module_interval`, `id_module_group`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `post_process`, `unit`, `wizard_level`, `macros`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `critical_inverse`, `warning_inverse`, `id_category`, `tags`, `disabled_types_event`, `min_ff_event_normal`, `min_ff_event_warning`, `min_ff_event_critical`, `each_ff`, `ff_timeout`, `dynamic_interval`, `dynamic_max`, `dynamic_min`, `prediction_sample_window`, `prediction_samples`, `prediction_threshold`) VALUES (55,'disk_root_free','module_begin module_name disk_root_free module_type generic_data module_exec df -k / | tail -1 | awk '{ print 100-$4 }' module_max 100 module_min 0 module_description Free disk Percentage of root partition module_end','Free disk Percentage of root partition',3,'',46,1,0,0,0,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,0.000000000000000,NULL,'basic',NULL,'','','',0,0,0,'','',0,0,0,0,0,0,0,0,0,0,0); INSERT INTO `tlocal_component` (`id`, `name`, `data`, `description`, `id_os`, `os_version`, `id_network_component_group`, `type`, `max`, `min`, `module_interval`, `id_module_group`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `post_process`, `unit`, `wizard_level`, `macros`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `critical_inverse`, `warning_inverse`, `id_category`, `tags`, `disabled_types_event`, `min_ff_event_normal`, `min_ff_event_warning`, `min_ff_event_critical`, `each_ff`, `ff_timeout`, `dynamic_interval`, `dynamic_max`, `dynamic_min`, `prediction_sample_window`, `prediction_samples`, `prediction_threshold`) VALUES (56,'OpenedFiles ','module_begin module_name OpenedFiles module_type generic_data module_exec lsof | wc -l module_description Total files opened in system module_end ','Total files opened in system ',1,'',43,1,0,0,0,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,0.000000000000000,NULL,'basic',NULL,'','','',0,0,0,'','',0,0,0,0,0,0,0,0,0,0,0); -INSERT INTO `tlocal_component` (`id`, `name`, `data`, `description`, `id_os`, `os_version`, `id_network_component_group`, `type`, `max`, `min`, `module_interval`, `id_module_group`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `post_process`, `unit`, `wizard_level`, `macros`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `critical_inverse`, `warning_inverse`, `id_category`, `tags`, `disabled_types_event`, `min_ff_event_normal`, `min_ff_event_warning`, `min_ff_event_critical`, `each_ff`, `ff_timeout`, `dynamic_interval`, `dynamic_max`, `dynamic_min`, `prediction_sample_window`, `prediction_samples`, `prediction_threshold`) VALUES (57,'Zombie processes','module_begin module_name Zombie processes module_type generic_data module_exec ps ­eos | grep Z | wc ­l | tr ­d “\n” module_description Number of zombie processes module_end ','Number of zombie processes ',1,'',43,1,0,0,0,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,0.000000000000000,NULL,'basic',NULL,'','','',0,0,0,'','',0,0,0,0,0,0,0,0,0,0,0); +INSERT INTO `tlocal_component` (`id`, `name`, `data`, `description`, `id_os`, `os_version`, `id_network_component_group`, `type`, `max`, `min`, `module_interval`, `id_module_group`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `post_process`, `unit`, `wizard_level`, `macros`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `critical_inverse`, `warning_inverse`, `id_category`, `tags`, `disabled_types_event`, `min_ff_event_normal`, `min_ff_event_warning`, `min_ff_event_critical`, `each_ff`, `ff_timeout`, `dynamic_interval`, `dynamic_max`, `dynamic_min`, `prediction_sample_window`, `prediction_samples`, `prediction_threshold`) VALUES (57,'Zombie processes','module_begin module_name Zombie processes module_type generic_data module_exec ps -eos | grep 'Z' | wc -l | tr -d "\n" module_description Number of zombie processes module_end ','Number of zombie processes ',1,'',43,1,0,0,0,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,0.000000000000000,NULL,'basic',NULL,'','','',0,0,0,'','',0,0,0,0,0,0,0,0,0,0,0); INSERT INTO `tlocal_component` (`id`, `name`, `data`, `description`, `id_os`, `os_version`, `id_network_component_group`, `type`, `max`, `min`, `module_interval`, `id_module_group`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `post_process`, `unit`, `wizard_level`, `macros`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `critical_inverse`, `warning_inverse`, `id_category`, `tags`, `disabled_types_event`, `min_ff_event_normal`, `min_ff_event_warning`, `min_ff_event_critical`, `each_ff`, `ff_timeout`, `dynamic_interval`, `dynamic_max`, `dynamic_min`, `prediction_sample_window`, `prediction_samples`, `prediction_threshold`) VALUES (58,'Disk_IO_Wait','module_begin module_name Disk_IO_Wait module_type generic_data module_exec top -n 3 -c | grep "Cpu" | awk '{ print $6 }' | grep -o "[0-9]*" | tail -1 module_description Simple approach to IO/Wait monitoring. module_end ','Simple approach to IO/Wait monitoring. ',1,'',43,1,0,0,0,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,0.000000000000000,NULL,'basic',NULL,'','','',0,0,0,'','',0,0,0,0,0,0,0,0,0,0,0); -- GIS Data From 65033788f05550d90f2358d5f9bf274f35f1c485 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 17 Mar 2017 09:37:10 +0100 Subject: [PATCH 003/121] Added macro _agentos_ --- pandora_console/include/help/en/help_alert_macros.php | 1 + pandora_console/include/help/es/help_alert_macros.php | 1 + pandora_console/include/help/ja/help_alert_macros.php | 1 + pandora_server/lib/PandoraFMS/Core.pm | 1 + pandora_server/lib/PandoraFMS/DB.pm | 11 +++++++++++ 5 files changed, 15 insertions(+) diff --git a/pandora_console/include/help/en/help_alert_macros.php b/pandora_console/include/help/en/help_alert_macros.php index 6753e2c59a..544fd5ec36 100644 --- a/pandora_console/include/help/en/help_alert_macros.php +++ b/pandora_console/include/help/en/help_alert_macros.php @@ -25,6 +25,7 @@ Besides the defined module macros, the following macros are available:
  • _agentdescription_: Description of the agent that triggered the alert.
  • _agentgroup_: Agent’s group name.
  • _agentstatus_: Current agent status.
  • +
  • _agentos_: Agent's operative system.
  • _address_: Address of the agent that triggered the alert.
  • _timestamp_: Time and date on which the alert was triggered (yy-mm-dd hh:mm:ss).
  • _timezone_: Timezone that is represented on _timestamp_.
  • diff --git a/pandora_console/include/help/es/help_alert_macros.php b/pandora_console/include/help/es/help_alert_macros.php index f4c8f476d9..335d583d5a 100644 --- a/pandora_console/include/help/es/help_alert_macros.php +++ b/pandora_console/include/help/es/help_alert_macros.php @@ -25,6 +25,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
  • _agentdescription_: Descripción del agente que disparó la alerta.
  • _agentgroup_: Nombre del grupo del agente.
  • _agentstatus_: Estado actual del agente.
  • +
  • _agentos_: Sistema operativo del agente.
  • _address_: Dirección del agente que disparó la alerta.
  • _timestamp_: Hora y fecha en que se disparó la alerta.
  • _timezone_: Area Nombre _timestamp_ que representa en.
  • diff --git a/pandora_console/include/help/ja/help_alert_macros.php b/pandora_console/include/help/ja/help_alert_macros.php index 15b892651c..cd1e2534cf 100644 --- a/pandora_console/include/help/ja/help_alert_macros.php +++ b/pandora_console/include/help/ja/help_alert_macros.php @@ -25,6 +25,7 @@
  • _agentdescription_ : 発生したアラートの説明
  • _agentgroup_ : エージェントグループ名
  • _agentstatus_ : エージェントの現在の状態
  • +
  • _agentos_: Agent's operative system
  • _address_ : アラートが発生したエージェントのアドレス
  • _timestamp_ : アラートが発生した日時 (yy-mm-dd hh:mm:ss).
  • _timezone_: _timestamp_ で使用されるタイムゾーン名.
  • diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 19717beae2..ad58be775a 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -980,6 +980,7 @@ sub pandora_execute_action ($$$$$$$$$;$) { _agentdescription_ => (defined ($agent)) ? $agent->{'comentarios'} : '', _agentgroup_ => (defined ($group)) ? $group->{'nombre'} : '', _agentstatus_ => undef, + _agentos_ => (defined ($agent)) ? get_os_name($dbh, $agent->{'id_os'}) : '', _address_ => (defined ($agent)) ? $agent->{'direccion'} : '', _timestamp_ => (defined($timestamp)) ? $timestamp : strftime ("%Y-%m-%d %H:%M:%S", localtime()), _timezone_ => strftime ("%Z", localtime()), diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 1c831e3b02..7774048357 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -72,6 +72,7 @@ our @EXPORT = qw( get_module_name get_nc_profile_name get_os_id + get_os_name get_plugin_id get_profile_id get_priority_name @@ -249,6 +250,16 @@ sub get_os_id ($$) { return defined ($rc) ? $rc : -1; } +######################################################################## +## Return OS name given the OS id. +######################################################################## +sub get_os_name ($$) { + my ($dbh, $os_id) = @_; + + my $rc = get_db_value ($dbh, "SELECT name FROM tconfig_os WHERE id_os = ?", $os_id); + return defined ($rc) ? $rc : -1; +} + ########################################################################## ## SUB get_agent_name (agent_id) ## Return agent group id, given "agent_id" From 62541482ab438947d97460508db8d5bf1f119423 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Wed, 22 Mar 2017 10:10:56 +0100 Subject: [PATCH 004/121] Filter custom graph size in visual console editor, autoset size - #99 --- pandora_console/general/cg_items.php | 7 +++ .../visual_console_builder.editor.js | 36 ++++++++++++++ .../include/functions_visual_map_editor.php | 48 ++++++++++++++++++- .../include/graphs/functions_flot.php | 2 +- .../operation/visual_console/render_view.php | 5 +- 5 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 pandora_console/general/cg_items.php diff --git a/pandora_console/general/cg_items.php b/pandora_console/general/cg_items.php new file mode 100644 index 0000000000..bb76299e07 --- /dev/null +++ b/pandora_console/general/cg_items.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index dbca48c15c..268720fb80 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -298,6 +298,26 @@ function update_button_palette_callback() { break; case 'module_graph': + + if($('#dir_items').html() == 'horizontal'){ + if(parseInt($('#text-left').val()) + (parseInt($('input[name=height_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('width')) + || parseInt($('#text-left').val()) + (parseInt($('input[name=width_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('width'))){ + + alert($('#count_items').html()+' joined graph items are wider than background'); + return false; + + } + } + + if($('#dir_items').html() == 'vertical'){ + if(parseInt($('#text-top').val()) + (parseInt($('input[name=height_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('height'))){ + alert($('#count_items').html()+' joined graph items are higher than background'); + return false; + + } + } + + if($('input[name=width_module_graph]').val() == ''){ alert('Undefined width'); return false; @@ -1151,6 +1171,8 @@ function loadFieldsFromDB(item) { }); + $('#count_items').html(1); + if (data.type == 6 || data.type == 7 || data.type == 8 || data.type == 1) { $("#period_row." + item).css('display', ''); @@ -1169,6 +1191,20 @@ function loadFieldsFromDB(item) { } else { + + jQuery.get ("ajax.php", + {"page": "general/cg_items","data": data.id_custom_graph}, + function (data, status) { + if(data.split(",")[0] == 4){ + $('#count_items').html(data.split(",")[1]); + $('#dir_items').html('vertical'); + } + else if (data.split(",")[0] == 5) { + $('#count_items').html(data.split(",")[1]); + $('#dir_items').html('horizontal'); + + } + }); $("input[name='radio_choice'][value='custom_graph']") .prop('checked', true); diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 8fa3306927..47ce7665ce 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -446,7 +446,10 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { html_print_input_text('width_module_graph', 300, '', 3, 5, true) . ' X ' . html_print_input_text('height_module_graph', 180, '', 3, 5, true) . - ''; + ' X ' . + '1 '. + ' item/s + '; //Insert and modify before the buttons to create or update. @@ -587,6 +590,49 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $(".border_color").attachColorPicker(); $(".fill_color").attachColorPicker(); $(".line_color").attachColorPicker(); + + $("input[name=radio_choice]").change(function(){ + $('#count_items').html(1); + }); + + $("#custom_graph").click(function(){ + $('#count_items').html(1); + jQuery.get ("ajax.php", + {"page": "general/cg_items","data": $(this).val()}, + function (data, status) { + if(data.split(",")[0] == 8){ + size = 400+(data.split(",")[1] * 50); + if(data.split(",")[1]>3){ + size = 400+(3 * 50); + } + $('#text-width_module_graph').val(size); + $('#text-height_module_graph').val(180); + + } + else if (data.split(",")[0] == 4) { + size = data.split(",")[1]; + if(data.split(",")[1] > 1){ + $('#count_items').html(data.split(",")[1]); + $('#dir_items').html('vertical'); + } + $('#text-width_module_graph').val(300); + $('#text-height_module_graph').val(50); + } + else if (data.split(",")[0] == 5) { + size = data.split(",")[1]; + if(data.split(",")[1] > 1){ + $('#count_items').html(data.split(",")[1]); + $('#dir_items').html('horizontal'); + } + $('#text-width_module_graph').val(100); + $('#text-height_module_graph').val(100); + } + + }); + + }); + + });
    "; + $return = "
    "; if ($water_mark != '') { $return .= ""; diff --git a/pandora_console/operation/visual_console/render_view.php b/pandora_console/operation/visual_console/render_view.php index fa507a1d55..5aff41f3e2 100755 --- a/pandora_console/operation/visual_console/render_view.php +++ b/pandora_console/operation/visual_console/render_view.php @@ -302,9 +302,8 @@ $ignored_params['refr'] = ''; } }); - $(".graph").each(function(){ - height = parseInt($(this).css("height")) - 30; - + $(".graph:not([class~='noresizevc'])").each(function(){ + height = parseInt($(this).css("height")) - 30; $(this).css('height', height); }); From c014e00f336f5abd5f18892ff88bc7305b95dd11 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 22 Mar 2017 11:30:41 +0100 Subject: [PATCH 005/121] Fit thresholds on module graphs --- .../include/graphs/flot/pandora.flot.js | 109 +++++++++++++++--- 1 file changed, 92 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index b6f1eb2308..f6fc5e8baf 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -1649,8 +1649,21 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, if (thresholded) { var zoom_data_threshold = new Array (); + var y_recal = axis_thresholded(threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, + red_threshold, extremes, red_up); + plot = $.plot($('#' + graph_id), data_base, + $.extend(true, {}, options, { + yaxis: { + max: y_recal.max, + min: y_recal.min + }, + xaxis: { + min: plot.getAxes().xaxis.min, + max: plot.getAxes().xaxis.max + } + })); zoom_data_threshold = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, - yellow_threshold, red_threshold, extremes, red_up); + red_threshold, extremes, red_up); plot.setData(zoom_data_threshold); plot.draw(); } @@ -1931,28 +1944,32 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, plot = $.plot($('#' + graph_id), data_base, $.extend(true, {}, options, { yaxis: {max: max_draw}, + xaxis: { + min: plot.getAxes().xaxis.min, + max: plot.getAxes().xaxis.max + } })); thresholded = false; } else { var max_draw = plot.getAxes().yaxis.datamax; - if (max_draw < red_threshold || max_draw < yellow_threshold) { - - var maxim_data = (red_threshold < yellow_threshold) ? yellow_threshold : red_threshold - - plot = $.plot($('#' + graph_id), data_base, - $.extend(true, {}, options, { - yaxis: {max: maxim_data + (maxim_data*0.5)}, - })); - } else { - plot = $.plot($('#' + graph_id), data_base, - $.extend(true, {}, options, { - yaxis: {max: plot.getAxes().yaxis.max}, - })); - } + // Recalculate the y axis + var y_recal = axis_thresholded(threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, + red_threshold, extremes, red_up); + plot = $.plot($('#' + graph_id), data_base, + $.extend(true, {}, options, { + yaxis: { + max: y_recal.max, + min: y_recal.min + }, + xaxis: { + min: plot.getAxes().xaxis.min, + max: plot.getAxes().xaxis.max + } + })); datas = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, - yellow_threshold, red_threshold, extremes, red_up); + red_threshold, extremes, red_up); thresholded = true; } @@ -2143,7 +2160,65 @@ function number_format(number, force_integer, unit) { return number + ' ' + shorts[pos] + unit; } -function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshold, +// Recalculate the threshold data depends on warning and critical +function axis_thresholded (threshold_data, y_min, y_max, red_threshold, extremes, red_up) { + + var y = { + min: 0, + max: 0 + }; + + // Default values + var yaxis_resize = { + up: null, + normal_up: 0, + normal_down: 0, + down: null + }; + // Resize the y axis to display all intervals + $.each(threshold_data, function() { + if (/_up/.test(this.id)){ + yaxis_resize['up'] = this.data[0][1]; + } + if (/_down/.test(this.id)){ + if (/critical/.test(this.id)) { + yaxis_resize['down'] = red_threshold; + } else { + yaxis_resize['down'] = extremes[this.id]; + } + } + if (/_normal/.test(this.id)){ + var end; + if (/critical/.test(this.id)) { + end = red_up; + } else { + end = extremes[this.id + '_2']; + } + if (yaxis_resize['normal_up'] < end) yaxis_resize['normal_up'] = end; + if (yaxis_resize['normal_down'] > this.data[0][1]) yaxis_resize['normal_down'] = this.data[0][1]; + } + }); + + // If you need to display a up or a down bar, display 10% of data height + var margin_up_or_down = (y_max - y_min)*0.10; + + // Calculate the new axis + y['max'] = yaxis_resize['normal_up'] > y_max ? yaxis_resize['normal_up'] : y_max; + y['min'] = yaxis_resize['normal_down'] > y_min ? yaxis_resize['normal_down'] : y_min; + if (yaxis_resize['up'] !== null) { + y['max'] = (yaxis_resize['up'] + margin_up_or_down) < y_max + ? y_max + : yaxis_resize['up'] + margin_up_or_down; + } + if (yaxis_resize['down'] !== null) { + y['min'] = (yaxis_resize['down'] - margin_up_or_down) < y_min + ? yaxis_resize['up'] + margin_up_or_down + : y_min; + } + + return y; +} +function add_threshold (data_base, threshold_data, y_min, y_max, red_threshold, extremes, red_up) { var datas = new Array (); From e2567f7b6a23ca764611774960040f54c3847a39 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Wed, 22 Mar 2017 12:06:29 +0100 Subject: [PATCH 006/121] Resolve jquery library bug (holagram dashboard) - #546 --- .../include/javascript/jquery.jquery-ui-1.10.0.custom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/jquery.jquery-ui-1.10.0.custom.js b/pandora_console/include/javascript/jquery.jquery-ui-1.10.0.custom.js index bfdf34624b..97f51207c8 100755 --- a/pandora_console/include/javascript/jquery.jquery-ui-1.10.0.custom.js +++ b/pandora_console/include/javascript/jquery.jquery-ui-1.10.0.custom.js @@ -5727,7 +5727,7 @@ $.widget( "ui.dialog", { if ( !$( event.target ).closest(".ui-dialog").length ) { event.preventDefault(); $(".ui-dialog:visible:last .ui-dialog-content") - .data("ui-dialog")._focusTabbable(); + .data("ui-dialog"); } } }); From 22af4e703a300978c001886696ceb2a9e33b8447 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Thu, 23 Mar 2017 10:31:04 +0100 Subject: [PATCH 007/121] Alert in sound console with snmp alerts events - #38 --- pandora_console/include/functions_alerts.php | 21 ++++++++++++++------ pandora_console/operation/events/events.php | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 2b166cd331..8e87eee5b3 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -145,10 +145,22 @@ function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query = else { $temp = array(); foreach ($type as $item) { - $temp[] = '"' . $item . '"'; + array_push ( $temp , $item ); } - $typeWhere = ' AND event_type IN (' . implode(',', $temp) . ')'; + $typeWhere = ' AND event_type IN ('; + + foreach ($temp as $ele) { + $typeWhere .= "'".$ele."'"; + + if($ele != end($temp)){ + $typeWhere .= ","; + } + + } + + $typeWhere .= ')'; + } if ($agents == null) { @@ -160,14 +172,11 @@ function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query = else { $idAgents = array_values($agents); - if($type=='alert_fired'){ - $idAgents = array_keys($agents); - } } $result = db_get_all_rows_sql('SELECT id_evento FROM tevento - WHERE estado = 0 AND id_agente IN (' . implode(',', $idAgents) . ') ' . $typeWhere . $query . ' + WHERE estado = 0 AND id_agente IN (0,' . implode(',', $idAgents) . ') ' . $typeWhere . $query . ' ORDER BY id_evento DESC LIMIT 1'); if ($result === false) { diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 29abba5543..52d0abfe8f 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -139,7 +139,7 @@ if (is_ajax ()) { $alert = get_parameter('alert_fired'); if ($alert == 'true') { $resultAlert = alerts_get_event_status_group($idGroup, - 'alert_fired', $query, $agents); + array('alert_fired','alert_ceased'), $query, $agents); } $critical = get_parameter('critical'); if ($critical == 'true') { From 0660d28ed3211a9ec361a0d1345220cd85f6c041 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 23 Mar 2017 11:54:04 +0100 Subject: [PATCH 008/121] Fixed pdf netflow reports --- pandora_console/include/functions_graph.php | 2 +- .../include/functions_reporting.php | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index d5e5fa9bb2..8582655e82 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4242,7 +4242,7 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $unit = $sources, array (), ui_get_full_url("images/image_problem.opaque.png", false, false, false), "", $unit, $homeurl, $config['homedir'] . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size'], $unit, 2); + $config['fontpath'], $config['font_size'], $unit, $ttl); } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 8927d87420..3d05c2099f 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -311,7 +311,8 @@ function reporting_make_reporting_data($report = null, $id_report, $type, $force_width_chart, $force_height_chart, - 'netflow_area'); + 'netflow_area', + $pdf); break; case 'netflow_pie': $report['contents'][] = reporting_netflow( @@ -320,7 +321,8 @@ function reporting_make_reporting_data($report = null, $id_report, $type, $force_width_chart, $force_height_chart, - 'netflow_pie'); + 'netflow_pie', + $pdf); break; case 'netflow_data': $report['contents'][] = reporting_netflow( @@ -329,7 +331,8 @@ function reporting_make_reporting_data($report = null, $id_report, $type, $force_width_chart, $force_height_chart, - 'netflow_data'); + 'netflow_data', + $pdf); break; case 'netflow_statistics': $report['contents'][] = reporting_netflow( @@ -338,7 +341,8 @@ function reporting_make_reporting_data($report = null, $id_report, $type, $force_width_chart, $force_height_chart, - 'netflow_statistics'); + 'netflow_statistics', + $pdf); break; case 'netflow_summary': $report['contents'][] = reporting_netflow( @@ -347,7 +351,8 @@ function reporting_make_reporting_data($report = null, $id_report, $type, $force_width_chart, $force_height_chart, - 'netflow_summary'); + 'netflow_summary', + $pdf); break; case 'monitor_report': $report['contents'][] = reporting_monitor_report( @@ -3241,7 +3246,7 @@ function reporting_monitor_report($report, $content) { } function reporting_netflow($report, $content, $type, - $force_width_chart, $force_height_chart, $type_netflow = null) { + $force_width_chart, $force_height_chart, $type_netflow = null, $pdf = false) { global $config; @@ -3315,7 +3320,7 @@ function reporting_netflow($report, $content, $type, $filter, $content['top_n_value'], $content ['server_name'], - 'HTML'); + $pdf ? 'PDF' : 'HTML'); break; case 'data': break; From 0b6227b1bfe5336a9d2c21724cba9a3b179956c9 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Thu, 23 Mar 2017 15:53:05 +0100 Subject: [PATCH 009/121] Change strings in minor release update manager / open - #486 --- .../godmode/update_manager/update_manager.offline.php | 2 +- pandora_console/include/functions_update_manager.php | 2 +- pandora_console/include/javascript/update_manager.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/update_manager/update_manager.offline.php b/pandora_console/godmode/update_manager/update_manager.offline.php index bd2591f0e1..c6843034f3 100644 --- a/pandora_console/godmode/update_manager/update_manager.offline.php +++ b/pandora_console/godmode/update_manager/update_manager.offline.php @@ -45,7 +45,7 @@ $baseurl = ui_get_full_url(false, false, false, false); var mr_available = "\n"; var package_available = "\n"; var mr_not_accepted = "\n"; - var mr_not_accepted_code_yes = "\n"; + var mr_not_accepted_code_yes = "\n"; var mr_cancel = "\n"; var package_cancel = "\n"; var package_not_accepted = "\n"; diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index 92c6f38331..9a1775234c 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -345,7 +345,7 @@ function update_manager_check_online_free_packages ($is_ajax=true) { var mr_available = "\n"; var package_available = "\n"; var mr_not_accepted = "\n"; - var mr_not_accepted_code_yes = "\n"; + var mr_not_accepted_code_yes = "\n"; var mr_cancel = "\n"; var package_cancel = "\n"; var package_not_accepted = "\n"; diff --git a/pandora_console/include/javascript/update_manager.js b/pandora_console/include/javascript/update_manager.js index 03d2dda856..62fa6f3619 100644 --- a/pandora_console/include/javascript/update_manager.js +++ b/pandora_console/include/javascript/update_manager.js @@ -607,7 +607,7 @@ function install_package (package, homeurl) { var dialog_have_mr_text = "
    "; dialog_have_mr_text = dialog_have_mr_text + "
    "; - dialog_have_mr_text = dialog_have_mr_text + "

    There are a DB changes

    "; + dialog_have_mr_text = dialog_have_mr_text + "

    This package includes db changes

    "; dialog_have_mr_text = dialog_have_mr_text + "

    " + text1_mr_file + "

    "; dialog_have_mr_text = dialog_have_mr_text + "

    " + text2_mr_file + "" + text3_mr_file + "" + text4_mr_file + "

    "; dialog_have_mr_text = dialog_have_mr_text + "
    "; @@ -1247,7 +1247,7 @@ function install_free_package_prev_step(package, version, homeurl) { var dialog_have_mr_text = "
    "; dialog_have_mr_text = dialog_have_mr_text + "
    "; - dialog_have_mr_text = dialog_have_mr_text + "

    There are a DB changes

    "; + dialog_have_mr_text = dialog_have_mr_text + "

    This package includes db changes

    "; dialog_have_mr_text = dialog_have_mr_text + "

    " + text1_mr_file + "

    "; dialog_have_mr_text = dialog_have_mr_text + "

    " + text2_mr_file + "" + text3_mr_file + "" + text4_mr_file + "

    "; dialog_have_mr_text = dialog_have_mr_text + "
    "; From 531e3a139158eacf0da989ef5bf137fadcd34fa1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 24 Mar 2017 10:46:41 +0100 Subject: [PATCH 010/121] Added safe output to free search at loading event filter --- pandora_console/operation/events/events_list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 703a76c14f..13c8bbd296 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -57,6 +57,7 @@ if (is_ajax()) { $event_filter = events_get_event_filter($id_filter); + $event_filter['search'] = io_safe_output($event_filter['search']); $event_filter['id_name'] = io_safe_output($event_filter['id_name']); $event_filter['tag_with'] = base64_encode(io_safe_output($event_filter['tag_with'])); $event_filter['tag_without'] = base64_encode(io_safe_output($event_filter['tag_without'])); From 15749e323f7222fc3cb1749a27a03154f469e504 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Fri, 24 Mar 2017 13:07:49 +0100 Subject: [PATCH 011/121] Change sec param in policies section, gpolicies to gmodules / 7 / open - #562 --- pandora_console/godmode/agentes/module_manager.php | 2 +- pandora_console/godmode/alerts/alert_list.list.php | 2 +- pandora_console/godmode/alerts/alert_view.php | 2 +- pandora_console/include/ajax/module.php | 2 +- pandora_console/include/functions_ui.php | 2 +- pandora_console/operation/agentes/status_monitor.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 715dcf30ec..acbf762210 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -694,7 +694,7 @@ foreach ($modules as $module) { } } - $data[1] = '' . + $data[1] = '' . html_print_image($img,true, array('title' => $title)) . ''; } diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 62ab5b3ca9..aec32ad0ae 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -688,7 +688,7 @@ foreach ($simple_alerts as $alert) { else { $img = 'images/policies.png'; - $data[3] .= '  ' . + $data[3] .= '  ' . html_print_image($img, true, array('title' => $policyInfo['name'])) . ''; } diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 5d2db04207..f420ea168c 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -115,7 +115,7 @@ if (enterprise_installed() && $alert['id_policy_alerts'] != 0) { else { $img = 'images/policies.png'; - $policy = '' . + $policy = '' . html_print_image($img, true, array('title' => $policyInfo['name'])) . ''; } diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index df85ab81e8..6eb5b0e17a 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -851,7 +851,7 @@ if ($list_modules) { } } - $data[1] = '' . + $data[1] = '' . html_print_image($img,true, array('title' => $title)) . ''; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 9e138b446d..8b9c377f1b 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -813,7 +813,7 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f else { $img = 'images/policies.png'; - $data[$index['policy']] = '' . + $data[$index['policy']] = '' . html_print_image($img,true, array('title' => $policyInfo['name'])) . ''; } diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 3f010a25c6..e4bcec7dd8 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1050,7 +1050,7 @@ if (!empty($result)) { } } - $data[0] = '' . + $data[0] = '' . html_print_image($img,true, array('title' => $title)) . ''; } From f3b5e3bb03ab65cc60fc990bb6c6c8cd72a3a37f Mon Sep 17 00:00:00 2001 From: enriquecd Date: Fri, 24 Mar 2017 15:08:35 +0100 Subject: [PATCH 012/121] Adjust area graph position in vconsole dashboard / open - #566 --- .../godmode/reporting/visual_console_builder.editor.js | 7 +++---- pandora_console/include/graphs/functions_flot.php | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index dbca48c15c..ee03bfdaf3 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -3125,9 +3125,8 @@ function move_elements_resize(original_width, original_height, width, height) { } function unselectAll() { - $("#background").css('border', '1px lightgray solid'); - - $(".item").each(function(){ + $("#background").css('border', '1px lightgray solid'); + $(".item").each(function(){ $(this).css('border', ''); if($(this).attr('withborder') == 'true'){ $(this).css('top', '+=1'); @@ -3136,7 +3135,7 @@ function unselectAll() { } }); - + selectedItem = null; } function click_button_toolbox(id) { diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index d3bf902fd9..ff05611534 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -265,7 +265,9 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, } $return .= html_print_input_hidden('line_width_graph', $config['custom_graph_width'], true); $return .= ""; - $return .= "
    "; + $return .= "
    "; if ($menu) { $height = 100; } From 7dc9f9f21b82e7797386f5839950235479aa3d03 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Mon, 27 Mar 2017 17:06:55 +0200 Subject: [PATCH 013/121] Fixed styles of diferents graphs in dashboards when active mobile version. --- .../include/graphs/flot/pandora.flot.js | 315 ++++++------------ 1 file changed, 95 insertions(+), 220 deletions(-) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index b6f1eb2308..0e82ccded6 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -142,23 +142,31 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, } var label_conf; - - label_conf = { - show: true, - radius: 0.75, - formatter: function(label, series) { - return '
    ' + - series.percent.toFixed(2) + '%
    '; - }, - background: { - opacity: 0.5, - color: '' - } - }; - var show_legend = true; + if((width < 400) && (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) { + show_legend = false; + label_conf = { + show: false + }; + } + else { + label_conf = { + show: true, + radius: 0.75, + formatter: function(label, series) { + return '
    ' + + series.percent.toFixed(2) + '%
    '; + }, + background: { + opacity: 0.5, + color: '' + } + }; + + } + var conf_pie = { series: { pie: { @@ -176,6 +184,9 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, clickable: true } }; + if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { + conf_pie.series.pie.label = {show: false}; + } var plot = $.plot($('#'+graph_id), data, conf_pie); if (no_data == data.length) { @@ -205,17 +216,17 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, var pielegends = $('#'+graph_id+' .pieLabelBackground'); pielegends.each(function () { - $(this).css('transform', "rotate(-35deg)"); + $(this).css('transform', "rotate(-35deg)").css('color', 'black'); }); var labelpielegends = $('#'+graph_id+' .pieLabel'); labelpielegends.each(function () { - $(this).css('transform', "rotate(-35deg)"); + $(this).css('transform', "rotate(-35deg)").css('color', 'black'); }); // Events $('#' + graph_id).bind('plothover', pieHover); $('#' + graph_id).bind('plotclick', Clickpie); - $('#' + graph_id).bind('mouseout',resetInteractivity); + $('#' + graph_id).bind('mouseout', resetInteractivity); $('#' + graph_id).css('margin-left', 'auto'); $('#' + graph_id).css('margin-right', 'auto'); @@ -309,15 +320,19 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, borderWidth: 1, backgroundColor: { colors: ["#FFF", "#FFF"] } }, + xaxis: { + axisLabelUseCanvas: true, + axisLabelFontSizePixels: font_size, + axisLabelFontFamily: font+'Font', + tickFormatter: xFormatter, + }, yaxis: { - axisLabelUseCanvas: true, - axisLabelFontSizePixels: 12, - axisLabelFontFamily: font+'Font', - axisLabelPadding: 3, - ticks: yFormatter, - tickSize: 1, - color: '', - }, + axisLabelUseCanvas: true, + axisLabelFontSizePixels: font_size, + axisLabelFontFamily: font+'Font', + ticks: yFormatter, + color: '', + }, legend: { show: false } @@ -340,140 +355,37 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, $('#' + graph_id).css("margin-left","auto"); $('#' + graph_id).css("margin-right","auto"); $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); - // Adjust the top of yaxis tick to set it in the middle of the bars - //yAxisHeight = $('#' + graph_id + ' .yAxis .tickLabel') - //.css('height').split('px')[0]; - //~ i = 0; - //~ $('#' + graph_id + ' .yAxis .tickLabel').each(function() { - //~ $(this).css('display','none'); - //~ $(this).addClass("legend_"+i); - //~ i++; - //~ }); - - $('#' + graph_id + ' .xAxis .tickLabel').each(function() { - /* - tickTop = $(this).css('top').split('px')[0]; - tickNewTop = parseInt(parseInt(tickTop) - (yAxisHeight / 2) - 3); - $(this).css('top', tickNewTop + 'px'); - - valuesNewTop = parseInt(parseInt(tickTop) - (yAxisHeight)); - - $('#value_' + i + '_' + graph_id) - .css('top',parseInt(plot.offset().top) + parseInt(valuesNewTop)); - - pixelPerValue = parseInt(plot.width()) / maxvalue; - - inCanvasValuePos = parseInt(pixelPerValue * - ($('#value_' + i + '_' + graph_id).html())); - label_width = ($('#value_' + i + '_' + graph_id) - .css('width').split('px')[0] - 3); - - label_left_offset = plot.offset().left + inCanvasValuePos + 5; //Label located on right side of bar + 5 pixels - - //If label fit into the bar just recalculate left position to fit on right side of bar - if (inCanvasValuePos > label_width) { - label_left_offset = plot.offset().left + inCanvasValuePos - - $('#value_' + i + '_' + graph_id).css('width').split('px')[0] - 3; - } - - $('#value_' + i + '_' + graph_id) - .css('left', label_left_offset); - i++; - */ - label = parseFloat($(this).text()); - text = label.toLocaleString(); - if ( label >= 1000000) - text = text.substring(0,4) + "M"; - else if (label >= 100000) - text = text.substring(0,3) + "K"; - else if (label >= 1000) - text = text.substring(0,2) + "K"; - - $(this).text(text); - - }); - /* - // When resize the window, adjust the values - $('#' + graph_id).parent().resize(function () { - i = 0; - pixelPerValue = parseInt(plot.width()) / maxvalue; - - $('#' + graph_id + ' .yAxis .tickLabel').each(function() { - inCanvasValuePos = parseInt(pixelPerValue * - ($('#value_' + i + '_' + graph_id).html())); - label_width = ($('#value_' + i + '_' + graph_id) - .css('width').split('px')[0] - 3); - - label_left_offset = plot.offset().left + inCanvasValuePos + 5; //Label located on right side of bar + 5 pixels - - //If label fit into the bar just recalculate left position to fit on right side of bar - if (inCanvasValuePos > label_width) { - label_left_offset = plot.offset().left + inCanvasValuePos - - $('#value_' + i + '_' + graph_id) - .css('width').split('px')[0] - 3; - } - - $('#value_' + i + '_' + graph_id) - .css('left', label_left_offset); - i++; - }); - }); - - // Format functions - function xFormatter(v, axis) { - if (labels[v] != undefined) { - return labels[v]; - } - else { - return ''; - } - } - - function yFormatter(v, axis) { - return v; - } - - // Events - $('#' + graph_id).bind('plothover', function (event, pos, item) { - $('.values_' + graph_id).css('font-weight', ''); - if (item != null) { - index = item.dataIndex; - $('#value_' + index + '_' + graph_id) - .css('font-weight', 'bold'); - } - }); - - if (water_mark) { - set_watermark(graph_id, plot, - $('#watermark_image_' + graph_id).attr('src')); - } - - if (maxvalue == 0) { - - // Fixed the position for the graphs with all values in - // bars is 0. - - $(".values_" + graph_id).css("left", (plot.offset().left + 5) + "px"); - } - * */ function yFormatter(v, axis) { format = new Array(); for (i = 0; i < labels_total.length; i++) { var label = labels_total[i][1]; - var shortLabel = reduceText(label, 30); + var shortLabel = reduceText(label, 25); var title = ''; if (label !== shortLabel) { title = label; label = shortLabel; } - format.push([i,'
    ' + format.push([i,'
    ' + label + '
    ']); } return format; } + function xFormatter(v, axis) { + label = parseFloat(v); + text = label.toLocaleString(); + if ( label >= 1000000) + text = text.substring(0,4) + "M"; + else if (label >= 100000) + text = text.substring(0,3) + "K"; + else if (label >= 1000) + text = text.substring(0,2) + "K"; + + return '
    '+text+'
    '; + } + if (water_mark) { set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src')); } @@ -600,20 +512,30 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, }, xaxis: { axisLabelUseCanvas: true, - axisLabelFontSizePixels: 7, + axisLabelFontSizePixels: font_size, axisLabelFontFamily: font+'Font', axisLabelPadding: 0, ticks: xFormatter, labelWidth: 130, + labelHeight: 50, }, yaxis: { axisLabelUseCanvas: true, - axisLabelFontSizePixels: 7, + axisLabelFontSizePixels: font_size, axisLabelFontFamily: font+'Font', axisLabelPadding: 100, autoscaleMargin: 0.02, tickFormatter: function (v, axis) { - return v ; + label = parseFloat(v); + text = label.toLocaleString(); + if ( label >= 1000000) + text = text.substring(0,4) + "M"; + else if (label >= 100000) + text = text.substring(0,3) + "K"; + else if (label >= 1000) + text = text.substring(0,2) + "K"; + + return '
    '+text+'
    '; } }, legend: { @@ -630,82 +552,43 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, } }; + if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) + options.xaxis.labelWidth = 100; + var plot = $.plot($('#'+graph_id),datas, options ); $('#' + graph_id).VUseTooltip(); $('#' + graph_id).css("margin-left","auto"); $('#' + graph_id).css("margin-right","auto"); - $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); - // Adjust the top of yaxis tick to set it in the middle of the bars - //yAxisHeight = $('#'+graph_id+' .yAxis .tickLabel').css('height').split('px')[0]; - - //plot.getPlaceholder().onload = function(){pruebas}; - //~ i = 0; - //~ $('#'+graph_id+' .xAxis .tickLabel').each(function() { - //~ $(this).css('display','none'); - //~ $(this).addClass("legend_"+i); - //~ i++; - //~ tickNewTop = parseInt(parseInt(tickTop) - (yAxisHeight/2)-3); - //~ $(this).css('top', tickNewTop+'px'); - //~ - //~ valuesNewTop = parseInt(parseInt(tickTop) - (yAxisHeight)); - //~ - //~ $('#value_'+i+'_'+graph_id).css('top',parseInt(plot.offset().top) + parseInt(valuesNewTop)); -//~ - //~ pixelPerValue = parseInt(plot.width()) / maxvalue; - //~ - //~ inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html())); - //~ - //~ $('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3); - //~ }); - - // When resize the window, adjust the values - //~ $('#'+graph_id).parent().resize(function () { - //~ i = 0; - //~ pixelPerValue = parseInt(plot.width()) / maxvalue; - //~ - //~ $('#'+graph_id+' .yAxis .tickLabel').each(function() { - //~ inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html())); - //~ - //~ $('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3); - //~ i++; - //~ }); - //~ }); - - - - $('#'+graph_id+' .yAxis .tickLabel').each(function() { - label = parseFloat($(this).text()); - text = label.toLocaleString(); - if ( label >= 1000000) - text = text.substring(0,4) + "M"; - else if (label >= 100000) - text = text.substring(0,3) + "K"; - else if (label >= 1000) - text = text.substring(0,2) + "K"; - - $(this).text(text); - }); + //~ $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); $('#'+graph_id+' .xAxis .tickLabel') .css('transform', 'rotate(-45deg)') + .css('max-width','100px') .find('div') .css('position', 'relative') .css('top', '+10px') - .css('left', '-20px'); - + .css('left', '-30px'); + if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) + $('#'+graph_id+' .xAxis .tickLabel') + .find('div') + .css('top', '+0px') + .css('left', '-20px'); // Format functions function xFormatter(v, axis) { var format = new Array(); for (i = 0; i < labels_total.length; i++) { var label = labels_total[i][1]; - var shortLabel = reduceText(label, 35); + var shortLabel = reduceText(label, 28); + if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) + shortLabel = reduceText(label, 18); var title = ''; if (label !== shortLabel) { title = label; label = shortLabel; } + format.push([i, - '
    ' + '
    ' + label + '
    ']); } @@ -713,22 +596,13 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, } function yFormatter(v, axis) { - return v; + return '
    '+v+'
    '; } function lFormatter(v, axis) { - return '
    '+v+'
    '; + return '
    '+v+'
    '; } - - // Events - //~ $('#'+graph_id).bind('plothover', function (event, pos, item) { - //~ $('.values_'+graph_id).css('font-weight', ''); - //~ if(item != null) { - //~ index = item.dataIndex; - //~ $('#value_'+index+'_'+graph_id).css('font-weight', 'bold'); - //~ } - //~ }); - + if (water_mark) { set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src')); } @@ -1581,7 +1455,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, // Re-calculate the graph height with the legend height if (dashboard || vconsole) { var hDiff = $('#'+graph_id).height() - $('#legend_'+graph_id).height(); - if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ){ + if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ){ } else { $('#'+graph_id).css('height', hDiff); @@ -1874,18 +1748,18 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, if (labels[v] == undefined) { return ''; } - return '
    '+labels[v]+'
    '; + return '
    '+labels[v]+'
    '; } function yFormatter(v, axis) { axis.datamin = 0; var formatted = number_format(v,force_integer,unit); - return '
    '+formatted+'
    '; + return '
    '+formatted+'
    '; } function lFormatter(v, item) { - return '
    '+v+'
    '; + return '
    '+v+'
    '; // Prepared to turn series with a checkbox //return '
    '+v+'
    '; } @@ -1994,7 +1868,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, $('#legend_'+graph_id).css('margin-bottom', '10px'); parent_height = parseInt( $('#menu_'+graph_id).parent().css('height').split('px')[0]); - adjust_menu(graph_id, plot, parent_height); + adjust_menu(graph_id, plot, parent_height, width); } if (!dashboard) { @@ -2195,5 +2069,6 @@ function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshol function reduceText (text, maxLength) { if (text.length <= maxLength) return text var firstSlideEnd = parseInt((maxLength - 3) / 2); - return text.substr(0, firstSlideEnd) + '...' + text.substr(-firstSlideEnd - 3); + var str_cut = text.substr(0, firstSlideEnd); + return str_cut + '...' + text.substr(-firstSlideEnd - 3); } From 967b43061dd12446a2fe03615ea4018147eef860 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 28 Mar 2017 11:59:30 +0200 Subject: [PATCH 014/121] Added not init state if there are no initialized modules --- pandora_console/include/functions_agents.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 5455dab2bf..d998d9ea1f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1739,6 +1739,10 @@ function agents_get_status($id_agent = 0, $noACLs = false) { } } + if (!isset($modules) || empty($modules) || count($modules) == 0) { + return AGENT_MODULE_STATUS_NOT_INIT; + } + $modules_status = array(); $modules_async = 0; foreach ($modules as $module) { From 881b86031c684830c3fb80a9cc47cfe3a30f5d64 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Tue, 28 Mar 2017 13:01:40 +0200 Subject: [PATCH 015/121] Fixed visual of graphs in dashboardswhen used mobile version. --- pandora_console/include/graphs/flot/pandora.flot.js | 7 ++++--- pandora_console/include/graphs/functions_flot.php | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 0e82ccded6..6a5badf26f 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -144,7 +144,7 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, var label_conf; var show_legend = true; - if((width < 400) && (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) { + if((width <= 450)) { show_legend = false; label_conf = { show: false @@ -354,7 +354,7 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, $('#' + graph_id).HUseTooltip(); $('#' + graph_id).css("margin-left","auto"); $('#' + graph_id).css("margin-right","auto"); - $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); + //~ $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); function yFormatter(v, axis) { format = new Array(); @@ -731,7 +731,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, force_integer, separator, separator2, yellow_up, red_up, yellow_inverse, red_inverse, series_suffix_str, dashboard, vconsole, xaxisname,background_color,legend_color) { - + var threshold = true; var thresholded = false; font = font.split("/").pop().split(".").shift(); @@ -1928,6 +1928,7 @@ function set_watermark(graph_id, plot, watermark_src) { if ($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) { down_ticks_height = $('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height').split('px')[0]; } + var left_pos = parseInt(context.canvas.width - 3) - $('#watermark_image_'+graph_id)[0].width; var top_pos = 6; //var top_pos = parseInt(context.canvas.height - down_ticks_height - 10) - $('#watermark_image_'+graph_id)[0].height; diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index d3bf902fd9..39eff32a48 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -54,6 +54,8 @@ function include_javascript_dependencies_flot_graph($return = false) { ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.exportdata.pandora.js') .'"> + '; $output .= " @@ -205,7 +207,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, // Parent layer $return = "
    "; // Set some containers to legend, graph, timestamp tooltip, etc. - $return .= "

    "; + $return .= "

    "; if (!empty($threshold_data)) { $yellow_up = $threshold_data['yellow_up']; @@ -241,7 +243,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $nbuttons++; } $menu_width = 25 * $nbuttons + 15; - if ( $dashboard == false AND $vconsole == false) { + if ( if ( $dashboard == false AND $vconsole == false) {) { $return .= "
    '; echo '

    '; - echo '
    '; + echo '
    '; include ('footer.php'); return; } /* Show help */ -echo '
    '; +echo '
    '; if (empty($config['enterprise_installed'])) { echo html_print_image('images/pandora_tinylogo_open.png', true, array("border" => '0')); } @@ -104,15 +97,13 @@ echo '
    '; } } echo '
    '; -echo '
    '; +echo '
    '; ob_start(); require_once ($help_file); $help = ob_get_contents(); ob_end_clean(); // Add a line after H1 tags -$help = str_replace('', '', $help); -$help = str_replace('', '', $help); echo $help; echo '
    '; echo '