From 55867796e462e74feb50a498908f1258f203d831 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 12 Apr 2013 09:27:55 +0000 Subject: [PATCH] 2013-04-12 Sergio Martin * include/functions_graph.php: Optimize the event graphs queries that appear in tactican and agent view * extensions/net_tools.php extensions/ssh_gateway.php extensions/vnc_view.php: Fixing the network extensions in extensions manager git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7969 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 +++++ pandora_console/extensions/net_tools.php | 4 +- pandora_console/extensions/ssh_gateway.php | 2 +- pandora_console/extensions/vnc_view.php | 2 +- pandora_console/include/functions_graph.php | 44 ++++++++++----------- 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 322343fb7b..953b9639c8 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-04-12 Sergio Martin + + * include/functions_graph.php: Optimize the event graphs + queries that appear in tactican and agent view + + * extensions/net_tools.php + extensions/ssh_gateway.php + extensions/vnc_view.php: Fixing the network extensions in + extensions manager + 2013-04-11 Miguel de Dios * include/graphs/functions_flot.php, diff --git a/pandora_console/extensions/net_tools.php b/pandora_console/extensions/net_tools.php index 2b7c1c091c..bdc32a8cf0 100644 --- a/pandora_console/extensions/net_tools.php +++ b/pandora_console/extensions/net_tools.php @@ -15,11 +15,11 @@ // GNU General Public License for more details. $id_agente = get_parameter ("id_agente"); - + // This extension is usefull only if the agent has associated IP $address = agents_get_address($id_agente); -if(!empty($address)) { +if(!empty($address) || empty($id_agente)) { extensions_add_opemode_tab_agent ('network_tools','Network Tools','extensions/net_tools/nettool.png',"main_net_tools", "v1r1"); } diff --git a/pandora_console/extensions/ssh_gateway.php b/pandora_console/extensions/ssh_gateway.php index 3e09fa3441..c3ea001e2c 100644 --- a/pandora_console/extensions/ssh_gateway.php +++ b/pandora_console/extensions/ssh_gateway.php @@ -19,7 +19,7 @@ $id_agente = get_parameter ("id_agente"); // This extension is usefull only if the agent has associated IP $address = agents_get_address($id_agente); -if(!empty($address)) { +if(!empty($address) || empty($id_agente)) { extensions_add_opemode_tab_agent ('ssh_gateway','SSH Gateway','extensions/ssh_gateway/secure_console.png',"ssh_gateway", "v1r1"); } diff --git a/pandora_console/extensions/vnc_view.php b/pandora_console/extensions/vnc_view.php index 7d7fc24da6..bca0ceab47 100644 --- a/pandora_console/extensions/vnc_view.php +++ b/pandora_console/extensions/vnc_view.php @@ -27,7 +27,7 @@ $id_agente = get_parameter ("id_agente"); // This extension is usefull only if the agent has associated IP $address = agents_get_address($id_agente); -if(!empty($address)) { +if(!empty($address) || empty($id_agente)) { extensions_add_opemode_tab_agent('vnc_view', __('VNC view'), 'images/vnc.png', 'vnc_view', "v1r1"); } ?> diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 672902bdc3..d4e7904a4a 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1439,19 +1439,17 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) { case "mysql": case "postgresql": $sql = sprintf ('SELECT COUNT(id_evento) AS count_number, - nombre - FROM tevento, tagente_modulo - WHERE id_agentmodule = id_agente_modulo - AND disabled = 0 AND tevento.id_agente = %d - GROUP BY id_agentmodule, nombre ORDER BY count_number DESC LIMIT %d', $id_agent, $max_items); + id_agentmodule + FROM tevento + WHERE tevento.id_agente = %d + GROUP BY id_agentmodule ORDER BY count_number DESC LIMIT %d', $id_agent, $max_items); break; case "oracle": $sql = sprintf ('SELECT COUNT(id_evento) AS count_number, - dbms_lob.substr(nombre,4000,1) AS nombre - FROM tevento, tagente_modulo - WHERE (id_agentmodule = id_agente_modulo - AND disabled = 0 AND tevento.id_agente = %d) AND rownum <= %d - GROUP BY id_agentmodule, dbms_lob.substr(nombre,4000,1) ORDER BY count_number DESC', $id_agent, $max_items); + id_agentmodule + FROM tevento + WHERE tevento.id_agente = %d AND rownum <= %d + GROUP BY id_agentmodule ORDER BY count_number DESC', $id_agent, $max_items); break; } @@ -1465,20 +1463,17 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) { } foreach ($events as $event) { - $key = io_safe_output($event['nombre']) . - ' ('.$event['count_number'].')'; + if($event['id_agentmodule'] == 0) { + $key = __('System') . ' ('.$event['count_number'].')'; + } + else { + $key = modules_get_agentmodule_name ($event['id_agentmodule']) . + ' ('.$event['count_number'].')'; + } + $data[$key] = $event["count_number"]; } - /* System events */ - $sql = "SELECT COUNT(*) - FROM tevento - WHERE id_agentmodule = 0 AND id_agente = $id_agent"; - $value = db_get_sql ($sql); - if ($value > 0) { - $data[__('System').' ('.$value.')'] = $value; - } - $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("/images/logo_vertical_water.png")); @@ -2051,11 +2046,11 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = switch ($config["dbtype"]) { case "mysql": $sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente, - id_grupo, COUNT(id_agente) AS count'.$field_extra.' + COUNT(id_agente) AS count'.$field_extra.' FROM '.$event_table.' WHERE 1=1 %s %s GROUP BY id_agente'.$groupby_extra.' - ORDER BY count DESC', $url, $tags_condition); + ORDER BY count DESC LIMIT 8', $url, $tags_condition); break; case "postgresql": case "oracle": @@ -2064,7 +2059,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = FROM '.$event_table.' WHERE 1=1 %s %s GROUP BY id_agente, id_grupo'.$groupby_extra.' - ORDER BY count DESC', $url, $tags_condition); + ORDER BY count DESC LIMIT 8', $url, $tags_condition); break; } @@ -2077,6 +2072,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = $other_events = 0; foreach ($result as $row) { + $row["id_grupo"] = agents_get_agent_group ($row["id_agente"]); if (!check_acl ($config["id_user"], $row["id_grupo"], "ER") == 1) continue;