From fd91ba63f673d8eab9f41c8242de3b87bbce8e04 Mon Sep 17 00:00:00 2001
From: fermin831 <fermin.hernandez@artica.es>
Date: Mon, 7 May 2018 12:53:12 +0200
Subject: [PATCH] Added realtime graph to monitor view

---
 pandora_console/include/ajax/module.php           |  3 ++-
 pandora_console/include/functions_modules.php     |  9 ++++++++-
 .../operation/agentes/status_monitor.php          | 15 +++++++++------
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php
index 7f81514b06..10b181baee 100755
--- a/pandora_console/include/ajax/module.php
+++ b/pandora_console/include/ajax/module.php
@@ -1084,7 +1084,8 @@ if ($list_modules) {
 			$win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"]));
 			
 			// Try to display the SNMP module realtime graph
-			$data[8] .= get_module_realtime_link_graph($module);
+			$rt_button .= get_module_realtime_link_graph($module);
+			if (!empty($rt_button)) $data[8] = $rt_button .  "&nbsp;&nbsp;";
 
 			# Show events for boolean modules by default.
 			if ($graph_type == 'boolean') {
diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php
index b4490003a4..f166aa1a23 100755
--- a/pandora_console/include/functions_modules.php
+++ b/pandora_console/include/functions_modules.php
@@ -2692,7 +2692,14 @@ function recursive_get_dt_from_modules_tree (&$f_modules, $modules, $deep) {
  * @return string All the HTML code to paint the button
  */
 function get_module_realtime_link_graph ($module) {
+	global $config;
 
+	// Sometimes some parameters are renamed
+	if (!isset($module['id_tipo_modulo'])) $module['id_tipo_modulo'] = $module['module_type'];
+	if (!isset($module['nombre'])) $module['nombre'] = $module['module_name'];
+
+	// Avoid to show on metaconsole
+	if (is_metaconsole()) return '';
 	// Realtime graph is an extension and it should be enabled
 	if (!extensions_is_enabled_extension("realtime_graphs.php")) return '';
 	// Only to remote_snmp, remote_snmp_proc. snmp_snmp_inc
@@ -2727,7 +2734,7 @@ function get_module_realtime_link_graph ($module) {
 
 	$link_button = '<a href="javascript:winopeng_var(\''.$link.'\',\''.$win_handle.'\', 850, 480)">' .
 		html_print_image("images/realtime_shortcut.png", true, array("border" => '0', "alt" => "")) .
-	'</a> &nbsp;&nbsp;';
+	'</a>';
 
 	return $link_button;
 }
diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php
index f630953dd5..57946cf610 100644
--- a/pandora_console/operation/agentes/status_monitor.php
+++ b/pandora_console/operation/agentes/status_monitor.php
@@ -753,7 +753,11 @@ switch ($config['dbtype']) {
 			tagente.id_grupo AS id_group, 
 			tagente.id_agente AS id_agent, 
 			tagente_modulo.id_tipo_modulo AS module_type,
-			tagente_modulo.module_interval, 
+			tagente_modulo.module_interval,
+			tagente_modulo.tcp_send,
+			tagente_modulo.ip_target,
+			tagente_modulo.snmp_community,
+			tagente_modulo.snmp_oid,
 			tagente_estado.datos, 
 			tagente_estado.estado,
 			tagente_modulo.min_warning,
@@ -1272,12 +1276,11 @@ if (!empty($result)) {
 			$graph_params_str = http_build_query($graph_params);
 			
 			$link = 'winopeng(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\')';
-			
-			$data[7] = '';
-			
+
+			$data[7] = get_module_realtime_link_graph($row);
+
 			if(!is_snapshot_data($row['datos'])){
-			
-			$data[7] = '<a href="javascript:'.$link.'">' . html_print_image('images/chart_curve.png', true, array('border' => '0', 'alt' => '')) .  '</a>';
+				$data[7] .= '<a href="javascript:'.$link.'">' . html_print_image('images/chart_curve.png', true, array('border' => '0', 'alt' => '')) .  '</a>';
 			}
 			$data[7] .= '<a href="javascript: ' .
 				'show_module_detail_dialog(' .