From 304d2add62094c183b6c9fe49f4647006db41a56 Mon Sep 17 00:00:00 2001 From: rafael Date: Tue, 8 Sep 2020 09:12:10 +0200 Subject: [PATCH 01/18] Adding error control if the link already exist, then wont be created again --- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 9443aa2514..6b198b57de 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -87,7 +87,7 @@ fi if [ ! -f /etc/pandora/pandora_agent.conf ] ; then ln -s /usr/share/pandora_agent/pandora_agent.conf /etc/pandora/pandora_agent.conf else - ln -s /usr/share/pandora_agent/pandora_agent.conf.rpmnew /etc/pandora/pandora_agent.conf.rpmnew + [[ ! -f /etc/pandora/pandora_agent.conf.rpmnew ]] && ln -s /usr/share/pandora_agent/pandora_agent.conf.rpmnew /etc/pandora/pandora_agent.conf.rpmnew fi if [ ! -e /etc/pandora/plugins ]; then From 867fccf6045ca19f9ab7a1b18d88ffd297a63798 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 17 Sep 2020 14:38:01 +0200 Subject: [PATCH 02/18] Custom id improvements --- .../agentes/module_manager_editor_common.php | 4 +- .../godmode/setup/setup_general.php | 14 +++- pandora_console/include/functions_api.php | 67 +++++++++++++++++++ pandora_console/include/functions_config.php | 8 +++ pandora_server/lib/PandoraFMS/DB.pm | 31 +++++++++ pandora_server/util/pandora_manage.pl | 43 ++++++++++++ 6 files changed, 163 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index b812e5b8b0..4641fcf28c 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -528,10 +528,10 @@ $table_advanced->data[0][1] = html_print_input_text( 20, 65, true, - $disabledBecauseInPolicy, + (($config['module_custom_id_ro']) ? true : $disabledBecauseInPolicy), false, '', - $classdisabledBecauseInPolicy + (($config['module_custom_id_ro']) ? 'readonly' : $classdisabledBecauseInPolicy) ); $table_advanced->data[0][3] = __('Unit'); diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 0d8ce68e8e..779b9c3d31 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -344,6 +344,9 @@ $table->data[$i++][1] = html_print_checkbox_switch('console_log_enabled', 1, $co $table->data[$i][0] = __('Enable audit log').ui_print_help_tip(__('Log location').': pandora_console/log/audit.log', true); $table->data[$i++][1] = html_print_checkbox_switch('audit_log_enabled', 1, $config['audit_log_enabled'], true); +$table->data[$i][0] = __('Module custom ID readonly').ui_print_help_tip(__('Useful for integrations'), true); +$table->data[$i++][1] = html_print_checkbox_switch('module_custom_id_ro', 1, $config['module_custom_id_ro'], true); + echo '
'; echo '
'; @@ -387,7 +390,7 @@ $table_mail_conf->data[6][1] = html_print_input_password('email_password', io_ou $uniqid = uniqid(); -$table_mail_conf->data[7][0] = html_print_button(__('Email test'), 'email_test_dialog', false, "show_email_test('$uniqid');", 'class="sub next"', true); +$table_mail_conf->data[7][0] = html_print_button(__('Email test'), 'email_test_dialog', false, "show_email_test('".$uniqid."');", 'class="sub next"', true); print_email_test_modal_window($uniqid); @@ -404,7 +407,14 @@ html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"' echo ''; echo ''; -// Print the modal window for the summary of each alerts group + +/** + * Print the modal window for the summary of each alerts group + * + * @param string $id Id. + * + * @return void + */ function print_email_test_modal_window($id) { // Email config table. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index e4f2bee4e2..e43e6e2561 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -35,6 +35,9 @@ enterprise_include_once('include/functions_modules.php'); enterprise_include_once('include/functions_clusters.php'); enterprise_include_once('include/functions_alerts.php'); +// Clases. +use PandoraFMS\Module; + /** * Parse the "other" parameter. @@ -2515,6 +2518,70 @@ function api_get_module_id($id, $thrash1, $name, $thrash3) } +/** + * Retrieves custom_id from given module_id. + * + * @param integer $id Module id. + * + * @return void + */ +function api_get_module_custom_id($id) +{ + if (is_metaconsole()) { + return; + } + + try { + $module = new Module($id); + if (!util_api_check_agent_and_print_error( + $module->id_agente(), + 'json' + ) + ) { + return; + } + } catch (Exception $e) { + returnError('id_not_found', 'json'); + } + + returnData('json', $module->custom_id()); +} + + +/** + * Retrieves custom_id from given module_id. + * + * @param integer $id Module id. + * + * @return void + */ +function api_set_module_custom_id($id, $value) +{ + if (is_metaconsole()) { + return; + } + + try { + $module = new Module($id); + if (!util_api_check_agent_and_print_error( + $module->id_agente(), + 'json', + 'AW' + ) + ) { + return; + } + + $module->custom_id($value); + $module->save(); + } catch (Exception $e) { + returnError('id_not_found', 'json'); + } + + returnData('json', ['type' => 'string', 'data' => $module->custom_id()]); +} + + /** * Get modules for an agent, and print all the result like a csv. * diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 3554f091ed..cea1dd0f81 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -331,6 +331,10 @@ function config_update_config() $error_update[] = __('Audit log enabled'); } + if (!config_update_value('module_custom_id_ro', get_parameter('module_custom_id_ro'))) { + $error_update[] = __('Module Custom ID read only'); + } + if (!config_update_value('unique_ip', get_parameter('unique_ip'))) { $error_update[] = __('unique_ip'); } @@ -1946,6 +1950,10 @@ function config_process_config() config_update_value('audit_log_enabled', 0); } + if (!isset($config['module_custom_id_ro'])) { + config_update_value('module_custom_id_ro', 0); + } + if (!isset($config['elasticsearch_ip'])) { config_update_value('elasticsearch_ip', ''); } diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index ae07c49c96..88c51b2f03 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -99,6 +99,8 @@ our @EXPORT = qw( get_user_exists get_user_profile_id get_group_children + get_agentmodule_custom_id + set_agentmodule_custom_id is_agent_address is_group_disabled get_agent_status @@ -446,6 +448,35 @@ sub get_agentmodule_data ($$$$$) { return @rows; } +########################################################################## +## Return module custom ID given the module id. +########################################################################## +sub get_agentmodule_custom_id ($$) { + my ($dbh, $id_agent_module) = @_; + + my $rc = get_db_value( + $dbh, + "SELECT custom_id FROM tagente_modulo WHERE id_agente_modulo = ?", + safe_input($id_agent_module) + ); + return defined($rc) ? $rc : undef; +} + +########################################################################## +## Updates module custom ID given the module id and custom Id. +########################################################################## +sub set_agentmodule_custom_id ($$$) { + my ($dbh, $id_agent_module, $custom_id) = @_; + + my $rc = db_update( + $dbh, + "UPDATE tagente_modulo SET custom_id = ? WHERE id_agente_modulo = ?", + safe_input($custom_id), + safe_input($id_agent_module) + ); + return defined($rc) ? ($rc eq '0E0' ? 0 : $rc) : -1; +} + ######################################################################## ## SUB get_agentmodule_status (agent_module_id) ## Return agent module status. given "agent_module_id" diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 0a97efe1a8..bdfb0f007c 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -118,6 +118,8 @@ sub help_screen{ help_screen_line('--get_planned_downtimes_items', ' [ ]', 'Get all items of planned downtimes'); help_screen_line('--set_planned_downtimes_deleted', ' ', 'Deleted a planned downtime'); help_screen_line('--get_module_id', ' ', 'Get the id of an module'); + help_screen_line('--get_module_custom_id', '', 'Get the custom_id of given module'); + help_screen_line('--set_module_custom_id', ' []', 'Set (or erase if empty) the custom_id of given module'); help_screen_line('--get_agent_group', ' []', 'Get the group name of an agent'); help_screen_line('--get_agent_group_id', ' []', 'Get the group ID of an agent'); help_screen_line('--get_agent_modules', ' []', 'Get the modules of an agent'); @@ -4616,6 +4618,39 @@ sub cli_get_module_id() { } +############################################################################## +# Retrieves the module custom_id given id_agente_modulo. +# Related option: --get_module_custom_id +# perl pandora_manage.pl /etc/pandora/pandora_server.conf --get_module_custom_id 4 +############################################################################## + +sub cli_get_module_custom_id { + my $module_id = $ARGV[2]; + + my $custom_id = get_agentmodule_custom_id($dbh, $module_id); + + if (defined($custom_id)) { + print $custom_id; + } +} + +############################################################################## +# Update sor erases the module custom_id given id_agente_modulo. +# Related option: --get_module_custom_id +# perl pandora_manage.pl /etc/pandora/pandora_server.conf --get_module_custom_id 4 test +############################################################################## + +sub cli_set_module_custom_id { + my ($module_id, $custom_id) = @ARGV[2..3]; + + my $rs = set_agentmodule_custom_id($dbh, $module_id, $custom_id); + + if ($rs > 0) { + print $custom_id; + } else { + print "[ERROR] No changes."; + } +} ############################################################################## # Show the group name where a given agent is @@ -7491,6 +7526,14 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 2); cli_get_module_id(); } + elsif ($param eq '--get_module_custom_id') { + param_check($ltotal, 1); + cli_get_module_custom_id(); + } + elsif ($param eq '--set_module_custom_id') { + param_check($ltotal, 2); + cli_set_module_custom_id(); + } elsif ($param eq '--get_agent_group') { param_check($ltotal, 2, 1); cli_get_agent_group(); From bc166dfba2f4b8683d4ec2ebae1cd3246d571d9a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 17 Sep 2020 16:51:23 +0200 Subject: [PATCH 03/18] module custom id in event list + minor fixes --- pandora_console/godmode/events/custom_events.php | 1 + pandora_console/include/functions_events.php | 4 ++++ pandora_console/operation/events/events.php | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index fb4b6f9ab1..124b0711c5 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -114,6 +114,7 @@ $fields_available['server_name'] = __('Server Name'); $fields_available['data'] = __('Data'); $fields_available['module_status'] = __('Module Status'); $fields_available['mini_severity'] = __('Severity mini'); +$fields_available['module_custom_id'] = __('Module custom ID'); // Remove fields already selected. diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 9f8cfdbf08..a6f0f83752 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -207,6 +207,7 @@ function events_get_all_fields() $columns['server_name'] = __('Server name'); $columns['data'] = __('Data'); $columns['module_status'] = __('Module status'); + $columns['module_custom_id'] = __('Module custom id'); return $columns; } @@ -291,6 +292,9 @@ function events_get_column_name($field, $table_alias=false) case 'module_status': return __('Module Status'); + case 'module_custom_id': + return __('Module custom ID'); + case 'options': return __('Options'); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index f9a727f6c2..b0e7cc3002 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -292,6 +292,7 @@ if (is_ajax()) { if (!is_metaconsole()) { $fields[] = 'am.nombre as module_name'; $fields[] = 'am.id_agente_modulo as id_agentmodule'; + $fields[] = 'am.custom_id as module_custom_id'; $fields[] = 'ta.server_name as server_name'; } else { $fields[] = 'ts.server_name as server_name'; @@ -470,9 +471,13 @@ $tags_select_with = []; $tags_select_without = []; $tag_with_temp = []; $tag_without_temp = []; -$tag_with = json_decode(base64_decode($tag_with), true); -$tag_without = json_decode(base64_decode($tag_without), true); +if (is_array($tag_with) === false) { + $tag_with = json_decode(base64_decode($tag_with), true); +} +if (is_array($tag_without) === false) { + $tag_without = json_decode(base64_decode($tag_without), true); +} foreach ($tags as $id_tag => $tag) { if (is_array($tag_with) === true @@ -1315,10 +1320,12 @@ try { // 'timestamp_rep', // 'timestamp_rep_min', // 'module_name', + // 'custom_id', [ 'text' => 'options', 'class' => 'action_buttons w120px', - ],[ + ], + [ 'text' => 'm', 'extra' => $checkbox_all, 'class' => 'mw120px', @@ -2004,6 +2011,9 @@ function process_datatables_item(item) { /* Module name */ item.id_agentmodule = item.module_name; + + // Module custom_id. + item.custom_id = item.module_custom_id; } /* Datatables auxiliary functions ends */ From 92da78496be3dff8fb5fec98bf7198077e1aeada Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 17 Sep 2020 16:54:40 +0200 Subject: [PATCH 04/18] Added module custom id to general tab in event details --- pandora_console/include/functions_events.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index a6f0f83752..b398df5553 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -4682,6 +4682,16 @@ function events_page_general($event) $table_general->data[] = $data; + $data = []; + $data[0] = __('Module custom ID'); + if ($event['module_custom_id'] != '') { + $data[1] = $event['module_custom_id']; + } else { + $data[1] = ''.__('N/A').''; + } + + $table_general->data[] = $data; + $table_data = $table_general->data; if (is_array($table_data)) { $table_data_total = count($table_data); From 4fb69f343a58e55efee9592d4b354bf402201ef8 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 17 Sep 2020 19:32:28 +0200 Subject: [PATCH 05/18] minor fix --- .../godmode/agentes/module_manager_editor_common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 4641fcf28c..50bcf4a824 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -528,10 +528,10 @@ $table_advanced->data[0][1] = html_print_input_text( 20, 65, true, - (($config['module_custom_id_ro']) ? true : $disabledBecauseInPolicy), + (($config['module_custom_id_ro'] && $__code_from != 'policies') ? true : $disabledBecauseInPolicy), false, '', - (($config['module_custom_id_ro']) ? 'readonly' : $classdisabledBecauseInPolicy) + (($config['module_custom_id_ro'] && $__code_from != 'policies') ? 'readonly' : $classdisabledBecauseInPolicy) ); $table_advanced->data[0][3] = __('Unit'); From c6165fbdeed94b0ae864c218f3def4af4b9ee977 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Mon, 21 Sep 2020 15:13:07 +0200 Subject: [PATCH 06/18] fixed mobile console donut charts --- .../godmode/agentes/agent_manager.php | 2 +- pandora_console/include/functions_graph.php | 64 +++++--- .../include/graphs/functions_flot.php | 3 +- pandora_console/mobile/include/ui.class.php | 1 + pandora_console/mobile/operation/agent.php | 150 +++++++----------- .../mobile/operation/module_graph.php | 3 - pandora_console/mobile/operation/tactical.php | 2 - 7 files changed, 101 insertions(+), 124 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 042e7eeac3..195574040e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -258,7 +258,7 @@ if (!$new_agent && $alias != '') { $table_qr_code .= '

'.__('QR Code Agent view').'

'; $table_qr_code .= '
'; if ($id_agente) { - $table_qr_code .= ""; + $table_qr_code .= ""; } // Add Custom id div. diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c86e1bdc38..d30bc6b812 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2554,20 +2554,35 @@ function truncate_negatives(&$element) /** - * Print a pie graph with events data of agent or all agents (if id_agent = false) + * Print a pie graph with events + * data of agent or all agents (if id_agent = false). * - * @param integer id_agent Agent ID - * @param integer width pie graph width - * @param integer height pie graph height - * @param bool return or echo flag - * @param bool show_not_init flag + * @param integer $id_agent Agent ID. + * @param integer $width Pie graph width. + * @param integer $height Pie graph height. + * @param boolean $return Flag. + * @param boolean $show_not_init Flag. + * @param array $data_agents Data. + * @param boolean $donut_narrow_graph Flag type graph. + * + * @return string Html chart. */ -function graph_agent_status($id_agent=false, $width=300, $height=200, $return=false, $show_not_init=false, $data_agents=false, $donut_narrow_graph=false) -{ +function graph_agent_status( + $id_agent=false, + $width=300, + $height=200, + $return=false, + $show_not_init=false, + $data_agents=false, + $donut_narrow_graph=false +) { global $config; if ($data_agents == false) { - $groups = implode(',', array_keys(users_get_groups(false, 'AR', false))); + $groups = implode( + ',', + array_keys(users_get_groups(false, 'AR', false)) + ); $p_table = 'tagente'; $s_table = 'tagent_secondary_group'; if (is_metaconsole()) { @@ -2575,10 +2590,8 @@ function graph_agent_status($id_agent=false, $width=300, $height=200, $return=fa $s_table = 'tmetaconsole_agent_secondary_group'; } - $data = db_get_row_sql( - sprintf( - 'SELECT - SUM(critical_count) AS Critical, + $sql = sprintf( + 'SELECT SUM(critical_count) AS Critical, SUM(warning_count) AS Warning, SUM(normal_count) AS Normal, SUM(unknown_count) AS Unknown @@ -2589,19 +2602,20 @@ function graph_agent_status($id_agent=false, $width=300, $height=200, $return=fa ta.disabled = 0 AND %s (ta.id_grupo IN (%s) OR tasg.id_group IN (%s))', - $show_not_init ? ', SUM(notinit_count) "Not init"' : '', - $p_table, - $s_table, - empty($id_agent) ? '' : "ta.id_agente = $id_agent AND", - $groups, - $groups - ) + $show_not_init ? ', SUM(notinit_count) "Not init"' : '', + $p_table, + $s_table, + (empty($id_agent) === true) ? '' : 'ta.id_agente = '.$id_agent.' AND', + $groups, + $groups ); + + $data = db_get_row_sql($sql); } else { $data = $data_agents; } - if (empty($data)) { + if (empty($data) === true) { $data = []; } @@ -2610,11 +2624,15 @@ function graph_agent_status($id_agent=false, $width=300, $height=200, $return=fa if ($config['fixed_graph'] == false) { $water_mark = [ 'file' => $config['homedir'].'/images/logo_vertical_water.png', - 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), + 'url' => ui_get_full_url( + 'images/logo_vertical_water.png', + false, + false, + false + ), ]; } - // $colors = array(COL_CRITICAL, COL_WARNING, COL_NORMAL, COL_UNKNOWN); $colors['Critical'] = COL_CRITICAL; $colors['Warning'] = COL_WARNING; $colors['Normal'] = COL_NORMAL; diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 6499cc876c..4b0bde1408 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -39,7 +39,6 @@ function include_javascript_dependencies_flot_graph($return=false, $mobile=false // NOTE: jquery.flot.threshold is not te original file. Is patched to allow multiple thresholds and filled area $output .= ' - @@ -79,7 +78,7 @@ function include_javascript_dependencies_flot_graph($return=false, $mobile=false percent = parseFloat(obj.series.percent).toFixed(2); alert(''+obj.series.label+': '+obj.series.data[0][1]+' ('+percent+'%)'); } - "; + "; if (!$return) { echo $output; diff --git a/pandora_console/mobile/include/ui.class.php b/pandora_console/mobile/include/ui.class.php index 87954cf96e..1992268990 100755 --- a/pandora_console/mobile/include/ui.class.php +++ b/pandora_console/mobile/include/ui.class.php @@ -779,6 +779,7 @@ class Ui echo " \n"; echo " \n"; + echo include_javascript_dependencies_flot_graph(false, false); echo "
"; if (!empty($this->dialogs)) { if (!empty($this->dialogs['onStart'])) { diff --git a/pandora_console/mobile/operation/agent.php b/pandora_console/mobile/operation/agent.php index 6337b75e93..95e4ca5bbf 100644 --- a/pandora_console/mobile/operation/agent.php +++ b/pandora_console/mobile/operation/agent.php @@ -108,30 +108,6 @@ class Agent } - public function ajax($parameter2=false) - { - $system = System::getInstance(); - - if (!$this->correct_acl) { - return; - } else { - switch ($parameter2) { - case 'render_events_bar': - $agent_id = $system->getRequest('agent_id', '0'); - $width = $system->getRequest('width', '400'); - graph_graphic_agentevents( - $agent_id, - $width, - 30, - SECONDS_1DAY, - ui_get_full_url(false) - ); - exit; - } - } - } - - private function show_agent() { $ui = Ui::getInstance(); @@ -194,24 +170,14 @@ class Agent } $address = $this->agent['direccion']; - // ~ foreach ($addresses as $k => $add) { - // ~ if ($add == $address) { - // ~ unset($addresses[$k]); - // ~ } - // ~ } - // ~ $ip = html_print_image('images/world.png', - // ~ true, array('title' => __('IP address'))) . - // ~ '  '; - $ip .= empty($address) ? ''.__('N/A').'' : $address; + $ip .= (empty($address) === true) ? ''.__('N/A').'' : $address; + $last_contact = ''.__('Last contact').': '; + $last_contact .= ui_print_timestamp( + $this->agent['ultimo_contacto'], + true + ); - // ~ if (!empty($addresses)) { - // ~ $ip .= ui_print_help_tip(__('Other IP addresses') . - // ~ ': ' . implode(', ',$addresses), true); - // ~ } - $last_contact = ''.__('Last contact').': '.ui_print_timestamp($this->agent['ultimo_contacto'], true); - - // ~ $description = '' . __('Description') . ': '; - if (empty($agent['comentarios'])) { + if (empty($agent['comentarios']) === true) { $description .= ''.__('N/A').''; } else { $description .= $this->agent['comentarios']; @@ -241,6 +207,34 @@ class Agent $html .= $description; $html .= ''; + $ui->contentGridAddCell($html, 'agent_details'); + + ob_start(); + + // Fixed width non interactive charts. + $status_chart_width = 160; + $graph_width = 160; + + hd($this->agent, true); + + $html = '
'; + $html .= ''.__('Modules by status').''; + $html .= '
'; + $html .= graph_agent_status( + $this->id, + $graph_width, + 160, + true, + false, + false, + true + ); + $html .= '
'; + $graph_js = ob_get_clean(); + $html = $graph_js.$html; + + unset($this->agent['fired_count']); + if ($system->getConfig('metaconsole')) { metaconsole_connect( null, @@ -248,24 +242,6 @@ class Agent ); } - $ui->contentGridAddCell($html, 'agent_details'); - - ob_start(); - - // Fixed width non interactive charts - $status_chart_width = 160; - $graph_width = 160; - - $html = '
'; - $html .= ''.__('Modules by status').''; - $html .= '
'; - $html .= graph_agent_status($this->id, $graph_width, 160, true); - $html .= '
'; - $graph_js = ob_get_clean(); - $html = $graph_js.$html; - - unset($this->agent['fired_count']); - if ($this->agent['total_count'] > 0) { $html .= '
'.reporting_tiny_stats($this->agent, true, 'agent', ' ').'
'; } @@ -273,7 +249,20 @@ class Agent $html .= '
'; $html .= '
'; $html .= ''.__('Events (24h)').''; - $html .= '
'; + $html .= '
'; + $html .= graph_graphic_agentevents( + $this->id, + 95, + 45, + SECONDS_1DAY, + '', + true, + false, + true, + 1, + '' + ); + $html .= '
'; $html .= '
'; $ui->contentGridAddCell($html, 'agent_graphs'); @@ -306,7 +295,10 @@ class Agent $ui->contentEndCollapsible(); if ($system->getConfig('metaconsole')) { - metaconsole_connect(null, $this->agent['id_tmetaconsole_setup']); + metaconsole_connect( + null, + $this->agent['id_tmetaconsole_setup'] + ); } $alerts = new Alerts(); @@ -371,46 +363,19 @@ class Agent $('.agent_details').height(max_height); } } - + if ($('.ui-block-a').css('float') != 'none') { set_same_heigth(); } - + $('.ui-collapsible').bind('expand', function () { refresh_link_listener_last_agent_events(); refresh_link_listener_list_agent_Modules(); }); - - function ajax_load_events_bar() { - $('#events_bar').html('
".__('Loading...')."
'); - - var bar_width = $('.agent_graphs').width() * 0.9; - postvars = {}; - postvars[\"action\"] = \"ajax\"; - postvars[\"parameter1\"] = \"agent\"; - postvars[\"parameter2\"] = \"render_events_bar\"; - postvars[\"agent_id\"] = \"".$this->id."\"; - postvars[\"width\"] = bar_width; - $.post(\"index.php\", - postvars, - function (data) { - $('#events_bar').html(data); - if ($('.ui-block-a').css('float') != 'none') { - set_same_heigth(); - } - }, - \"html\"); - } - - ajax_load_events_bar(); - // Detect orientation change to refresh dinamic content $(window).on({ orientationchange: function(e) { - // Refresh events bar - ajax_load_events_bar(); - // Keep same height on boxes if ($('.ui-block-a').css('float') == 'none') { $('.agent_graphs').height('auto'); @@ -419,14 +384,13 @@ class Agent else { set_same_heigth(); } - } }); - + if ($('.ui-block-a').css('float') != 'none') { set_same_heigth(); } - }); + }); " ); diff --git a/pandora_console/mobile/operation/module_graph.php b/pandora_console/mobile/operation/module_graph.php index 2dbea7c94a..2793a07b88 100644 --- a/pandora_console/mobile/operation/module_graph.php +++ b/pandora_console/mobile/operation/module_graph.php @@ -270,9 +270,6 @@ class ModuleGraph global $config; - echo include_javascript_dependencies_flot_graph(true); - ui_require_javascript_file('pandora', 'include/javascript/', true); - ?> - - - - - - - + +<?php echo __('%s Interface Graph', get_product_name()).' ('.agents_get_alias($agent_id).' - '.$interface_name; ?>) + + + + + + + + + + $now) { $date = $now; } - $urlImage = ui_get_full_url(false); +$urlImage = ui_get_full_url(false); - // Graph. - echo '
'; +// FORM TABLE. +$table = html_get_predefined_table('transparent', 2); +$table->width = '100%'; +$table->id = 'stat_win_form_div'; +$table->style[0] = 'text-align:left;'; +$table->style[1] = 'text-align:left;'; +$table->styleTable = 'margin-bottom: 20px;'; +$table->class = 'table_modal_alternate'; - $height = 400; - $width = '90%'; +$data = []; +$data[0] = __('Refresh time'); +$data[1] = html_print_extended_select_for_time( + 'refresh', + $refresh, + '', + '', + 0, + 7, + true +); +$table->data[] = $data; +$table->rowclass[] = ''; - $params = [ - 'period' => $period, - 'width' => $width, - 'height' => $height, - 'unit_name' => array_fill(0, count($interface_traffic_modules), $config['interface_unit']), - 'date' => $date, - 'homeurl' => $config['homeurl'], - 'percentil' => (($show_percentil) ? $config['percentil'] : null), - 'fullscale' => $fullscale, - 'zoom' => $zoom, - ]; +$data = []; +$data[0] = __('Begin date'); +$data[1] = html_print_input_text( + 'start_date', + substr($start_date, 0, 10), + '', + 15, + 255, + true +); +$data[1] .= html_print_image( + '/images/calendar_view_day.png', + true, + [ + 'onclick' => "scwShow(scwID('text-start_date'),this);", + 'style' => 'vertical-align: bottom;', + ], + false, + false, + false, + true +); +$table->data[] = $data; +$table->rowclass[] = ''; - if (is_metaconsole()) { - $params['id_server'] = $server_id; - } +$data = []; +$data[0] = __('Begin time'); +$data[1] = html_print_input_text('start_time', $start_time, '', 10, 10, true); +$table->data[] = $data; +$table->rowclass[] = ''; - if ($config['type_interface_charts'] == 'line') { - $stacked = CUSTOM_GRAPH_LINE; - } else { - $stacked = CUSTOM_GRAPH_AREA; - } +$data = []; +$data[0] = __('Time range'); +$data[1] = html_print_extended_select_for_time( + 'period', + $period, + '', + '', + 0, + 7, + true +); +$table->data[] = $data; +$table->rowclass[] = ''; - $params_combined = [ - 'weight_list' => [], - 'projection' => false, - 'labels' => array_keys($interface_traffic_modules), - 'from_interface' => true, - 'modules_series' => array_values($interface_traffic_modules), - 'return' => 0, - 'stacked' => $stacked, - ]; +$data = []; +$data[0] = __('Show percentil'); +$data[1] = html_print_checkbox_switch( + 'show_percentil', + 1, + (bool) $show_percentil, + true +); +$table->data[] = $data; +$table->rowclass[] = ''; - graphic_combined_module( - array_values($interface_traffic_modules), - $params, - $params_combined - ); +$data = []; +$data[0] = __('Show full scale graph (TIP)').ui_print_help_tip( + __('This option may cause performance issues'), + true, + 'images/tip.png', + true +); +$data[1] = html_print_checkbox_switch('fullscale', 1, (bool) $fullscale, true); +$table->data[] = $data; +$table->rowclass[] = ''; - echo '
'; +$data = []; +$data[0] = __('Zoom factor'); +$options = []; +$options[$zoom] = 'x'.$zoom; +$options[1] = 'x1'; +$options[2] = 'x2'; +$options[3] = 'x3'; +$options[4] = 'x4'; +$options[5] = __('Full'); +$data[1] = html_print_select( + $options, + 'zoom', + $zoom, + '', + '', + 0, + true, + false, + false +); +$table->data[] = $data; +$table->rowclass[] = ''; - // FORM TABLE - $table = html_get_predefined_table('transparent', 2); - $table->width = '100%'; - $table->id = 'stat_win_form_div'; - $table->style[0] = 'text-align:left;'; - $table->style[1] = 'text-align:left;'; - $table->styleTable = 'margin-bottom: 20px;'; - $table->class = 'table_modal_alternate'; - - $data = []; - $data[0] = __('Refresh time'); - $data[1] = html_print_extended_select_for_time('refresh', $refresh, '', '', 0, 7, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Begin date'); - $data[1] = html_print_input_text('start_date', substr($start_date, 0, 10), '', 15, 255, true); - $data[1] .= html_print_image('/images/calendar_view_day.png', true, ['onclick' => "scwShow(scwID('text-start_date'),this);", 'style' => 'vertical-align: bottom;'], false, false, false, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Begin time'); - $data[1] = html_print_input_text('start_time', $start_time, '', 10, 10, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Time range'); - $data[1] = html_print_extended_select_for_time('period', $period, '', '', 0, 7, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Show percentil'); - $data[1] = html_print_checkbox_switch('show_percentil', 1, (bool) $show_percentil, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Show full scale graph (TIP)').ui_print_help_tip( - __('This option may cause performance issues'), - true, - 'images/tip.png', - true - ); - $data[1] = html_print_checkbox_switch('fullscale', 1, (bool) $fullscale, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Zoom factor'); - $options = []; - $options[$zoom] = 'x'.$zoom; - $options[1] = 'x1'; - $options[2] = 'x2'; - $options[3] = 'x3'; - $options[4] = 'x4'; - $options[5] = __('Full'); - $data[1] = html_print_select($options, 'zoom', $zoom, '', '', 0, true, false, false); - $table->data[] = $data; - $table->rowclass[] = ''; - - $form_table = html_print_table($table, true); - $form_table .= '
'.html_print_submit_button( - __('Reload'), - 'submit', - false, - 'class="sub upd"', - true - ).'
'; +$form_table = html_print_table($table, true); +$form_table .= '
'.html_print_submit_button( + __('Reload'), + 'submit', + false, + 'class="sub upd"', + true +).'
'; - // Menu. - $menu_form = "
".html_print_input_hidden('params', base64_encode($params_json), true); +// Menu. +$menu_form = "".html_print_input_hidden('params', base64_encode($params_json), true); - if (!empty($server_id)) { - $menu_form .= html_print_input_hidden('server', $server_id, true); - } +if (empty($server_id) === false) { + $menu_form .= html_print_input_hidden('server', $server_id, true); +} - echo $menu_form; - echo '
-
- '.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).' - '.__('Graph configuration menu').' - '.html_print_image('images/config.png', true, ['float' => 'right'], false, false, true).' -
- -
'; - echo '
'; +echo $menu_form; +echo '
+
+ '.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).' + '.__('Graph configuration menu').'
+ +
'; +echo ''; - // Hidden div to forced title - html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', 'hidden' => true]); - ?> +// Hidden div to forced title. +html_print_div( + [ + 'id' => 'forced_title_layer', + 'class' => 'forced_title_layer', + 'hidden' => true, + ] +); + +// Graph. +echo '
'; + +$height = 280; +$width = '90%'; + +$params = [ + 'period' => $period, + 'width' => $width, + 'height' => $height, + 'unit_name' => array_fill(0, count($interface_traffic_modules), $config['interface_unit']), + 'date' => $date, + 'homeurl' => $config['homeurl'], + 'percentil' => (($show_percentil) ? $config['percentil'] : null), + 'fullscale' => $fullscale, + 'zoom' => $zoom, +]; + +if (is_metaconsole()) { + $params['id_server'] = $server_id; +} + +if ($config['type_interface_charts'] == 'line') { + $stacked = CUSTOM_GRAPH_LINE; +} else { + $stacked = CUSTOM_GRAPH_AREA; +} + +$params_combined = [ + 'weight_list' => [], + 'projection' => false, + 'labels' => array_keys($interface_traffic_modules), + 'from_interface' => true, + 'modules_series' => array_values($interface_traffic_modules), + 'return' => 0, + 'stacked' => $stacked, +]; + +graphic_combined_module( + array_values($interface_traffic_modules), + $params, + $params_combined +); + +echo '
'; +?> - "; - echo '

'.__('The CSV export has been successful.').'

'; - echo '
'; - // Module id + // Module id. $id = (int) get_parameter('id', 0); - // Agent id + // Agent id. $agent_id = (int) modules_get_agentmodule_agent($id); - if (empty($id) || empty($agent_id)) { - ui_print_error_message(__('There was a problem locating the source of the graph')); + if (empty($id) === true || empty($agent_id) === true) { + ui_print_error_message( + __('There was a problem locating the source of the graph') + ); exit; } - // ACL + // ACL. $all_groups = agents_get_all_groups_agent($agent_id); if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AR')) { include $config['homedir'].'/general/noaccess.php'; @@ -138,7 +154,9 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1. $fullscale_sent = get_parameter('fullscale_sent', 0); if (!$fullscale_sent) { - if (!isset($config['full_scale_option']) || $config['full_scale_option'] == 0) { + if (isset($config['full_scale_option']) === false + || $config['full_scale_option'] == 0 + ) { $fullscale = 0; } else if ($config['full_scale_option'] == 1) { $fullscale = 1; @@ -153,9 +171,6 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1. $fullscale = get_parameter('fullscale', 0); } - // To avoid the horizontal overflow - $width -= 20; - $time_compare = false; if ($time_compare_separated) { @@ -169,8 +184,8 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1. $width = ($width * ($zoom / 1.4)); } - // Build date - $date = strtotime("$start_date $start_time"); + // Build date. + $date = strtotime($start_date.' '.$start_time); $now = time(); if ($date > $now) { @@ -179,14 +194,222 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1. $urlImage = ui_get_full_url(false, false, false, false); - $unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $id); + $unit = db_get_value( + 'unit', + 'tagente_modulo', + 'id_agente_modulo', + $id + ); + // FORM TABLE. + $table = html_get_predefined_table('transparent', 2); + $table->width = '100%'; + $table->id = 'stat_win_form_div'; + $table->style[0] = 'text-align:left;'; + $table->style[1] = 'text-align:left;'; + $table->style[2] = 'text-align:left;font-weight: bold;'; + $table->style[3] = 'text-align:left;'; + $table->class = 'table_modal_alternate'; + + $table->data = []; + $table->data[0][0] = __('Refresh time'); + $table->data[0][1] = html_print_extended_select_for_time( + 'refresh', + $refresh, + '', + '', + 0, + 7, + true + ); + + $table->data[0][2] = __('Show events'); + $disabled = false; + if (isset($config['event_replication']) === true) { + if ($config['event_replication'] + && !$config['show_events_in_local'] + ) { + $disabled = true; + } + } + + $table->data[0][3] = html_print_checkbox_switch( + 'draw_events', + 1, + (bool) $draw_events, + true, + $disabled + ); + if ($disabled) { + $table->data[1] .= ui_print_help_tip( + __("'Show events' is disabled because this %s node is set to event replication.", get_product_name()), + true + ); + } + + $table->data[1][0] = __('Begin date'); + $table->data[1][1] = html_print_input_text( + 'start_date', + $start_date, + '', + 10, + 20, + true + ); + + $table->data[1][2] = __('Show alerts'); + $table->data[1][3] = html_print_checkbox_switch( + 'draw_alerts', + 1, + (bool) $draw_alerts, + true + ); + + $table->data[2][0] = __('Begin time'); + $table->data[2][1] = html_print_input_text( + 'start_time', + $start_time, + '', + 10, + 10, + true + ); + + $table->data[2][2] = __('Show unknown graph'); + $table->data[2][3] = html_print_checkbox_switch( + 'unknown_graph', + 1, + (bool) $unknown_graph, + true + ); + + $table->data[3][0] = __('Time range'); + $table->data[3][1] = html_print_extended_select_for_time( + 'period', + $period, + '', + '', + 0, + 7, + true + ); + + $table->data[3][2] = __('Show full scale graph (TIP)'); + $table->data[3][3] = html_print_checkbox_switch( + 'fullscale', + 1, + (bool) $fullscale, + true, + false + ); + + if (!modules_is_boolean($id)) { + $table->data[4][0] = __('Zoom'); + $options = []; + $options[$zoom] = 'x'.$zoom; + $options[1] = 'x1'; + $options[2] = 'x2'; + $options[3] = 'x3'; + $options[4] = 'x4'; + $options[5] = 'x5'; + $table->data[4][1] = html_print_select( + $options, + 'zoom', + $zoom, + '', + '', + 0, + true, + false, + false + ); + + $table->data[4][2] = __('Show percentil'); + $table->data[4][3] = html_print_checkbox_switch( + 'show_percentil', + 1, + (bool) $show_percentil, + true + ); + } + + $table->data[5][0] = __('Time compare (Overlapped)'); + $table->data[5][1] = html_print_checkbox_switch( + 'time_compare_overlapped', + 1, + (bool) $time_compare_overlapped, + true + ); + + $table->data[5][2] = __('Time compare (Separated)'); + $table->data[5][3] = html_print_checkbox_switch( + 'time_compare_separated', + 1, + (bool) $time_compare_separated, + true + ); + + $form_table = html_print_table($table, true); + $form_table .= '
'; + $form_table .= html_print_submit_button( + __('Reload'), + 'submit', + false, + 'class="sub upd"', + true + ); + $form_table .= '
'; + + // Menu. + $menu_form = "
"; + $menu_form .= html_print_input_hidden('id', $id, true); + $menu_form .= html_print_input_hidden('label', $label, true); + + if (empty($server_id) === false) { + $menu_form .= html_print_input_hidden('server', $server_id, true); + } + + if (isset($_GET['type']) === true) { + $type = get_parameter_get('type'); + $menu_form .= html_print_input_hidden('type', $type, true); + } + + $menu_form .= '
'; + $menu_form .= '
'; + $menu_form .= html_print_image( + 'images/arrow_down_green.png', + true, + [ + 'class' => 'module_graph_menu_arrow', + 'float' => 'left', + ], + false, + false, + true + ); + $menu_form .= ''; + $menu_form .= __('Graph configuration menu'); + $menu_form .= ''; + $menu_form .= '
'; + $menu_form .= ''; + $menu_form .= '
'; + $menu_form .= '
'; + + echo $menu_form; + + // Hidden div to forced title. + html_print_div( + [ + 'id' => 'forced_title_layer', + 'class' => 'forced_title_layer', + 'hidden' => true, + ] + ); // Graph. - echo '
'; - $width = '90%'; - $height = '450'; - + $output = '
'; switch ($graph_type) { case 'boolean': case 'sparse': @@ -209,12 +432,14 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1. 'type_graph' => $config['type_module_charts'], 'fullscale' => $fullscale, 'zoom' => $zoom, + 'height' => 300, ]; - echo grafico_modulo_sparse($params); - echo '
'; + $output .= grafico_modulo_sparse($params); + $output .= '
'; if ($show_events_graph) { $width = '500'; - echo graphic_module_events( + $height = '450'; + $output .= graphic_module_events( $id, $width, $height, @@ -229,200 +454,12 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1. break; default: - echo fs_error_image('../images'); + $output .= fs_error_image('../images'); break; } - echo '
'; - - - - // FORM TABLE. - $table = html_get_predefined_table('transparent', 2); - $table->width = '100%'; - $table->id = 'stat_win_form_div'; - $table->style[0] = 'text-align:left;'; - $table->style[1] = 'text-align:left;'; - $table->styleTable = 'margin-bottom: 20px;'; - $table->class = 'table_modal_alternate'; - - $data = []; - $data[0] = __('Refresh time'); - $data[1] = html_print_extended_select_for_time( - 'refresh', - $refresh, - '', - '', - 0, - 7, - true - ); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Begin date'); - $data[1] = html_print_input_text('start_date', $start_date, '', 10, 20, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Begin time'); - $data[1] = html_print_input_text('start_time', $start_time, '', 10, 10, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - if (!modules_is_boolean($id)) { - $data = []; - $data[0] = __('Zoom'); - $options = []; - $options[$zoom] = 'x'.$zoom; - $options[1] = 'x1'; - $options[2] = 'x2'; - $options[3] = 'x3'; - $options[4] = 'x4'; - $options[5] = 'x5'; - $data[1] = html_print_select($options, 'zoom', $zoom, '', '', 0, true, false, false); - $table->data[] = $data; - $table->rowclass[] = ''; - } - - $data = []; - $data[0] = __('Time range'); - $data[1] = html_print_extended_select_for_time( - 'period', - $period, - '', - '', - 0, - 7, - true - ); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Show events'); - $disabled = false; - if (isset($config['event_replication'])) { - if ($config['event_replication'] && !$config['show_events_in_local']) { - $disabled = true; - } - } - - $data[1] = html_print_checkbox_switch( - 'draw_events', - 1, - (bool) $draw_events, - true, - $disabled - ); - if ($disabled) { - $data[1] .= ui_print_help_tip( - __("'Show events' is disabled because this %s node is set to event replication.", get_product_name()), - true - ); - } - - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Show alerts'); - $data[1] = html_print_checkbox_switch('draw_alerts', 1, (bool) $draw_alerts, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - /* - $data = array(); - $data[0] = __('Show event graph'); - $data[1] = html_print_checkbox_switch ("show_events_graph", 1, (bool) $show_events_graph, true); - $table->data[] = $data; - $table->rowclass[] = ''; - */ - - switch ($graph_type) { - case 'boolean': - case 'sparse': - $data = []; - $data[0] = __('Show percentil'); - $data[1] = html_print_checkbox_switch('show_percentil', 1, (bool) $show_percentil, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Time compare (Overlapped)'); - $data[1] = html_print_checkbox_switch('time_compare_overlapped', 1, (bool) $time_compare_overlapped, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Time compare (Separated)'); - $data[1] = html_print_checkbox_switch('time_compare_separated', 1, (bool) $time_compare_separated, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Show unknown graph'); - $data[1] = html_print_checkbox_switch('unknown_graph', 1, (bool) $unknown_graph, true); - $table->data[] = $data; - $table->rowclass[] = ''; - break; - } - - $data = []; - $data[0] = __('Show full scale graph (TIP)'); - $data[1] = html_print_checkbox_switch( - 'fullscale', - 1, - (bool) $fullscale, - true, - false - ); - $table->data[] = $data; - $table->rowclass[] = ''; - - $form_table = html_print_table($table, true); - $form_table .= '
'.html_print_submit_button( - __('Reload'), - 'submit', - false, - 'class="sub upd"', - true - ).'
'; - - - // Menu. - $menu_form = "
".html_print_input_hidden('id', $id, true).html_print_input_hidden('label', $label, true); - - if (!empty($server_id)) { - $menu_form .= html_print_input_hidden('server', $server_id, true); - } - - if (isset($_GET['type'])) { - $type = get_parameter_get('type'); - $menu_form .= html_print_input_hidden('type', $type, true); - } - - echo $menu_form; - echo '
-
- '.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).' - '.__('Graph configuration menu').' - '.html_print_image('images/config.png', true, ['float' => 'right'], false, false, true).' -
- -
'; - echo '
'; - - // Hidden div to forced title - html_print_div( - [ - 'id' => 'forced_title_layer', - 'class' => 'forced_title_layer', - 'hidden' => true, - ] - ); + $output .= '
'; + echo $output; ?> @@ -430,9 +467,14 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1. @@ -460,21 +502,26 @@ ui_include_time_picker(true); closeText: '' }); - $.datepicker.setDefaults($.datepicker.regional[""]); + $.datepicker.setDefaults( + $.datepicker.regional[""] + ); // Menu. $('#module_graph_menu_header').on('click', function(){ var arrow = $('#module_graph_menu_header .module_graph_menu_arrow'); var arrow_up = 'arrow_up_green'; var arrow_down = 'arrow_down_green'; - if( $('.module_graph_menu_content').hasClass('module_graph_menu_content_closed')){ + if( $('.module_graph_menu_content').hasClass( + 'module_graph_menu_content_closed')){ $('.module_graph_menu_content').show(); - $('.module_graph_menu_content').removeClass('module_graph_menu_content_closed'); + $('.module_graph_menu_content').removeClass( + 'module_graph_menu_content_closed'); arrow.attr('src',arrow.attr('src').replace(arrow_down, arrow_up)); } else{ $('.module_graph_menu_content').hide(); - $('.module_graph_menu_content').addClass('module_graph_menu_content_closed'); + $('.module_graph_menu_content').addClass( + 'module_graph_menu_content_closed'); arrow.attr('src',arrow.attr('src').replace(arrow_up, arrow_down)); } }); diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 16c6223041..a49db7b7f4 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1545,7 +1545,7 @@ if (!empty($result)) { $graph_params_str = http_build_query($graph_params); - $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 1000, 700)'; + $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; $data[8] = get_module_realtime_link_graph($row); From 308598ba8d9ab4340e9a45bead211107823f2bb0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 1 Oct 2020 16:23:00 +0200 Subject: [PATCH 16/18] minor fix --- pandora_server/util/pandora_manage.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 24b206d076..4ed049eaf6 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -4631,6 +4631,8 @@ sub cli_get_module_custom_id { if (defined($custom_id)) { print $custom_id; + } else { + print "\n"; } } From 354ae8417192565016dedb89e2edc731c477dacc Mon Sep 17 00:00:00 2001 From: artica Date: Fri, 2 Oct 2020 01:00:20 +0200 Subject: [PATCH 17/18] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 523585a590..786eacd42e 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.749-201001 +Version: 7.0NG.749-201002 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 9990b4c93b..fa0313e1a7 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.749-201001" +pandora_version="7.0NG.749-201002" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 194fabf54f..51f6981346 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.749'; -use constant AGENT_BUILD => '201001'; +use constant AGENT_BUILD => '201002'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index bae05abad0..b147985914 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.749 -%define release 201001 +%define release 201002 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 47529218c9..7d2207770f 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.749 -%define release 201001 +%define release 201002 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 39091a2762..2072a2a029 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.749" -PI_BUILD="201001" +PI_BUILD="201002" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index d89212ae39..1c3d38061b 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{201001} +{201002} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 54c6de0acc..be71e56603 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.749(Build 201001)") +#define PANDORA_VERSION ("7.0NG.749(Build 201002)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 603432de13..f460bce4c5 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.749(Build 201001))" + VALUE "ProductVersion", "(7.0NG.749(Build 201002))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index c65d4869eb..d64f3a141c 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.749-201001 +Version: 7.0NG.749-201002 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index deba45bbb7..3e2c114d88 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.749-201001" +pandora_version="7.0NG.749-201002" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index a13a5c1b8f..bdf970fc3a 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC201001'; +$build_version = 'PC201002'; $pandora_version = 'v7.0NG.749'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 3052dc545c..78b28fe634 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 3bcd814580..5b0d9e5e13 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.749 -%define release 201001 +%define release 201002 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 0855533a96..bcecc75231 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.749 -%define release 201001 +%define release 201002 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 23853d080b..6360d074bb 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.749" -PI_BUILD="201001" +PI_BUILD="201002" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 9d64197c33..6a1e8f216f 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.749 PS201001"; +my $version = "7.0NG.749 PS201002"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 42551e3761..9ee2bcc0da 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.749 PS201001"; +my $version = "7.0NG.749 PS201002"; # save program name for logging my $progname = basename($0); From a5d5a45cac027a20fff677b0a910fa8e29eeb42c Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 2 Oct 2020 14:16:55 +0200 Subject: [PATCH 18/18] add render graph to reports --- pandora_console/extras/mr/42.sql | 3 + .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 10 +- .../reporting_builder.item_editor.php | 69 ++++- .../godmode/reporting/reporting_builder.php | 22 ++ .../godmode/setup/setup_visuals.php | 187 +++++++++++-- pandora_console/include/chart_generator.php | 1 + pandora_console/include/functions.php | 9 +- pandora_console/include/functions_agents.php | 45 ++- pandora_console/include/functions_graph.php | 261 ++++++++++++------ .../include/functions_reporting.php | 141 +++++----- .../include/functions_reporting_html.php | 23 +- .../include/graphs/flot/pandora.flot.js | 4 +- pandora_console/include/styles/agent_view.css | 2 +- pandora_console/include/styles/pandora.css | 1 + pandora_console/mobile/operation/agent.php | 2 - .../agentes/estado_generalagente.php | 20 +- .../agentes/interface_traffic_graph_win.php | 2 +- pandora_console/pandoradb.sql | 2 + pandora_console/pandoradb_data.sql | 4 +- 19 files changed, 577 insertions(+), 231 deletions(-) diff --git a/pandora_console/extras/mr/42.sql b/pandora_console/extras/mr/42.sql index 2714e3f491..914ae0fae7 100644 --- a/pandora_console/extras/mr/42.sql +++ b/pandora_console/extras/mr/42.sql @@ -22,4 +22,7 @@ ALTER TABLE talert_actions ADD COLUMN `field18_recovery` TEXT NOT NULL DEFAULT " ALTER TABLE talert_actions ADD COLUMN `field19_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field20_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE `treport_content` add column `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; +ALTER TABLE `treport_content_template` add column `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; + COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index edfeeb7996..e6208f034a 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -849,7 +849,8 @@ ALTER TABLE `treport_content_template` MODIFY COLUMN `historical_db` tinyint(1) MODIFY COLUMN `visual_format` tinyint(1) unsigned NOT NULL DEFAULT '0'; ALTER TABLE `treport_content_template` ADD COLUMN `landscape` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content_template` ADD COLUMN `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0; -ALTER TABLE `treport_content_template` add column `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0; +ALTER TABLE `treport_content_template` ADD COLUMN `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0; +ALTER TABLE `treport_content_template` ADD COLUMN `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; -- ---------------------------------------------------------------------- -- Table `tnews` @@ -1370,13 +1371,13 @@ ALTER TABLE `ttag` ADD COLUMN `previous_name` text NULL; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 41); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 42); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '749'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', 750); INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields'; DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password'; @@ -1692,7 +1693,8 @@ ALTER TABLE `treport_content` MODIFY COLUMN `historical_db` tinyint(1) unsigned MODIFY COLUMN `failover_type` tinyint(1) NULL DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `landscape` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content` ADD COLUMN `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0; -ALTER TABLE `treport_content` add column `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0; +ALTER TABLE `treport_content` ADD COLUMN `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0; +ALTER TABLE `treport_content` ADD COLUMN `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 471866bdb3..ed12e6b714 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -156,6 +156,8 @@ $agent_max_value = true; $agent_min_value = true; $uncompressed_module = true; +$graph_render = (empty($config['type_mode_graph']) === true) ? 0 : $config['type_mode_graph']; + switch ($action) { case 'new': $actionParameter = 'save'; @@ -259,7 +261,8 @@ switch ($action) { case 'simple_graph': $fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0; - $percentil = isset($style['percentil']) ? $config['percentil'] : 0; + $percentil = isset($style['percentil']) ? (bool) $style['percentil'] : 0; + $graph_render = $item['graph_render']; // The break hasn't be forgotten. case 'simple_baseline_graph': case 'projection_graph': @@ -653,6 +656,7 @@ switch ($action) { $period = $item['period']; $fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0; $recursion = $item['recursion']; + $graph_render = $item['graph_render']; break; case 'top_n': @@ -2091,18 +2095,24 @@ $class = 'databox filters'; - + __('Avg, max & min'), + 2 => __('Max only'), + 3 => __('Min only'), + 0 => __('Avg only'), + ]; + html_print_select( + $list_graph_render, + 'graph_render', + $graph_render ); ?> @@ -2128,9 +2138,26 @@ $class = 'databox filters'; + + + + + + + + + - + @@ -3891,6 +3918,16 @@ $(document).ready (function () { }); }); + $("#checkbox-fullscale").change(function(e){ + if(e.target.checked === true) { + $("#graph_render").prop('disabled', 'disabled'); + } else { + $("#graph_render").prop('disabled', false); + } + }); + + $('#checkbox-fullscale').trigger('change'); + $("#submit-create_item").click(function () { var type = $('#type').val(); var name = $('#text-name').val(); @@ -4906,6 +4943,7 @@ function chooseType() { $("#row_show_graph").hide(); $("#row_max_min_avg").hide(); $("#row_fullscale").hide(); + $("#row_graph_render").hide(); $("#row_time_compare_overlapped").hide(); $("#row_quantity").hide(); $("#row_exception_condition_value").hide(); @@ -5010,8 +5048,14 @@ function chooseType() { case 'simple_graph': $("#row_time_compare_overlapped").show(); $("#row_fullscale").show(); - if ($("#checkbox-percentil").prop("checked")) - $("#row_percentil").show(); + $("#row_graph_render").show(); + $("#row_percentil").show(); + + // Force type. + if('' === 'new'){ + $("#graph_render").val(); + } + // The break hasn't be forgotten, this element // only should be shown on the simple graphs. case 'simple_baseline_graph': @@ -5377,7 +5421,12 @@ function chooseType() { $("#row_description").show(); $("#row_period").show(); $("#row_historical_db_check").hide(); + $("#row_graph_render").show(); $("#row_fullscale").show(); + // Force MAX type. + if('' === 'new'){ + $("#graph_render").val(2); + } break; case 'top_n': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index b88cc5d64e..4df826d2b3 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1632,6 +1632,9 @@ switch ($action) { break; case 'simple_graph': + $values['graph_render'] = (int) get_parameter( + 'graph_render' + ); case 'simple_baseline_graph': // HACK it is saved in show_graph field. $values['show_graph'] = (int) get_parameter( @@ -1641,6 +1644,14 @@ switch ($action) { $good_format = true; break; + case 'network_interfaces_report': + $values['graph_render'] = (int) get_parameter( + 'graph_render' + ); + $values['period'] = get_parameter('period'); + $good_format = true; + break; + case 'min_value': case 'max_value': case 'avg_value': @@ -2274,6 +2285,9 @@ switch ($action) { break; case 'simple_graph': + $values['graph_render'] = (int) get_parameter( + 'graph_render' + ); case 'simple_baseline_graph': // HACK it is saved in show_graph field. $values['show_graph'] = (int) get_parameter( @@ -2283,6 +2297,14 @@ switch ($action) { $good_format = true; break; + case 'network_interfaces_report': + $values['graph_render'] = (int) get_parameter( + 'graph_render' + ); + $values['period'] = get_parameter('period'); + $good_format = true; + break; + case 'min_value': case 'max_value': case 'avg_value': diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index f8974e9770..e21c3b6e55 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -738,67 +738,166 @@ $row++; $table_chars->data = []; $table_chars->data[$row][0] = __('Graph color #1'); - $table_chars->data[$row][1] = html_print_input_text('graph_color1', $config['graph_color1'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color1', + $config['graph_color1'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #2'); - $table_chars->data[$row][1] = html_print_input_text('graph_color2', $config['graph_color2'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color2', + $config['graph_color2'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #3'); - $table_chars->data[$row][1] = html_print_input_text('graph_color3', $config['graph_color3'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color3', + $config['graph_color3'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #4'); - $table_chars->data[$row][1] = html_print_input_text('graph_color4', $config['graph_color4'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color4', + $config['graph_color4'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #5'); - $table_chars->data[$row][1] = html_print_input_text('graph_color5', $config['graph_color5'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color5', + $config['graph_color5'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #6'); - $table_chars->data[$row][1] = html_print_input_text('graph_color6', $config['graph_color6'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color6', + $config['graph_color6'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #7'); - $table_chars->data[$row][1] = html_print_input_text('graph_color7', $config['graph_color7'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color7', + $config['graph_color7'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #8'); - $table_chars->data[$row][1] = html_print_input_text('graph_color8', $config['graph_color8'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color8', + $config['graph_color8'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #9'); - $table_chars->data[$row][1] = html_print_input_text('graph_color9', $config['graph_color9'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color9', + $config['graph_color9'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Graph color #10'); - $table_chars->data[$row][1] = html_print_input_text('graph_color10', $config['graph_color10'], '', 8, 8, true); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_color10', + $config['graph_color10'], + '', + 8, + 8, + true + ); $row++; $table_chars->data[$row][0] = __('Value to interface graphics'); - $table_chars->data[$row][1] = html_print_input_text('interface_unit', $config['interface_unit'], '', 20, 20, true); + $table_chars->data[$row][1] = html_print_input_text( + 'interface_unit', + $config['interface_unit'], + '', + 20, + 20, + true + ); $row++; $disabled_graph_precision = false; - if (!enterprise_installed()) { + if (enterprise_installed() === false) { $disabled_graph_precision = true; } $table_chars->data[$row][0] = __('Data precision'); - $table_chars->data[$row][1] = html_print_input_text('graph_precision', $config['graph_precision'], '', 5, 5, true, $disabled_graph_precision, false, 'onChange="change_precision()"'); + $table_chars->data[$row][1] = html_print_input_text( + 'graph_precision', + $config['graph_precision'], + '', + 5, + 5, + true, + $disabled_graph_precision, + false, + 'onChange="change_precision()"' + ); $row++; - if (!isset($config['short_module_graph_data'])) { + if (isset($config['short_module_graph_data']) === false) { $config['short_module_graph_data'] = true; } $table_chars->data[$row][0] = __('Data precision in graphs'); - $table_chars->data[$row][1] = html_print_input_text('short_module_graph_data', $config['short_module_graph_data'], '', 5, 5, true, $disabled_graph_precision, false, 'onChange="change_precision()"'); + $table_chars->data[$row][1] = html_print_input_text( + 'short_module_graph_data', + $config['short_module_graph_data'], + '', + 5, + 5, + true, + $disabled_graph_precision, + false, + 'onChange="change_precision()"' + ); $row++; - $table_chars->data[$row][0] = __('Default line thickness for the Custom Graph.'); + $table_chars->data[$row][0] = __( + 'Default line thickness for the Custom Graph.' + ); $table_chars->data[$row][1] = html_print_input_text( 'custom_graph_width', $config['custom_graph_width'], @@ -853,7 +952,14 @@ $row++; $row++; $table_chars->data[$row][0] = __('Percentile'); - $table_chars->data[$row][1] = html_print_input_text('percentil', $config['percentil'], '', 20, 20, true); + $table_chars->data[$row][1] = html_print_input_text( + 'percentil', + $config['percentil'], + '', + 20, + 20, + true + ); $row++; $table_chars->data[$row][0] = __('Graph TIP view:'); @@ -863,17 +969,37 @@ $row++; $options_full_escale[1] = __('All'); $options_full_escale[2] = __('On Boolean graphs'); - $table_chars->data[$row][1] = html_print_select($options_full_escale, 'full_scale_option', $config['full_scale_option'], '', '', 0, true, false, false); + $table_chars->data[$row][1] = html_print_select( + $options_full_escale, + 'full_scale_option', + $config['full_scale_option'], + '', + '', + 0, + true, + false, + false + ); $row++; - $table_chars->data[$row][0] = __('Show only average'); + $table_chars->data[$row][0] = __('Graph mode'); $options_soft_graphs = []; $options_soft_graphs[0] = __('Show only average by default'); $options_soft_graphs[1] = __('Show MAX/AVG/MIN by default'); - $table_chars->data[$row][1] = html_print_select($options_soft_graphs, 'type_mode_graph', $config['type_mode_graph'], '', '', 0, true, false, false); + $table_chars->data[$row][1] = html_print_select( + $options_soft_graphs, + 'type_mode_graph', + $config['type_mode_graph'], + '', + '', + 0, + true, + false, + false + ); $row++; $table_chars->data[$row][0] = __('Zoom graphs:'); @@ -885,18 +1011,19 @@ $row++; $options_zoom_graphs[4] = 'x4'; $options_zoom_graphs[5] = 'x5'; - $table_chars->data[$row][1] = html_print_select($options_zoom_graphs, 'zoom_graph', $config['zoom_graph'], '', '', 0, true, false, false); + $table_chars->data[$row][1] = html_print_select( + $options_zoom_graphs, + 'zoom_graph', + $config['zoom_graph'], + '', + '', + 0, + true, + false, + false + ); $row++; - /* - $table_font->data[$row][0] = __('Font path'); - $fonts = load_fonts(); - $table_font->data[$row][1] = html_print_select($fonts, 'fontpath', - io_safe_output($config["fontpath"]), '', '', 0, true); - - $row++; - */ - echo '
'; echo ''.__('Charts configuration').' '.ui_print_help_icon('charts_conf_tab', true).''; html_print_table($table_chars); diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 1b3c352df9..3ed8e294db 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -198,6 +198,7 @@ if (file_exists('languages/'.$user_language.'.mo') === true) { break; case 'sparse': + $params['pdf'] = true; echo grafico_modulo_sparse($params); break; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 9485d39fc1..3dada9977a 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3771,7 +3771,11 @@ function series_type_graph_array($data, $show_elements_graph) } } else { $name_legend = ''; - if ((int) $config['type_mode_graph'] === 1) { + if (isset($show_elements_graph['fullscale']) === true + && (int) $show_elements_graph['fullscale'] === 1 + ) { + $name_legend .= 'Tip: '; + } else { $name_legend .= 'Avg: '; } @@ -3839,7 +3843,8 @@ function series_type_graph_array($data, $show_elements_graph) $data_return['series_type'][$key] = $type_graph; $name_legend = ''; - if ((int) $config['type_mode_graph'] === 1) { + + if ((int) $show_elements_graph['type_mode_graph'] != 0) { if (strpos($key, 'min') !== false) { $name_legend .= 'Min: '; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 96af9612e5..beff278dc1 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2957,7 +2957,6 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false) } $ni_by_agents = []; - foreach ($agents as $agent) { $agent_id = $agent['id_agente']; $agent_group_id = $agent['id_grupo']; @@ -2965,27 +2964,52 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false) $agent_interfaces = []; $accepted_module_types = []; - $remote_snmp_proc = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'remote_snmp_proc'); + $remote_snmp_proc = (int) db_get_value( + 'id_tipo', + 'ttipo_modulo', + 'nombre', + 'remote_snmp_proc' + ); if ($remote_snmp_proc) { $accepted_module_types[] = $remote_snmp_proc; } - $remote_icmp_proc = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'remote_icmp_proc'); + $remote_icmp_proc = (int) db_get_value( + 'id_tipo', + 'ttipo_modulo', + 'nombre', + 'remote_icmp_proc' + ); if ($remote_icmp_proc) { $accepted_module_types[] = $remote_icmp_proc; } - $remote_tcp_proc = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'remote_tcp_proc'); + $remote_tcp_proc = (int) db_get_value( + 'id_tipo', + 'ttipo_modulo', + 'nombre', + 'remote_tcp_proc' + ); if ($remote_tcp_proc) { $accepted_module_types[] = $remote_tcp_proc; } - $generic_proc = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'generic_proc'); + $generic_proc = (int) db_get_value( + 'id_tipo', + 'ttipo_modulo', + 'nombre', + 'generic_proc' + ); if ($generic_proc) { $accepted_module_types[] = $generic_proc; } - $remote_snmp = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'remote_snmp'); + $remote_snmp = (int) db_get_value( + 'id_tipo', + 'ttipo_modulo', + 'nombre', + 'remote_snmp' + ); if ($remote_snmp) { $accepted_module_types[] = $remote_snmp; } @@ -3008,8 +3032,13 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false) } $filter = " tagente_modulo.id_agente = $agent_id AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo IN (".implode(',', $accepted_module_types).") AND (tagente_modulo.nombre LIKE '%_ifOperStatus' OR tagente_modulo.nombre LIKE 'ifOperStatus_%')"; - $modules = agents_get_modules($agent_id, $columns, $filter, true, false); - + $modules = agents_get_modules( + $agent_id, + $columns, + $filter, + true, + false + ); if (!empty($modules)) { $interfaces = []; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 40b9ed0900..9747cb1033 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -299,13 +299,17 @@ function grafico_modulo_sparse_data( return false; } - $array_data = series_suffix_leyend( - 'sum', - $series_suffix, - $agent_module_id, - $data_module_graph, - $array_data - ); + if ((int) $params['type_mode_graph'] !== 2 + && (int) $params['type_mode_graph'] !== 3 + ) { + $array_data = series_suffix_leyend( + 'sum', + $series_suffix, + $agent_module_id, + $data_module_graph, + $array_data + ); + } if ($params['percentil']) { $array_data = series_suffix_leyend( @@ -317,22 +321,30 @@ function grafico_modulo_sparse_data( ); } - if ($params['type_mode_graph']) { - $array_data = series_suffix_leyend( - 'min', - $series_suffix, - $agent_module_id, - $data_module_graph, - $array_data - ); + if ($params['type_mode_graph'] > 0) { + if ((int) $params['type_mode_graph'] === 1 + || (int) $params['type_mode_graph'] === 3 + ) { + $array_data = series_suffix_leyend( + 'min', + $series_suffix, + $agent_module_id, + $data_module_graph, + $array_data + ); + } - $array_data = series_suffix_leyend( - 'max', - $series_suffix, - $agent_module_id, - $data_module_graph, - $array_data - ); + if ((int) $params['type_mode_graph'] === 1 + || (int) $params['type_mode_graph'] === 2 + ) { + $array_data = series_suffix_leyend( + 'max', + $series_suffix, + $agent_module_id, + $data_module_graph, + $array_data + ); + } } // This is for a specific type of report that consists in passing @@ -614,6 +626,7 @@ function grafico_modulo_sparse_data( * 'return_img_base_64' => false, * 'image_treshold' => false, * 'graph_combined' => false, + * 'graph_render' => 0, * 'zoom' => 1, * 'server_id' => null, * 'stacked' => 0. @@ -776,14 +789,28 @@ function grafico_modulo_sparse($params, $server_name='') if (!isset($params['type_mode_graph'])) { $params['type_mode_graph'] = $config['type_mode_graph']; + if (isset($params['graph_render']) === true) { + $params['type_mode_graph'] = $params['graph_render']; + } } if (!isset($params['projection'])) { $params['projection'] = false; } + if (isset($params['pdf']) === false) { + $params['pdf'] = false; + } + if (!isset($params['agent_module_id'])) { - return graph_nodata_image($params['width'], $params['height']); + return graph_nodata_image( + $params['width'], + $params['height'], + 'area', + '', + false, + $params['pdf'] + ); } else { $agent_module_id = $params['agent_module_id']; } @@ -816,12 +843,6 @@ function grafico_modulo_sparse($params, $server_name='') $date_array['final_date'] = $params['date']; $date_array['start_date'] = ($params['date'] - $params['period']); - if (is_metaconsole()) { - $id_meta = metaconsole_get_id_server($server_name); - $server = metaconsole_get_connection_by_id($id_meta); - metaconsole_connect($server); - } - if ($agent_module_id) { $module_data = db_get_row_sql( 'SELECT * FROM tagente_modulo @@ -979,7 +1000,14 @@ function grafico_modulo_sparse($params, $server_name='') $array_events_alerts ); } else { - $return = graph_nodata_image($params['width'], $params['height']); + $return = graph_nodata_image( + $params['width'], + $params['height'], + 'area', + '', + false, + $params['pdf'] + ); } $return .= '
'; @@ -1006,7 +1034,14 @@ function grafico_modulo_sparse($params, $server_name='') $array_events_alerts ); } else { - $return .= graph_nodata_image($params['width'], $params['height']); + $return = graph_nodata_image( + $params['width'], + $params['height'], + 'area', + '', + false, + $params['pdf'] + ); } } else { if (empty($array_data) === false) { @@ -1027,15 +1062,13 @@ function grafico_modulo_sparse($params, $server_name='') $params['width'], $params['height'], 'area', - __('No data to display within the selected interval') + __('No data to display within the selected interval'), + false, + $params['pdf'] ); } } - if (is_metaconsole()) { - metaconsole_restore_db(); - } - return $return; } @@ -1247,8 +1280,17 @@ function graphic_combined_module( } if (!isset($params['type_mode_graph'])) { - // $config['type_mode_graph'] $params['type_mode_graph'] = 0; + if (isset($params['graph_render']) === true) { + $params['type_mode_graph'] = $params['graph_render']; + $params_combined['type_mode_graph'] = $params['graph_render']; + } + } + + if (isset($params['fullscale']) === false) { + $params_combined['fullscale'] = false; + } else { + $params_combined['fullscale'] = $params['fullscale']; } $params['graph_combined'] = true; @@ -1281,7 +1323,7 @@ function graphic_combined_module( $sources = false; - if ($params_combined['id_graph'] == 0) { + if ((int) $params_combined['id_graph'] === 0) { $count_modules = count($module_list); if (!$params_combined['weight_list']) { @@ -1290,7 +1332,7 @@ function graphic_combined_module( if ($count_modules > 0) { foreach ($module_list as $key => $value) { - $sources[$key]['id_server'] = (isset($value['id_server']) === true) ? $value['id_server'] : $params['id_server']; + $sources[$key]['id_server'] = (isset($value['id_server']) === true) ? $value['id_server'] : $params['server_id']; $sources[$key]['id_agent_module'] = $value['module']; $sources[$key]['weight'] = $weights[$key]; $sources[$key]['label'] = $params_combined['labels']; @@ -4258,21 +4300,23 @@ function fullscale_data( } } - if (isset($v['datos']) && $v['datos']) { - // Max. - if ($v['datos'] >= $max_value) { + // Max. + if ($v['datos'] === false || $v['datos'] >= $max_value) { + if ($v['datos'] === false) { + $max_value = 0; + } else { $max_value = $v['datos']; } - - // Min. - if ($v['datos'] <= $min_value) { - $min_value = $v['datos']; - } - - // Avg sum. - $sum_data += $v['datos']; } + // Min. + if ($v['datos'] <= $min_value) { + $min_value = $v['datos']; + } + + // Avg sum. + $sum_data += $v['datos']; + // Avg count. $count_data++; @@ -4291,23 +4335,30 @@ function fullscale_data( $real_date = ($k['data'][0]['utimestamp'] * 1000); } - $data['sum'.$series_suffix]['data'][] = [ - $real_date, - ($sum_data / $count_data), - ]; + if ($type_mode_graph <= 1) { + $data['sum'.$series_suffix]['data'][] = [ + $real_date, + ($sum_data / $count_data), + ]; + } + if ($type_mode_graph && !$params['baseline']) { - if ($min_value != PHP_INT_MAX) { - $data['min'.$series_suffix]['data'][] = [ - $real_date, - $min_value, - ]; + if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 3) { + if ($min_value != PHP_INT_MAX) { + $data['min'.$series_suffix]['data'][] = [ + $real_date, + $min_value, + ]; + } } - if ($max_value != (-PHP_INT_MAX)) { - $data['max'.$series_suffix]['data'][] = [ - $real_date, - $max_value, - ]; + if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 2) { + if ($max_value != (-PHP_INT_MAX)) { + $data['max'.$series_suffix]['data'][] = [ + $real_date, + $max_value, + ]; + } } } else { if ($min_value != PHP_INT_MAX) { @@ -4400,25 +4451,33 @@ function fullscale_data( } } - $data['sum'.$series_suffix]['min'] = $min_value_total; - $data['sum'.$series_suffix]['max'] = $max_value_total; - $data['sum'.$series_suffix]['avg'] = 0; - if (isset($count_data_total) === true) { - $data['sum'.$series_suffix]['avg'] = ($sum_data_total / $count_data_total); + if ($type_mode_graph <= 1) { + $data['sum'.$series_suffix]['min'] = $min_value_total; + $data['sum'.$series_suffix]['max'] = $max_value_total; + $data['sum'.$series_suffix]['avg'] = 0; + if (isset($count_data_total) === true) { + $data['sum'.$series_suffix]['avg'] = ($sum_data_total / $count_data_total); + } } if ($type_mode_graph && !$params['baseline']) { - $data['min'.$series_suffix]['min'] = $min_value_min; - $data['min'.$series_suffix]['max'] = $min_value_max; - $data['min'.$series_suffix]['avg'] = ($sum_data_min / $count_data_total); + if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 3) { + $data['min'.$series_suffix]['min'] = $min_value_min; + $data['min'.$series_suffix]['max'] = $min_value_max; + $data['min'.$series_suffix]['avg'] = ($sum_data_min / $count_data_total); + } - $data['max'.$series_suffix]['min'] = $max_value_min; - $data['max'.$series_suffix]['max'] = $max_value_max; - $data['max'.$series_suffix]['avg'] = ($sum_data_max / $count_data_total); + if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 2) { + $data['max'.$series_suffix]['min'] = $max_value_min; + $data['max'.$series_suffix]['max'] = $max_value_max; + $data['max'.$series_suffix]['avg'] = ($sum_data_max / $count_data_total); + } - $data['sum'.$series_suffix]['min'] = $avg_value_min; - $data['sum'.$series_suffix]['max'] = $avg_value_max; - $data['sum'.$series_suffix]['avg'] = ($sum_data_avg / $count_data_total); + if ($type_mode_graph <= 1) { + $data['sum'.$series_suffix]['min'] = $avg_value_min; + $data['sum'.$series_suffix]['max'] = $avg_value_max; + $data['sum'.$series_suffix]['avg'] = ($sum_data_avg / $count_data_total); + } } } else { foreach ($data_uncompress as $k) { @@ -4543,20 +4602,28 @@ function fullscale_data( $last_data, ]; } else { - $data['sum'.$series_suffix]['data'][] = [ - ($date_array['final_date'] * 1000), - $last_data, - ]; + if ($type_mode_graph <= 1) { + $data['sum'.$series_suffix]['data'][] = [ + ($date_array['final_date'] * 1000), + $last_data, + ]; + } + if ($data_slice) { if ($type_mode_graph && !$params['baseline']) { - $data['min'.$series_suffix]['data'][] = [ - ($date_array['final_date'] * 1000), - $min_value, - ]; - $data['max'.$series_suffix]['data'][] = [ - ($date_array['final_date'] * 1000), - $max_value, - ]; + if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 3) { + $data['min'.$series_suffix]['data'][] = [ + ($date_array['final_date'] * 1000), + $min_value, + ]; + } + + if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 2) { + $data['max'.$series_suffix]['data'][] = [ + ($date_array['final_date'] * 1000), + $max_value, + ]; + } } else { $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['min'] = $min_value; $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = 0; @@ -4975,8 +5042,20 @@ function graph_nodata_image( $height=110, $type='area', $text='', - $percent=false + $percent=false, + $base64=false ) { + if ($base64 === true) { + $dataImg = file_get_contents( + html_print_image( + 'images/image_problem_area.png', + false, + ['style' => 'width:150px;'] + ) + ); + return base64_encode($dataImg); + } + $image = ui_get_full_url( 'images/image_problem_area.png', false, diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index a27be4f530..818af98197 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3684,17 +3684,24 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic', $return['failed'] = null; $return['data'] = []; - if (is_metaconsole()) { + if (is_metaconsole() === true) { metaconsole_restore_db(); $server_names = metaconsole_get_connection_names(); - if (isset($server_names) && is_array($server_names)) { + + if (isset($server_names) === true + && is_array($server_names) === true + ) { foreach ($server_names as $key => $value) { $id_meta = metaconsole_get_id_server($value); $connection = metaconsole_get_connection_by_id($id_meta); if (metaconsole_connect($connection) != NOERR) { continue; } else { - $network_interfaces_by_agents = agents_get_network_interfaces(false, $filter); + $network_interfaces_by_agents = agents_get_network_interfaces( + false, + $filter + ); + $return = agents_get_network_interfaces_array( $network_interfaces_by_agents, $return, @@ -3737,81 +3744,90 @@ function agents_get_network_interfaces_array( $pdf, $id_meta ) { - if (empty($network_interfaces_by_agents)) { - $return['failed'] = __('The group has no agents or none of the agents has any network interface'); + global $config; + + if (empty($network_interfaces_by_agents) === true + && is_metaconsole() === false + ) { + $return['failed'] = __( + 'The group has no agents or none of the agents has any network interface' + ); $return['data'] = []; } else { - foreach ($network_interfaces_by_agents as $agent_id => $agent) { - $row_data = []; - $row_data['agent'] = $agent['name']; - $row_data['interfaces'] = []; - foreach ($agent['interfaces'] as $interface_name => $interface) { - $row_interface = []; - $row_interface['name'] = $interface_name; - $row_interface['ip'] = $interface['ip']; - $row_interface['mac'] = $interface['mac']; - $row_interface['status'] = $interface['status_image']; - $row_interface['chart'] = null; + if (isset($network_interfaces_by_agents) === true + && is_array($network_interfaces_by_agents) === true + ) { + foreach ($network_interfaces_by_agents as $agent_id => $agent) { + $row_data = []; + $row_data['agent'] = $agent['name']; + $row_data['interfaces'] = []; + foreach ($agent['interfaces'] as $interface_name => $interface) { + $row_interface = []; + $row_interface['name'] = $interface_name; + $row_interface['ip'] = $interface['ip']; + $row_interface['mac'] = $interface['mac']; + $row_interface['status'] = $interface['status_image']; + $row_interface['chart'] = null; - $width = null; + $params = [ + 'period' => $content['period'], + 'unit_name' => array_fill(0, count($interface['traffic']), __('bytes/s')), + 'date' => $report['datetime'], + 'only_image' => $pdf, + 'homeurl' => $config['homeurl'], + 'fullscale' => $fullscale, + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'], + 'landscape' => $content['landscape'], + 'return_img_base_64' => true, + 'graph_render' => $content['graph_render'], + ]; - $params = [ - 'period' => $content['period'], - 'width' => $width, - 'unit_name' => array_fill(0, count($interface['traffic']), __('bytes/s')), - 'date' => $report['datetime'], - 'only_image' => $pdf, - 'homeurl' => $config['homeurl'], - 'fullscale' => $fullscale, - 'server_id' => $id_meta, - 'height' => $config['graph_image_height'], - 'landscape' => $content['landscape'], - 'return_img_base_64' => true, - ]; + $params_combined = [ + 'labels' => array_keys($interface['traffic']), + 'modules_series' => array_values($interface['traffic']), + 'stacked' => CUSTOM_GRAPH_LINE, + ]; - $params_combined = [ - 'labels' => array_keys($interface['traffic']), - 'modules_series' => array_values($interface['traffic']), - ]; + switch ($type) { + case 'dinamic': + case 'static': + if (!empty($interface['traffic'])) { + if ($pdf === false) { + $row_interface['chart'] = graphic_combined_module( + array_values($interface['traffic']), + $params, + $params_combined + ); + } else { + $row_interface['chart'] = ''; + } + } + break; - switch ($type) { - case 'dinamic': - case 'static': - if (!empty($interface['traffic'])) { - if ($pdf === false) { + case 'data': + if (!empty($interface['traffic'])) { + $params['return_data'] = true; $row_interface['chart'] = graphic_combined_module( array_values($interface['traffic']), $params, $params_combined ); - } else { - $row_interface['chart'] = ''; } - } - break; + break; + } - case 'data': - if (!empty($interface['traffic'])) { - $params['return_data'] = true; - $row_interface['chart'] = graphic_combined_module( - array_values($interface['traffic']), - $params, - $params_combined - ); - } - break; + $row_data['interfaces'][] = $row_interface; } - $row_data['interfaces'][] = $row_interface; + $return['data'][] = $row_data; } - - $return['data'][] = $row_data; } } @@ -8435,6 +8451,7 @@ function reporting_simple_graph( 'landscape' => $content['landscape'], 'backgroundColor' => 'transparent', 'return_img_base_64' => true, + 'graph_render' => $content['graph_render'], ]; if ($only_image === false) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 533c8680ec..22dd951105 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2516,7 +2516,7 @@ function reporting_html_group_configuration($table, $item, $pdf=0) function reporting_html_network_interfaces_report($table, $item, $pdf=0) { $return_pdf = ''; - if (!empty($item['failed'])) { + if (empty($item['failed']) === false) { if ($pdf === 0) { $table->colspan['interfaces']['cell'] = 3; $table->cellstyle['interfaces']['cell'] = 'text-align: left;'; @@ -5120,7 +5120,7 @@ function reporting_get_last_activity() function reporting_get_event_histogram($events, $text_header_event=false) { global $config; - if (!defined('METACONSOLE')) { + if (!is_metaconsole()) { include_once $config['homedir'].'/include/graphs/functions_gd.php'; } else { include_once '../../include/graphs/functions_gd.php'; @@ -5128,7 +5128,7 @@ function reporting_get_event_histogram($events, $text_header_event=false) $max_value = count($events); - if (defined('METACONSOLE')) { + if (is_metaconsole()) { $max_value = SECONDS_1HOUR; } @@ -5149,7 +5149,7 @@ function reporting_get_event_histogram($events, $text_header_event=false) EVENT_CRIT_CRITICAL => COL_CRITICAL, ]; - if (defined('METACONSOLE')) { + if (is_metaconsole()) { $full_legend = []; $cont = 0; } @@ -5193,7 +5193,7 @@ function reporting_get_event_histogram($events, $text_header_event=false) break; } - if (defined('METACONSOLE')) { + if (is_metaconsole()) { $full_legend[$cont] = $data['timestamp']; $graph_data[] = [ 'data' => $color, @@ -5212,17 +5212,18 @@ function reporting_get_event_histogram($events, $text_header_event=false) $table->width = '100%'; $table->data = []; $table->size = []; + $table->size[0] = '100%'; $table->head = []; $table->title = ''.$text_header_event.''; $table->data[0][0] = ''; - if (!empty($graph_data)) { - $url_slice = defined('METACONSOLE') ? $url : $urlImage; + if (empty($graph_data) === false) { + $url_slice = is_metaconsole() ? $url : $urlImage; $slicebar = flot_slicesbar_graph( $graph_data, $max_value, - 100, + '450px;border:0', 25, $full_legend, $colors, @@ -5235,8 +5236,8 @@ function reporting_get_event_histogram($events, $text_header_event=false) 0, [], true, - $ttl, - true, + 1, + false, false ); @@ -5245,7 +5246,7 @@ function reporting_get_event_histogram($events, $text_header_event=false) $table->data[0][0] = __('No events'); } - if (!defined('METACONSOLE')) { + if (!is_metaconsole()) { if (!$text_header_event) { $event_graph = '
'.$text_header_event.''.html_print_table($table, true).'
'; diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index e764c6b20f..6cd5e482c9 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2469,7 +2469,9 @@ function pandoraFlotArea( }); label_aux = - legend[series.label].split(":")[0] + data_legend[series.label]; + legend[series.label].split(": Min")[0] + + ": " + + data_legend[series.label]; $("#legend_" + graph_id + " .legendLabel") .eq(i) .html(label_aux); diff --git a/pandora_console/include/styles/agent_view.css b/pandora_console/include/styles/agent_view.css index 60bed6ca29..e93449ff63 100644 --- a/pandora_console/include/styles/agent_view.css +++ b/pandora_console/include/styles/agent_view.css @@ -8,7 +8,7 @@ div#bullets_modules span { } table#agent_interface_info .noresizevc.graph { - width: 500px; + margin-bottom: 10px; } div.agent_details_agent_alias { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 98963ee2a2..2ee0735edc 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -3077,6 +3077,7 @@ div.nodata_container { display: table; } +div#stat-win-interface-graph div.nodata_container, div#stat-win-module-graph div.nodata_container { width: 30%; height: 100%; diff --git a/pandora_console/mobile/operation/agent.php b/pandora_console/mobile/operation/agent.php index 95e4ca5bbf..80896ac988 100644 --- a/pandora_console/mobile/operation/agent.php +++ b/pandora_console/mobile/operation/agent.php @@ -215,8 +215,6 @@ class Agent $status_chart_width = 160; $graph_width = 160; - hd($this->agent, true); - $html = '
'; $html .= ''.__('Modules by status').''; $html .= '
'; diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 58df460112..df788514a1 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -32,7 +32,6 @@ global $config; require_once 'include/functions_agents.php'; require_once $config['homedir'].'/include/functions_graph.php'; -include_graphs_dependencies(); require_once $config['homedir'].'/include/functions_groups.php'; require_once $config['homedir'].'/include/functions_ui.php'; require_once $config['homedir'].'/include/functions_incidents.php'; @@ -611,7 +610,7 @@ if (!empty($network_interfaces)) { $table_interface->style = []; $table_interface->style['interface_status'] = 'width: 30px;padding-top:0px;padding-bottom:0px;'; $table_interface->style['interface_graph'] = 'width: 20px;padding-top:0px;padding-bottom:0px;'; - $table_interface->style['interface_event_graph'] = 'width: 100%;padding-top:0px;padding-bottom:0px;'; + $table_interface->style['interface_event_graph'] = 'width: 35%;padding-top:0px;padding-bottom:0px;'; $table_interface->align['interface_event_graph'] = 'right'; // $table_interface->style['interface_event_graph'] = 'width: 5%;padding-top:0px;padding-bottom:0px;'; $table_interface->align['interface_event_graph_text'] = 'left'; @@ -619,7 +618,7 @@ if (!empty($network_interfaces)) { $table_interface->align['interface_name'] = 'left'; $table_interface->align['interface_ip'] = 'left'; $table_interface->align['last_contact'] = 'left'; - $table_interface->style['last_contact'] = 'width: 40%;padding-top:0px;padding-bottom:0px;'; + $table_interface->style['last_contact'] = 'width: 20%;padding-top:0px;padding-bottom:0px;'; $table_interface->style['interface_ip'] = 'width: 8%;padding-top:0px;padding-bottom:0px;'; $table_interface->style['interface_mac'] = 'width: 12%;padding-top:0px;padding-bottom:0px;'; @@ -729,9 +728,15 @@ if (!empty($network_interfaces)) { $text_event_header = __('Events info (24hr.)'); if (!$events) { $no_events = ['color' => ['criticity' => 2]]; - $e_graph = reporting_get_event_histogram($no_events, $text_event_header); + $e_graph = reporting_get_event_histogram( + $no_events, + $text_event_header + ); } else { - $e_graph = reporting_get_event_histogram($events, $text_event_header); + $e_graph = reporting_get_event_histogram( + $events, + $text_event_header + ); } $data = []; @@ -865,6 +870,9 @@ echo $agent_incidents; if (isset($table_interface)) { ui_toggle( html_print_table($table_interface, true), - ''.__('Interface information (SNMP)').'' + ''.__('Interface information (SNMP)').'', + '', + 'interface-table-status-agent', + true ); } diff --git a/pandora_console/operation/agentes/interface_traffic_graph_win.php b/pandora_console/operation/agentes/interface_traffic_graph_win.php index b34c92efec..6e7e9f8098 100644 --- a/pandora_console/operation/agentes/interface_traffic_graph_win.php +++ b/pandora_console/operation/agentes/interface_traffic_graph_win.php @@ -302,7 +302,7 @@ html_print_div( ); // Graph. -echo '
'; +echo '
'; $height = 280; $width = '90%'; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b8aa4382c7..f17bdf0c9e 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1544,6 +1544,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `landscape` tinyint(1) UNSIGNED NOT NULL default 0, `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0, `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0, + `graph_render` tinyint(1) UNSIGNED NOT NULL default 0, PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) ON UPDATE CASCADE ON DELETE CASCADE @@ -3123,6 +3124,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( `landscape` tinyint(1) UNSIGNED NOT NULL default 0, `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0, `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0, + `graph_render` tinyint(1) UNSIGNED NOT NULL default 0, PRIMARY KEY(`id_rc`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 0c0fde0fba..bbd94738b0 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 41), +('MR', 42), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package_enterprise', '749'), +('current_package_enterprise', 750), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'), ('custom_docs_logo', 'default_docs.png'), ('custom_support_logo', 'default_support.png'),