2013-03-15 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_events.php, include/functions_html.php,
	include/functions_graph.php, include/functions_reporting.php,
	operation/events/events_list.php, operation/events/events.php,
	operation/agentes/group_view.php: improved source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7859 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-03-15 14:38:48 +00:00
parent 7025a8deec
commit df50d9f731
8 changed files with 51 additions and 42 deletions

View File

@ -1,3 +1,10 @@
2013-03-15 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_events.php, include/functions_html.php,
include/functions_graph.php, include/functions_reporting.php,
operation/events/events_list.php, operation/events/events.php,
operation/agentes/group_view.php: improved source code style.
2013-03-15 Miguel de Dios <miguel.dedios@artica.es>
* godmode/massive/massive_copy_modules.php: uploaded lost changes

View File

@ -70,14 +70,14 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met
global $config;
$table = events_get_events_table($meta, $history);
if($meta) {
if ($meta) {
$groupby_extra = ', server_id';
}
else {
$groupby_extra = '';
}
switch ($config["dbtype"]) {
case "mysql":
db_process_sql ('SET group_concat_max_len = 9999999');
@ -89,9 +89,9 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met
(SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user,
(SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario
FROM $table te
WHERE 1=1 ".$sql_post."
GROUP BY estado, evento, id_agentmodule".$groupby_extra."
ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination;
WHERE 1=1 " . $sql_post . "
GROUP BY estado, evento, id_agentmodule" . $groupby_extra . "
ORDER BY timestamp_rep DESC LIMIT " . $offset . "," . $pagination;
break;
case "postgresql":
$sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '<br>') AS user_comment,
@ -101,9 +101,9 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met
(SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user,
(SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario
FROM $table te
WHERE 1=1 ".$sql_post."
GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra".$groupby_extra."
ORDER BY timestamp_rep DESC LIMIT ".$pagination." OFFSET ".$offset;
WHERE 1=1 " . $sql_post . "
GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra" . $groupby_extra . "
ORDER BY timestamp_rep DESC LIMIT " . $pagination . " OFFSET " . $offset;
break;
case "oracle":
$set = array();
@ -111,7 +111,7 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met
$set['offset'] = $offset;
// TODO: Remove duplicate user comments
$sql = "SELECT a.*, b.event_rep, b.timestamp_rep
FROM (SELECT * FROM $table WHERE 1=1 ".$sql_post.") a,
FROM (SELECT * FROM $table WHERE 1=1 " . $sql_post . ") a,
(SELECT MAX (id_evento) AS id_evento, to_char(evento) AS evento,
id_agentmodule, COUNT(*) AS event_rep,
LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep,
@ -120,8 +120,8 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met
(SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user,
(SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario
FROM $table te
WHERE 1=1 ".$sql_post."
GROUP BY estado, to_char(evento), id_agentmodule".$groupby_extra.") b
WHERE 1=1 " . $sql_post . "
GROUP BY estado, to_char(evento), id_agentmodule" . $groupby_extra . ") b
WHERE a.id_evento=b.id_evento AND
to_char(a.evento)=to_char(b.evento)
AND a.id_agentmodule=b.id_agentmodule";

View File

@ -1383,17 +1383,17 @@ function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $re
$filter = array('disabled' => 0, 'id_grupo' => array_keys(users_get_groups(false, 'AR', false)));
if(!empty($id_agent)) {
if (!empty($id_agent)) {
$filter['id_agente'] = $id_agent;
}
$fields = array('SUM(critical_count) Critical',
'SUM(warning_count) Warning',
'SUM(normal_count) Normal',
'SUM(unknown_count) Unknown');
'SUM(warning_count) Warning',
'SUM(normal_count) Normal',
'SUM(unknown_count) Unknown');
if($show_not_init) {
if ($show_not_init) {
$fields[] = 'SUM(notinit_count) "Not init"';
}
@ -1401,18 +1401,18 @@ function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $re
// If any value is negative, truncate it to 0
function truncate_negatives(&$element) {
if($element < 0) {
if ($element < 0) {
$element = 0;
}
}
array_walk($data, 'truncate_negatives');
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("/images/logo_vertical_water.png"));
$colors = array(COL_CRITICAL, COL_WARNING, COL_NORMAL, COL_UNKNOWN);
if($show_not_init) {
if ($show_not_init) {
$colors[] = COL_NOTINIT;
}

View File

@ -1070,7 +1070,7 @@ function html_print_input_hidden_extended($name, $value, $id, $return = false, $
*/
function html_print_submit_button ($label = 'OK', $name = '', $disabled = false, $attributes = '', $return = false) {
if (!$name) {
$name="unnamed";
$name = "unnamed";
}
if (is_array ($attributes)) {

View File

@ -1004,7 +1004,8 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he
$tdata = array();
$table_mbs->colspan[count($table_mbs->data)][0] = 4;
$table_mbs->cellstyle[count($table_mbs->data)][0] = 'text-align: center;';
$tdata[0] = '<div style="margin: auto; width: ' . $graph_width . 'px;">' . graph_agent_status (false, $graph_width, $graph_height, true, true) . '</div>';
$tdata[0] = '<div style="margin: auto; width: ' . $graph_width . 'px;">' .
graph_agent_status (false, $graph_width, $graph_height, true, true) . '</div>';
$table_mbs->rowclass[] = '';
$table_mbs->data[] = $tdata;
}
@ -1137,15 +1138,15 @@ function reporting_get_stats_users($data) {
else{
$urls['defined_users'] = 'javascript:';
}
// Users table
$table_us = html_get_predefined_table();
$tdata = array();
$tdata[0] = html_print_image('images/group.png', true, array('title' => __('Defined users'), 'width' => '20px'));
$tdata[1] = count (get_users ());
$tdata[1] = '<a style="color: black;" class="big_data" href="' . $urls["defined_users"] . '">' . $tdata[1] . '</a>';
$tdata[2] = $tdata[3] = '&nbsp;';
$table_us->rowclass[] = '';
$table_us->data[] = $tdata;
@ -1166,15 +1167,15 @@ function reporting_get_stats_agents_monitors($data) {
$urls = array();
$urls['total_agents'] = "index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60";
$urls['monitor_checks'] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=-1";
// Agents and modules table
$table_am = html_get_predefined_table();
$tdata = array();
$tdata[0] = html_print_image('images/bricks.png', true, array('title' => __('Total agents'), 'width' => '20px'));
$tdata[1] = $data["total_agents"] <= 0 ? '-' : $data["total_agents"];
$tdata[1] = '<a style="color: black;" class="big_data" href="' . $urls['total_agents'] . '">' . $tdata[1] . '</a>';
$tdata[2] = html_print_image('images/brick.png', true, array('title' => __('Monitor checks'), 'width' => '20px'));
$tdata[3] = $data["monitor_checks"] <= 0 ? '-' : $data["monitor_checks"];
$tdata[3] = '<a style="color: black;" class="big_data" href="' . $urls['monitor_checks'] . '">' . $tdata[3] . '</a>';
@ -1189,7 +1190,7 @@ function reporting_get_stats_agents_monitors($data) {
return $output;
}
function reporting_get_stats_indicators($data, $width = 280, $height = 20) {
$table_ind = html_get_predefined_table();

View File

@ -50,8 +50,8 @@ $groups_full = users_get_groups ($config['id_user'], "AR", true, true);
$groups = array();
foreach($groups_full as $group) {
$groups[$group['id_grupo']]['name'] = $group['nombre'];
if($group['id_grupo'] != 0) {
if ($group['id_grupo'] != 0) {
$groups[$group['parent']]['childs'][] = $group['id_grupo'];
$groups[$group['id_grupo']]['prefix'] = $groups[$group['parent']]['prefix'].'&nbsp;&nbsp;&nbsp;';
}
@ -59,13 +59,14 @@ foreach($groups_full as $group) {
$groups[$group['id_grupo']]['prefix'] = '';
}
if(!isset($groups[$group['id_grupo']]['childs'])) {
if (!isset($groups[$group['id_grupo']]['childs'])) {
$groups[$group['id_grupo']]['childs'] = array();
}
}
if ($config["realtimestats"] == 0){
$updated_time = __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true);
if ($config["realtimestats"] == 0) {
$updated_time = __('Last update') . " : " .
ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true);
}
else {
$updated_time = __("Updated at realtime");
@ -74,7 +75,7 @@ else {
// Header
ui_print_page_header (__("Group view"), "images/bricks.png", false, "", false, $updated_time );
if(tags_has_user_acl_tags()) {
if (tags_has_user_acl_tags()) {
ui_print_tags_warning();
}

View File

@ -41,7 +41,7 @@ if(enterprise_installed() && defined("METACONSOLE")) {
// Get the history mode
$history = (bool) get_parameter('history', 0);
if(isset($config['event_replication']) && $config['event_replication'] == 1 && !$meta) {
if (isset($config['event_replication']) && $config['event_replication'] == 1 && !$meta) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer. View disabled due event replication.");
ui_print_info_message('Event viewer is disabled due event replication. For more information, please contact with the administrator');
@ -690,7 +690,7 @@ $(document).ready( function() {
id = this.id.split ("-").pop ();
$("#delete_cross_"+id).attr ("src", "images/spinner.gif");
jQuery.post ("<?php echo ui_get_full_url("ajax.php", false, false, false); ?>",
{"page" : "operation/events/events",
"delete_event" : 1,

View File

@ -162,7 +162,7 @@ if ($update_pressed || $open_filter){
if ($open_filter) {
echo '<a href="#" id="tgl_event_control"><b>'.__('Event control filter').'</b>&nbsp;'.html_print_image ("images/go.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'</a><br><br>';
}
else{
else {
echo '<a href="#" id="tgl_event_control"><b>'.__('Event control filter').'</b>&nbsp;'.html_print_image ("images/down.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'</a><br><br>';
}
@ -291,7 +291,7 @@ $data[0] = html_print_button(__('Add'), 'add_with', $add_with_tag_disabled,
$data[0] .= html_print_input_hidden('tag_with', $tag_with_base64, true);
$data[0] .= html_print_button(__('Remove'), 'remove_with', $remove_with_tag_disabled,
'', 'class="delete sub"', true);
$data[1] = html_print_button(__('Add'), 'add_without', $add_without_tag_disabled,
'', 'class="add sub"', true);
$data[1] .= html_print_input_hidden('tag_without', $tag_without_base64, true);
@ -374,7 +374,7 @@ $params['input_name'] = 'text_agent';
$params['value'] = $text_agent;
$params['return'] = true;
if($meta) {
if ($meta) {
$params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax';
}
else {
@ -415,7 +415,7 @@ $data = array();
$data[0] = '<div style="width:100%; text-align:left">';
$data[0] .= '<a href="javascript:" onclick="show_save_filter_dialog();">' . html_print_image("images/disk.png", true, array("border" => '0', "title" => __('Save filter'), "alt" => __('Save filter'))) . '</a> &nbsp;';
$data[0] .= '<a href="javascript:" onclick="show_load_filter_dialog();">' . html_print_image("images/server_database.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . '</a>&nbsp;';
if(empty($id_name)) {
if (empty($id_name)) {
$data[0] .= '[<span id="filter_loaded_span" style="font-weight: normal">' . __('No filter loaded') . '</span>]';
}
else {