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); - ?>