2012-09-21 Miguel de Dios <miguel.dedios@artica.es>

* operation/agentes/estado_monitores.php: added the small form to
	filter the modules/monitors in the agent general view and of course
	pagination.
	
	* include/functions_html.php, operation/events/events.php,
	operation/events/export_csv.php, operation/events/sound_events.php,
	operation/events/events_list.php,
	operation/netflow/nf_live_view.php, operation/tree.php,
	operation/agentes/ver_agente.php, operation/agentes/stat_win.php:
	cleaned source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6993 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-09-21 11:24:16 +00:00
parent 3320cbda4f
commit 829134da29
11 changed files with 211 additions and 69 deletions

View File

@ -1,3 +1,16 @@
2012-09-21 Miguel de Dios <miguel.dedios@artica.es>
* operation/agentes/estado_monitores.php: added the small form to
filter the modules/monitors in the agent general view and of course
pagination.
* include/functions_html.php, operation/events/events.php,
operation/events/export_csv.php, operation/events/sound_events.php,
operation/events/events_list.php,
operation/netflow/nf_live_view.php, operation/tree.php,
operation/agentes/ver_agente.php, operation/agentes/stat_win.php:
cleaned source code style.
2012-09-21 Junichi Satoh <junichi@rworks.jp>
* include/help/ja/help_macros.php: Added a new help file.

View File

@ -509,7 +509,7 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
if ($maxlength == 0)
$maxlength = 255;
if ($size == 0)
$size = 10;

View File

@ -155,16 +155,77 @@ switch ($config["dbtype"]) {
// TODO: Clean extra_sql
$extra_sql = '';
$status_filter_monitor = (int)get_parameter('status_filter_monitor', -1);
$status_text_monitor = get_parameter('status_text_monitor', '');
$filter_monitors = (bool)get_parameter('filter_monitors', false);
$status_filter_sql = '1 = 1';
if ($status_filter_monitor != -1) {
$status_filter_sql = 'tagente_estado.estado = ' . $status_filter_monitor;
}
$status_text_monitor_sql = '%';
if (!empty($status_text_monitor)) {
$status_text_monitor_sql = $status_text_monitor . '%';
}
//Count monitors/modules
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf("
SELECT COUNT(*)
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s AND %s tagente_estado.utimestamp != 0
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql, $extra_sql, $order['field'], $order['order']);
break;
case "oracle":
$sql = sprintf ("
SELECT COUNT(*)" .
" FROM tagente_estado, tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.nombre LIKE '%s'
AND %s
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.utimestamp != 0
ORDER BY tagente_modulo.id_module_group , %s %s
", $id_agente, $status_text_monitor_sql, $status_filter_sql, $order['field'], $order['order']);
break;
}
$count_modules = db_get_all_rows_sql ($sql);
$count_modules = reset($count_modules[0]);
//Get monitors/modules
// Get all module from agent
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf("
SELECT * FROM tagente_estado, (SELECT * FROM tagente_modulo WHERE id_agente = %d AND delete_pending = 0 AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group ON tagente_modulo.id_module_group = tmodule_group.id_mg
SELECT *
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s tagente_estado.utimestamp != 0
ORDER BY tagente_modulo.id_module_group , %s %s", $id_agente, $extra_sql, $order['field'], $order['order']);
AND %s AND %s tagente_estado.utimestamp != 0
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql, $extra_sql, $order['field'], $order['order']);
break;
// If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table()
case "oracle":
@ -178,15 +239,20 @@ switch ($config["dbtype"]) {
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.id_agente = %d
AND tagente_modulo.nombre LIKE '%s'
AND %s
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.utimestamp != 0
ORDER BY tagente_modulo.id_module_group , %s %s
", $id_agente, $order['field'], $order['order']);
", $id_agente, $status_text_monitor_sql, $status_filter_sql, $order['field'], $order['order']);
break;
}
$modules = db_get_all_rows_sql ($sql);
$limit = " LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$modules = db_get_all_rows_sql ($sql . $limit);
if (empty ($modules)) {
$modules = array ();
}
@ -331,14 +397,34 @@ foreach ($modules as $module) {
$data[5] = ui_print_status_image($status, $title, true);
if ($module["id_tipo_modulo"] == 24) { // log4x
if ($module["id_tipo_modulo"] == 24) {
// log4x
switch($module["datos"]) {
case 10: $salida = "TRACE"; $style="font-weight:bold; color:darkgreen;"; break;
case 20: $salida = "DEBUG"; $style="font-weight:bold; color:darkgreen;"; break;
case 30: $salida = "INFO"; $style="font-weight:bold; color:darkgreen;"; break;
case 40: $salida = "WARN"; $style="font-weight:bold; color:darkorange;"; break;
case 50: $salida = "ERROR"; $style="font-weight:bold; color:red;"; break;
case 60: $salida = "FATAL"; $style="font-weight:bold; color:red;"; break;
case 10:
$salida = "TRACE";
$style="font-weight:bold; color:darkgreen;";
break;
case 20:
$salida = "DEBUG";
$style="font-weight:bold; color:darkgreen;";
break;
case 30:
$salida = "INFO";
$style="font-weight:bold; color:darkgreen;";
break;
case 40:
$salida = "WARN";
$style="font-weight:bold; color:darkorange;";
break;
case 50:
$salida = "ERROR";
$style="font-weight:bold; color:red;";
break;
case 60:
$salida = "FATAL";
$style="font-weight:bold; color:red;";
break;
}
$salida = "<span style='$style'>$salida</span>";
}
@ -381,8 +467,7 @@ foreach ($modules as $module) {
$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&amp;period=86400&amp;id=".$module["id_agente_modulo"]."&amp;label=".base64_encode($module["nombre"])."&amp;refresh=600','day_".$win_handle."')";
// if ($nombre_tipo_modulo != "log4x")
$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
$data[8] .= "<a href='index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=$id_agente&tab=data_view&amp;period=86400&amp;id=".$module["id_agente_modulo"]."'>" . html_print_image('images/binary.png', true, array("border" => '0', "alt" => "")) . "</a>";
}
@ -411,12 +496,21 @@ function toggle_full_value(id) {
</script>
<?php
echo "<h4 style='padding-top:0px !important;'>".__('Full list of monitors')."</h4>";
print_form_filter_monitors($status_filter_monitor, $status_text_monitor);
if (empty ($table->data)) {
echo '<div class="nf">'.__('This agent doesn\'t have any active monitors').'</div>';
if ($filter_monitors) {
echo '<div class="nf">' . __('Any monitors aren\'t with this filter.') . '</div>';
}
else {
echo '<div class="nf">' . __('This agent doesn\'t have any active monitors.') . '</div>';
}
}
else {
echo "<h4 style='padding-top:0px !important;'>".__('Full list of monitors')."</h4>";
ui_pagination ($count_modules);
html_print_table ($table);
ui_pagination ($count_modules);
}
unset ($table);
@ -429,12 +523,45 @@ ui_require_jquery_file ('cluetip');
<script type="text/javascript">
/* <![CDATA[ */
$("a.tag_details").cluetip ({
arrows: true,
attribute: 'href',
cluetipClass: 'default'
}).click (function () {
return false;
});
arrows: true,
attribute: 'href',
cluetipClass: 'default'
})
.click (function () {
return false;
});
/* ]]> */
</script>
</script>
<?php
function print_form_filter_monitors($status_filter_monitor = -1,
$status_text_monitor = '') {
$form_text = '<form action="" method="post">';
$table->data[0][0] = html_print_input_hidden('filter_monitors', 1, true);
$table->data[0][0] .= __('Status:');
$status_list = array(
-1 => __('All'),
AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'),
AGENT_MODULE_STATUS_CRITICAL_ALERT => __('Alert'),
AGENT_MODULE_STATUS_NORMAL => __('Normal'),
AGENT_MODULE_STATUS_WARNING => __('Warning'),
AGENT_MODULE_STATUS_UNKNOW => __('Unknow'));
$table->data[0][1] = html_print_select ($status_list,
'status_filter_monitor', $status_filter_monitor, '', '', 0,
true);
$table->data[0][2] = __('Free text for search (*):');
$table->data[0][3] = html_print_input_text('status_text_monitor', $status_text_monitor, '', 30, 100, true);
$table->data[0][4] = html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"', true);
$table->data[0][4] .= '</form>';
$table->data[0][5] = '<form action="" method="post">';
$table->data[0][5] .= html_print_submit_button(__('Reset'), 'reset', false, 'class="sub upd"', true);
$table->data[0][5] .= '</form>';
html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"', true);
$form_text .= html_print_table($table, true);
$form_text .= '';
ui_toggle($form_text, __('Form filter'), __('Form filter'));
}
?>

View File

@ -38,7 +38,7 @@ if (! isset ($config['id_user']) && get_parameter("loginhash", 0)) {
$_SESSION['id_usuario'] = $loginhash_user;
$config["id_user"] = $loginhash_user;
$hash_connection_data = true;
$hash_connection_data = true;
}
}
@ -108,7 +108,7 @@ $label = base64_decode(get_parameter('label', ''));
$("#graph_menu_arrow").click(function(){
if ($("#graph_menu_arrow").attr("src").indexOf("hide") == -1){
$("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow_hide.png");
$("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow_hide.png");
}
else {
$("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow.png");

View File

@ -188,7 +188,7 @@ if (is_ajax ()) {
$first_elements = array();
foreach ($idAgents as $idA) {
$row = explode ('|', $idA);
$server_name = $row[0];
$id_agent = $row [1];
@ -217,20 +217,20 @@ if (is_ajax ()) {
// Add agent and server
foreach ($temp as $element_key => $element_value) {
//$temp_element[$element_key . '|' . $id_agent . '|' . $server_name] = $element_value;
if (!isset($temp_element[$element_value]) && $first)
$temp_element[$element_value] = $element_key . '|' . $id_agent . '|' . $server_name;
else if (isset($temp_element[$element_value]))
$temp_element[$element_value] .= ';' . $element_key . '|' . $id_agent . '|' . $server_name;
}
}
// If the result array is empty then there aren't common modules
else if (!$first)
unset($temp_element);
// First iteration flag
if (empty($nameModules) && $first == true)
@ -269,7 +269,7 @@ if (is_ajax ()) {
io_safe_output($custom_condition) . '
AND delete_pending = 0
AND id_agente IN (' . implode(',', $idAgents) . ')';
if($selection_mode == 'common') {
$sql .= ' AND (
SELECT count(nombre)
@ -307,8 +307,8 @@ if (is_ajax ()) {
$force_local_modules = (int) get_parameter ('force_local_modules', 0);
if ($agentName != null) {
$search = array();
$search['name'] = io_safe_output($agentName);
$search = array();
$search['name'] = io_safe_output($agentName);
}
else
$search = false;
@ -367,7 +367,8 @@ if (is_ajax ()) {
echo '<strong>'.__('Last contact').':</strong> '.human_time_comparation($agent['ultimo_contacto']).'<br />';
echo '<strong>'.__('Last remote contact').':</strong> '.human_time_comparation($agent['ultimo_contacto_remoto']).'<br />';
$sql = sprintf ('SELECT tagente_modulo.descripcion, tagente_modulo.nombre
$sql = sprintf ('SELECT tagente_modulo.descripcion,
tagente_modulo.nombre
FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente = %d
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
@ -445,7 +446,7 @@ if (is_ajax ()) {
echo html_print_image("images/" . modules_get_type_icon ($agentmoduletype), true) . '<br />';
echo '<strong>'.__('Module group').':</strong> ';
$modulegroup = modules_get_modulegroup_name (modules_get_agentmodule_modulegroup ($module['id_agente_modulo']));
if($modulegroup === false){
if ($modulegroup === false) {
echo __('None').'<br />';
}
else{
@ -454,7 +455,7 @@ if (is_ajax ()) {
echo '<strong>'.__('Agent').':</strong> ';
echo ui_print_truncate_text(modules_get_agentmodule_agent_name($module['id_agente_modulo']), 'agent_small', false, true, false).'<br />';
if($module['id_tipo_modulo'] == 18) {
if ($module['id_tipo_modulo'] == 18) {
echo '<strong>'.__('Address').':</strong> ';
// Get the IP/IPs from the module description
@ -484,14 +485,14 @@ if (is_ajax ()) {
echo ui_print_truncate_text($group['nombre'], GENERIC_SIZE_TEXT, false, true, false) . '</h3>';
echo '<strong>'.__('Parent').':</strong> ';
if ($group['parent'] == 0) {
echo __('None').'<br />';
echo __('None') . '<br />';
}
else {
$group_parent = db_get_row ('tgrupo', 'id_grupo', $group['parent']);
echo html_print_image("images/groups_small/" . groups_get_icon ($group['parent']) . ".png", true);
echo $group_parent['nombre'].'<br />';
echo $group_parent['nombre'] . '<br />';
}
echo '<strong>'.__('Sons').':</strong> ';
echo '<strong>' . __('Sons') . ':</strong> ';
$groups_sons = db_get_all_fields_in_table ('tgrupo', 'parent', $group['id_grupo']);
if ($groups_sons === false) {
echo __('None').'<br />';

View File

@ -240,14 +240,14 @@ if ($config["pure"] == 0) {
// Sound events
$sound_event['active'] = false;
$sound_event['text'] = '<a href="javascript: openSoundEventWindow();">' . html_print_image('images/music_note.png', true, array('title' => __('Sound events'))) . '</a>';
$sound_event['text'] = '<a href="javascript: openSoundEventWindow();">' . html_print_image('images/music_note.png', true, array('title' => __('Sound events'))) . '</a>';
// If the user has administrator permission display manage tab
if (check_acl ($config["id_user"], 0, "IW")) {
// Manage events
$manage_events['active'] = false;
$manage_events['text'] = '<a href="index.php?sec=geventos&sec2=godmode/events/events&amp;section=filter">' .
html_print_image("images/setup.png", true, array ("title" => __('Manage events'))) . '</a>';
html_print_image("images/setup.png", true, array ("title" => __('Manage events'))) . '</a>';
$onheader = array('manage_events' => $manage_events,
'separator' => '',
@ -554,7 +554,7 @@ $(document).ready( function() {
// Change state image
$("#status_img_"+id).attr ("src", "images/hourglass.png");
$("#status_img_"+id).attr ("title", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>);
// Remove row due to new state
if (($("#status").val() == 0) || ($("#status").val() == 1)){

View File

@ -65,7 +65,7 @@ if (is_ajax()) {
$values['search'] = get_parameter('search');
$values['text_agent'] = get_parameter('text_agent');
$values['pagination'] = get_parameter('pagination');
$values['event_view_hr'] = get_parameter('event_view_hr');
$values['event_view_hr'] = get_parameter('event_view_hr');
$values['id_user_ack'] = get_parameter('id_user_ack');
$values['group_rep'] = get_parameter('group_rep');
$values['tag'] = get_parameter('tag');
@ -82,7 +82,7 @@ if (is_ajax()) {
}
}
if ($update_event_filter){
if ($update_event_filter) {
$values = array();
$id = get_parameter('id');
$values['id_name'] = get_parameter('id_name');
@ -100,9 +100,10 @@ if (is_ajax()) {
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['id_group_filter'] = get_parameter('id_group_filter');
$result = db_process_sql_update('tevent_filter', $values, array('id_filter' => $id));
$result = db_process_sql_update('tevent_filter',
$values, array('id_filter' => $id));
if ($result === false){
if ($result === false) {
echo 'error';
}
else {
@ -115,7 +116,7 @@ if (is_ajax()) {
echo json_encode($event_filter);
}
return;
}
@ -509,7 +510,7 @@ $result = db_get_all_rows_sql ($sql);
// Delete rnum field generated by oracle_recode_query() function
if (($config['dbtype'] == 'oracle') && ($result !== false)) {
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
unset($result[$i]['rnum']);
}
}
@ -863,7 +864,7 @@ foreach ($result as $event) {
$data[$i] .= '<a href="javascript: toggleVisibleExtendedInfo(' . $event["id_evento"] . ');">';
$data[$i] .= html_print_image ("images/eye.png", true,
array ("title" => __('Show more')));
array ("title" => __('Show more')));
$data[$i] .= '</a>&nbsp;';
// Create incident from this event
@ -911,7 +912,7 @@ foreach ($result as $event) {
if($event["id_alert_am"] != 0) {
$string .= '<div id="standby_alert_checkbox_' . $event['id_evento']. '" class="standby_alert_checkbox" style="display: none">'.__('Set alert on standby').'<br>'.html_print_checkbox('standby-alert-'.$event["id_evento"], 'ff2', false, true).'</div>';
}
$string .= '</td></tr></table>';
$string .= '</td></tr></table>';
$data = array($string);

View File

@ -66,13 +66,13 @@ switch ($status) {
if ($search != "")
$filter[] = 'evento LIKE "%'.io_safe_input($search).'%"';
if (($event_type != "all") OR ($event_type != 0))
$filter['event_type'] = $event_type;
$filter['event_type'] = $event_type;
if ($severity != -1)
$filter[] = 'criticity >= '.$severity;
if ($id_agent == -2) {
$text_agent = (string) get_parameter("text_agent", __("All"));
switch ($text_agent)
{
case __('All'):
@ -106,9 +106,9 @@ if ($id_agent != -1)
$filter['id_agente'] = $id_agent;
if ($id_event != -1)
$filter['id_evento'] = $id_event;
$filter['id_evento'] = $id_event;
$timestamp_filter = '';
$timestamp_filter = '';
if ($event_view_hr > 0) {
$unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds
$timestamp_filter = " AND (utimestamp > $unixtime OR estado = 2)";
@ -125,7 +125,7 @@ if ($tag != "") {
//$filter['order'] = 'timestamp DESC';
$now = date ("Y-m-d");
// Show contentype header
// Show contentype header
Header ("Content-type: text/txt");
header ('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.txt"');

View File

@ -158,7 +158,7 @@ function forgetPreviousEvents() {
running = true;
},
"json"
);
);
}
function check_event() {

View File

@ -356,7 +356,7 @@ if ($draw != '') {
$("#radiobtn0001").attr("checked", "");
$("#radiobtn0002").attr("checked", "checked");
}
});
});
// Shows update filter button
$("#submit-update_button").css("visibility", "");

View File

@ -536,20 +536,20 @@ if (is_ajax ())
switch ($lessBranchs) {
case 0:
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 1:
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 2:
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 3:
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
}
@ -742,7 +742,7 @@ treeview_printTree($activeTab);
function loadSubTree(type, div_id, less_branchs, id_father) {
hiddenDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv');
loadDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv');
pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree'));
pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree'));
//If has yet ajax request running
if (loadDiv == 2)