2013-03-15 Vanessa Gil <vanessa.gil@artica.es>
* include/functions_treeview.php include/functions_ui.php include/ajax/module.php include/javascript/pandora_modules.js operation/tree.php: Added popup with data module. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7854 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
86efc9c40e
commit
2f7b2abe28
|
@ -1,3 +1,12 @@
|
|||
2013-03-15 Vanessa Gil <vanessa.gil@artica.es>
|
||||
|
||||
* include/functions_treeview.php
|
||||
include/functions_ui.php
|
||||
include/ajax/module.php
|
||||
include/javascript/pandora_modules.js
|
||||
operation/tree.php: Added popup with data
|
||||
module.
|
||||
|
||||
2013-03-15 Hirofumi Kosaka <kosaka@rworks.jp>
|
||||
|
||||
* include/functions_api.php: Improved performance of
|
||||
|
|
|
@ -1456,4 +1456,4 @@ switch ($activeTab) {
|
|||
reporting_enterprise_select_tab($activeTab);
|
||||
break;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -14,8 +14,13 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
include_once($config['homedir'] . "/include/functions_agents.php");
|
||||
global $config;
|
||||
|
||||
include_once($config['homedir'] . "/include/functions_agents.php");
|
||||
include_once($config['homedir'] . "/include/functions_ui.php");
|
||||
require_once ($config['homedir'] . '/enterprise/include/functions_metaconsole.php');
|
||||
ui_require_jquery_file ("ui-timepicker-addon");
|
||||
|
||||
$search_modules = get_parameter('search_modules');
|
||||
|
||||
if ($search_modules) {
|
||||
|
@ -47,4 +52,193 @@ if ($get_plugin_macros) {
|
|||
echo json_encode($macros);
|
||||
}
|
||||
|
||||
$get_module_detail = get_parameter ('get_module_detail', 0);
|
||||
|
||||
if ($get_module_detail) {
|
||||
|
||||
$module_id = get_parameter ('id_module');
|
||||
$period = get_parameter ("period", 86400);
|
||||
$group = agents_get_agentmodule_group ($module_id);
|
||||
$agentId = get_parameter("id_agent");
|
||||
$server_name = get_parameter('server_name');
|
||||
|
||||
if (defined ('METACONSOLE')) {
|
||||
$server = metaconsole_get_connection ($server_name);
|
||||
$conexion = mysql_connect ($server['dbhost'], $server['dbuser'], $server['dbpass']);
|
||||
$select_db = mysql_select_db ($server['dbname'], $conexion);
|
||||
}
|
||||
|
||||
$formtable->width = '98%';
|
||||
$formtable->class = "databox";
|
||||
$formtable->data = array ();
|
||||
$formtable->size = array ();
|
||||
|
||||
$periods = array(300=>__('5 minutes'), 1800=>__('30 minutes'), 3600=>__('1 hour'), 21600=>__('6 hours'), 43200=>__('12 hours'),
|
||||
86400=>__('1 day'), 604800=>__('1 week'), 1296000=>__('15 days'), 2592000=>__('1 month'), 7776000=>__('3 months'),
|
||||
15552000=>__('6 months'), 31104000=>__('1 year'), 62208000=>__('2 years'), 93312000=>__('3 years')
|
||||
);
|
||||
|
||||
$formtable->data[0][0] = __('Select period:');
|
||||
$formtable->data[0][1] = html_print_select ($periods, 'period', $period, '', '', 0, true, false, false);
|
||||
$formtable->data[0][2] = "<a href='javascript: show_module_detail_dialog(" . $module_id .", ". $agentId.", \"" . $server_name . "\", 0, -1)'>". html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>";
|
||||
|
||||
html_print_table($formtable);
|
||||
|
||||
$moduletype_name = modules_get_moduletype_name (modules_get_agentmodule_type ($module_id));
|
||||
|
||||
$offset = (int) get_parameter("offset");
|
||||
$block_size = (int) $config["block_size"];
|
||||
|
||||
$columns = array ();
|
||||
|
||||
$datetime_from = strtotime ($date_from.' '.$time_from);
|
||||
$datetime_to = strtotime ($date_to.' '.$time_to);
|
||||
|
||||
if ($moduletype_name == "log4x") {
|
||||
$table->width = "100%";
|
||||
|
||||
$sql_body = sprintf ("FROM tagente_datos_log4x WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period);
|
||||
|
||||
$columns = array(
|
||||
"Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center" ),
|
||||
"Sev" => array("severity", "modules_format_data", "align" => "center", "width" => "70px"),
|
||||
"Message"=> array("message", "modules_format_verbatim", "align" => "left", "width" => "45%"),
|
||||
"StackTrace" => array("stacktrace", "modules_format_verbatim", "align" => "left", "width" => "50%")
|
||||
);
|
||||
}
|
||||
else if (preg_match ("/string/", $moduletype_name)) {
|
||||
|
||||
$sql_body = sprintf (" FROM tagente_datos_string WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period);
|
||||
$columns = array(
|
||||
"Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "left"),
|
||||
"Data" => array("datos", "modules_format_data", "align" => "left"),
|
||||
"Time" => array("utimestamp", "modules_format_time", "align" => "center")
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
||||
$sql_body = sprintf (" FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period);
|
||||
|
||||
$columns = array(
|
||||
"Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "left"),
|
||||
"Data" => array("datos", "modules_format_data", "align" => "left"),
|
||||
"Time" => array("utimestamp", "modules_format_time", "align" => "center")
|
||||
);
|
||||
}
|
||||
|
||||
$sql_body = io_safe_output($sql_body);
|
||||
// Clean all codification characters
|
||||
|
||||
$sql = "SELECT * " . $sql_body;
|
||||
$sql_count = "SELECT count(*) " . $sql_body;
|
||||
|
||||
$count = db_get_value_sql ($sql_count, $conexion);
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql .= " LIMIT " . $offset . "," . $block_size;
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql .= " LIMIT " . $block_size . " OFFSET " . $offset;
|
||||
break;
|
||||
case "oracle":
|
||||
$set = array();
|
||||
$set['limit'] = $block_size;
|
||||
$set['offset'] = $offset;
|
||||
$sql = oracle_recode_query ($sql, $set);
|
||||
break;
|
||||
}
|
||||
|
||||
$result = db_get_all_rows_sql ($sql, false, true, $conexion);
|
||||
|
||||
if ($result === false) {
|
||||
$result = array ();
|
||||
}
|
||||
|
||||
if (($config['dbtype'] == 'oracle') && ($result !== false)) {
|
||||
for ($i=0; $i < count($result); $i++) {
|
||||
unset($result[$i]['rnum']);
|
||||
}
|
||||
}
|
||||
|
||||
$table->width = '98%';
|
||||
$table->data = array();
|
||||
|
||||
$index = 0;
|
||||
foreach($columns as $col => $attr) {
|
||||
$table->head[$index] = $col;
|
||||
|
||||
if (isset($attr["align"]))
|
||||
$table->align[$index] = $attr["align"];
|
||||
|
||||
if (isset($attr["width"]))
|
||||
$table->size[$index] = $attr["width"];
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
$id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo',
|
||||
'nombre', 'web_content_string');
|
||||
|
||||
foreach ($result as $row) {
|
||||
$data = array ();
|
||||
|
||||
$is_web_content_string = (bool)db_get_value_filter('id_agente_modulo',
|
||||
'tagente_modulo',
|
||||
array('id_agente_modulo' => $row['id_agente_modulo'],
|
||||
'id_tipo_modulo' => $id_type_web_content_string));
|
||||
|
||||
foreach($columns as $col => $attr) {
|
||||
if ($attr[1] != "modules_format_data") {
|
||||
$data[] = $attr[1] ($row[$attr[0]]);
|
||||
|
||||
}
|
||||
elseif (($config['command_snapshot']) && (preg_match ("/[\n]+/i", $row[$attr[0]]))) {
|
||||
// Its a single-data, multiline data (data snapshot) ?
|
||||
|
||||
|
||||
// Detect string data with \n and convert to <br>'s
|
||||
$datos = preg_replace ('/\n/i','<br>',$row[$attr[0]]);
|
||||
$datos = preg_replace ('/\s/i',' ',$datos);
|
||||
|
||||
// Because this *SHIT* of print_table monster, I cannot format properly this cells
|
||||
// so, eat this, motherfucker :))
|
||||
|
||||
$datos = "<span style='font-family: mono,monospace;'>".$datos."</span>";
|
||||
|
||||
// I dont why, but using index (value) method, data is automatically converted to html entities ¿?
|
||||
$data[$attr[1]] = $datos;
|
||||
}
|
||||
elseif ($is_web_content_string) {
|
||||
//Fixed the goliat sends the strings from web
|
||||
//without HTML entities
|
||||
|
||||
$data[$attr[1]] = io_safe_input($row[$attr[0]]);
|
||||
}
|
||||
else {
|
||||
// Just a string of alphanumerical data... just do print
|
||||
//Fixed the data from Selenium Plugin
|
||||
if ($row[$attr[0]] != strip_tags($row[$attr[0]]))
|
||||
$data[$attr[1]] = io_safe_input($row[$attr[0]]);
|
||||
else
|
||||
$data[$attr[1]] = $row[$attr[0]];
|
||||
}
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
if (count($table->data) > 200) break;
|
||||
}
|
||||
|
||||
if (empty ($table->data)) {
|
||||
echo '<h3 class="error">'.__('No available data to show').'</h3>';
|
||||
}
|
||||
else {
|
||||
ui_pagination($count, false, $offset);
|
||||
html_print_table($table);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -96,12 +96,22 @@ function treeview_printModuleTable($id_module, $server_data = false) {
|
|||
$agent_name = db_get_value('nombre', 'tagente', 'id_agente', $module['id_agente']);
|
||||
|
||||
// Actions table
|
||||
/*
|
||||
echo '<table cellspacing="4" cellpadding="4" border="0" class="databox" style="width:100%; text-align: center;">';
|
||||
echo '<tr>';
|
||||
echo '<td><form id="module_detail" method="post" action="' . $console_url . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $module['id_agente'] . '&tab=data' . $url_hash . '">';
|
||||
html_print_submit_button (__('Go to modules detail'), 'upd_button', false, 'class="sub search"');
|
||||
echo '</form></td></tr>';
|
||||
|
||||
echo '</table>';
|
||||
*/
|
||||
|
||||
//id_module and id_agent hidden
|
||||
echo '<div id="ids" style="display:none;">';
|
||||
html_print_input_text('id_module', $id_module);
|
||||
html_print_input_text('id_agent', $module['id_agente']);
|
||||
html_print_input_text('server_name', $server_name);
|
||||
echo '</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -350,10 +360,12 @@ function treeview_printTable($id_agente, $server_data = array()) {
|
|||
echo '<table cellspacing="4" cellpadding="4" border="0" class="databox" style="width:100%; text-align: center;">';
|
||||
|
||||
// If user has access to normal console
|
||||
/*
|
||||
echo '<tr>';
|
||||
echo '<td><form id="agent_detail" method="post" action="' . $console_url . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.$url_hash.'">';
|
||||
html_print_submit_button (__('Go to agent detail'), 'upd_button', false, 'class="sub search"');
|
||||
echo '</form></td></tr>';
|
||||
*/
|
||||
|
||||
echo '</table>';
|
||||
|
||||
|
@ -1202,3 +1214,89 @@ function treeview_getSecondBranchSQL ($fatherType, $id, $id_father) {
|
|||
return $sql;
|
||||
}
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
|
||||
/*
|
||||
module_id = $('#text-id_module').val();
|
||||
id_agent = $('#text-id_agent').val();
|
||||
server_name = $('#text-server_name').val();
|
||||
|
||||
$("#submit-upd_button").click( function() {
|
||||
show_module_detail_dialog(module_id, id_agent, server_name, 0, 86400);
|
||||
});
|
||||
|
||||
$("#submit-updbutton_period").click( function() {
|
||||
//refresh_period_callback();
|
||||
|
||||
var period = $('#period').val();
|
||||
console.log(period);
|
||||
show_module_detail_dialog(module_id, id_agent, server_name, 0, period);
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
// Show the modal window of an module
|
||||
function show_module_detail_dialog(module_id, id_agent, server_name, offset, period) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: "page=include/ajax/module&get_module_detail=1&server_name="+server_name+"&id_agent="+id_agent+"&id_module=" + module_id+"&offset="+offset+"&period="+period,
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
$("#module_details_window").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 620,
|
||||
height: 500
|
||||
})
|
||||
.show ();
|
||||
refresh_pagination_callback ();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_pagination_callback () {
|
||||
$(".pagination").click( function() {
|
||||
|
||||
var classes = $(this).attr('class');
|
||||
classes = classes.split(' ');
|
||||
var offset_class = classes[1];
|
||||
offset_class = offset_class.split('_');
|
||||
var offset = offset_class[1];
|
||||
|
||||
var period = $('#period').val();
|
||||
//console.log(period);
|
||||
|
||||
show_module_detail_dialog(module_id, id_agent, server_name, offset, period);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_period_callback () {
|
||||
|
||||
$("#submit-updbutton_period").click( function() {
|
||||
var period = $('#period').val();
|
||||
console.log(period);
|
||||
show_module_detail_dialog(module_id, id_agent, server_name, 0, period);
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
@ -1489,7 +1489,9 @@ function ui_pagination ($count, $url = false, $offset = 0, $pagination = 0, $ret
|
|||
$inicio_bloque_fake = $inicio_bloque + 1;
|
||||
// To Calculate last block (doesnt end with round data,
|
||||
// it must be shown if not round to block limit)
|
||||
$output .= '<a class="pagination" href="'.$url.'&'.$offset_name.'='.$inicio_bloque.'">';
|
||||
$link_offset = $config['block_size'] * $i;
|
||||
|
||||
$output .= '<a class="pagination offset_' . $link_offset . '" href="'.$url.'&'.$offset_name.'='.$inicio_bloque.'">';
|
||||
if ($inicio_bloque == $offset) {
|
||||
$output .= "<b>[ $i ]</b>";
|
||||
}
|
||||
|
@ -1523,6 +1525,7 @@ function ui_pagination ($count, $url = false, $offset = 0, $pagination = 0, $ret
|
|||
echo $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -638,3 +638,30 @@ function load_plugin_macros_fields(row_model_id) {
|
|||
});
|
||||
}
|
||||
|
||||
// Show the modal window of a module
|
||||
function show_module_detail_dialog(module_id, id_agente) {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: "page=include/ajax/module&get_module_detail=1&id_agente="+id_agente+"&id_module=" + module_id,
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
$("#module_details_window").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 620,
|
||||
height: 500
|
||||
})
|
||||
.show ();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -429,8 +429,9 @@ if (is_ajax ())
|
|||
"period=86400&" .
|
||||
"id=" . $row["id_agente_modulo"];
|
||||
}
|
||||
echo "<a href='" . $url_module_data . "'>" . html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>";
|
||||
|
||||
//echo "<a href='" . $url_module_data . "'>" . html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>";
|
||||
echo "<a href='javascript: show_module_detail_dialog(" . $row["id_agente_modulo"] . ", ". $row['id_agente'].", \"" . $server_name . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>";
|
||||
|
||||
echo " ";
|
||||
|
||||
$nmodule_alerts = db_get_value_sql(sprintf("SELECT count(*) FROM talert_template_modules WHERE id_agent_module = %s", $row["id_agente_modulo"]));
|
||||
|
@ -609,7 +610,8 @@ echo "<div class='pepito' id='b'></div>";
|
|||
echo "<div class='pepito' id='c'></div>";
|
||||
///////// END MENU AND TABS /////////////
|
||||
|
||||
|
||||
echo "<div id='module_details_window'></div>";
|
||||
ui_require_javascript_file('pandora_modules');
|
||||
|
||||
treeview_printTree($activeTab);
|
||||
?>
|
||||
|
@ -794,4 +796,51 @@ treeview_printTree($activeTab);
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Show the modal window of an module
|
||||
function show_module_detail_dialog(module_id, id_agent, server_name, offset, period) {
|
||||
if (period == -1) {
|
||||
period = $('#period').val();
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: "page=include/ajax/module&get_module_detail=1&server_name="+server_name+"&id_agent="+id_agent+"&id_module=" + module_id+"&offset="+offset+"&period="+period,
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
$("#module_details_window").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 620,
|
||||
height: 500
|
||||
})
|
||||
.show ();
|
||||
refresh_pagination_callback (module_id, id_agent, server_name);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_pagination_callback (module_id, id_agent, server_name) {
|
||||
$(".pagination").click( function() {
|
||||
var classes = $(this).attr('class');
|
||||
classes = classes.split(' ');
|
||||
var offset_class = classes[1];
|
||||
offset_class = offset_class.split('_');
|
||||
var offset = offset_class[1];
|
||||
|
||||
var period = $('#period').val();
|
||||
|
||||
show_module_detail_dialog(module_id, id_agent, server_name, offset, period);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue