2013-02-05 Miguel de Dios <miguel.dedios@artica.es>

* ajax.php: added the autologin hash for some ajax call of user
	without login (but with hash autologin).
	
	* godmode/reporting/reporting_builder.list_items.php,
	include/db/mysql.php: cleaned source code style.
	
	* include/functions_reporting.php, include/functions_events.php,
	operation/reporting/reporting_xml.php: optimized the get by steps
	the group events.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7588 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-02-05 14:46:16 +00:00
parent 827cd23557
commit 6ce7910dc8
7 changed files with 190 additions and 96 deletions

View File

@ -1,3 +1,15 @@
2013-02-05 Miguel de Dios <miguel.dedios@artica.es>
* ajax.php: added the autologin hash for some ajax call of user
without login (but with hash autologin).
* godmode/reporting/reporting_builder.list_items.php,
include/db/mysql.php: cleaned source code style.
* include/functions_reporting.php, include/functions_events.php,
operation/reporting/reporting_xml.php: optimized the get by steps
the group events.
2013-02-05 Sancho Lerena <slerena@artica.es>
* operation/menu.php: Fixed duplicity in SNMP trap menu. SNMP

View File

@ -26,9 +26,30 @@ require_once ('include/auth/mysql.php');
// Real start
session_start ();
// Hash login process
if (isset ($_GET["loginhash"])) {
$loginhash_data = get_parameter("loginhash_data", "");
$loginhash_user = get_parameter("loginhash_user", "");
if ($config["loginhash_pwd"] != ""
&& $loginhash_data == md5($loginhash_user.$config["loginhash_pwd"])) {
db_logon ($loginhash_user, $_SERVER['REMOTE_ADDR']);
$_SESSION['id_usuario'] = $loginhash_user;
$config["id_user"] = $loginhash_user;
}
else {
require_once ('general/login_page.php');
db_pandora_audit("Logon Failed (loginhash", "", "system");
while (@ob_end_flush ());
exit ("</html>");
}
}
// Check user
check_login ();
define ('AJAX', true);
/* Enterprise support */

View File

@ -228,6 +228,7 @@ $table = null;
$table->style[0] = 'text-align: right;';
if ($items) {
$table->width = '100%';

View File

@ -1060,6 +1060,7 @@ function events_print_type_description ($type, $return = false) {
function events_get_group_events ($id_group, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
global $config;
$id_group = groups_safe_acl ($config["id_user"], $id_group, "ER");
@ -1102,6 +1103,65 @@ function events_get_group_events ($id_group, $period, $date,
return db_get_all_rows_sql ($sql);
}
/**
* Get all the events happened in a group during a period of time.
*
* The returned events will be in the time interval ($date - $period, $date]
*
* @param mixed $id_group Group id to get events for.
* @param int $period Period of time in seconds to get events.
* @param int $date Beginning date to get events.
*
* @return array An array with all the events happened.
*/
function events_get_group_events_steps ($begin, &$result, $id_group, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
global $config;
$id_group = groups_safe_acl ($config["id_user"], $id_group, "ER");
if (empty ($id_group)) {
//An empty array means the user doesn't have access
return false;
}
$datelimit = $date - $period;
$sql_where = ' AND 1 = 1 ';
if ($filter_event_critical) {
$sql_where .= ' AND criticity = 4 ';
}
if ($filter_event_warning) {
$sql_where .= ' AND criticity = 3 ';
}
if ($filter_event_validated) {
$sql_where .= ' AND estado = 1 ';
}
if ($filter_event_no_validated) {
$sql_where .= ' AND estado = 0 ';
}
$sql = sprintf ('SELECT *,
(SELECT t2.nombre
FROM tagente AS t2
WHERE t2.id_agente = t3.id_agente) AS agent_name,
(SELECT t2.fullname
FROM tusuario AS t2
WHERE t2.id_user = t3.id_usuario) AS user_name
FROM tevento AS t3
WHERE utimestamp > %d AND utimestamp <= %d
AND id_grupo IN (%s) ' . $sql_where . '
ORDER BY utimestamp ASC',
$datelimit, $date, implode (",", $id_group));
//html_debug_print($sql);
return db_get_all_row_by_steps_sql($begin, $result, $sql);
}
/**
* Get all the events happened in an Agent during a period of time.
*

View File

@ -537,12 +537,13 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0, $min_valu
$previous_utimestamp = $first_data['utimestamp'];
if ((($max_value > $min_value AND ($first_data['datos'] > $max_value OR $first_data['datos'] < $min_value))) OR
($max_value <= $min_value AND $first_data['datos'] < $min_value)) {
$previous_status = 1;
foreach ($downtime_dates as $date_dt) {
if (($date_dt['date_from'] <= $previous_utimestamp) AND ($date_dt['date_to'] >= $previous_utimestamp)) {
$previous_status = 0;
}
$previous_status = 1;
foreach ($downtime_dates as $date_dt) {
if (($date_dt['date_from'] <= $previous_utimestamp) AND ($date_dt['date_to'] >= $previous_utimestamp)) {
$previous_status = 0;
}
}
}
else {
$previous_status = 0;
@ -1173,6 +1174,7 @@ function reporting_event_reporting ($id_group, $period, $date = 0, $return = fal
if (empty ($return))
html_print_table ($table);
return $table;
}
@ -2096,68 +2098,64 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
$table->head[5] = __('Val. by');
$table->head[6] = __('Timestamp');
$events = events_get_group_events($id_group, $period, $date,
$begin = true;
$result = null;
$count = 0;
while ($event = events_get_group_events_steps($begin, $result, $id_group, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated);
$filter_event_warning, $filter_event_no_validated)) {
if ($events) {
foreach ($events as $event) {
//First pass along the class of this row
$table->rowclass[] =
get_priority_class ($event["criticity"]);
//html_debug_print(++$count, true);
$data = array ();
$data = array ();
$begin = false;
// Colored box
switch ($event['estado']) {
case 0:
$img_st = "images/star.png";
$title_st = __('New event');
break;
case 1:
$img_st = "images/tick.png";
$title_st = __('Event validated');
break;
case 2:
$img_st = "images/hourglass.png";
$title_st = __('Event in process');
break;
}
$data[] = html_print_image ($img_st, true,
array ("class" => "image_status",
"width" => 16,
"height" => 16,
"title" => $title_st,
"id" => 'status_img_' . $event["id_evento"]));
$data[] = ui_print_truncate_text(
io_safe_output($event['evento']),
140, false, true);
//$data[1] = $event['event_type'];
$data[] = events_print_type_img ($event["event_type"], true);
if (!empty($event['agent_name']))
$data[] = $event['agent_name'];
else
$data[] = __('Pandora System');
$data[] = get_priority_name ($event['criticity']);
$data[] = io_safe_output($event['user_name']);
$data[] = '<font style="font-size: 6pt;">' .
$event['timestamp'] .
'</font>';
array_push ($table->data, $data);
// Colored box
switch ($event['estado']) {
case 0:
$img_st = "images/star.png";
$title_st = __('New event');
break;
case 1:
$img_st = "images/tick.png";
$title_st = __('Event validated');
break;
case 2:
$img_st = "images/hourglass.png";
$title_st = __('Event in process');
break;
}
$data[] = html_print_image ($img_st, true,
array ("class" => "image_status",
"width" => 16,
"height" => 16,
"title" => $title_st,
"id" => 'status_img_' . $event["id_evento"]));
if ($html) {
return html_print_table ($table, $return);
}
else {
return $table;
}
$data[] = ui_print_truncate_text(
io_safe_output($event['evento']),
140, false, true);
//$data[1] = $event['event_type'];
$data[] = events_print_type_img ($event["event_type"], true);
if (!empty($event['agent_name']))
$data[] = $event['agent_name'];
else
$data[] = __('Pandora System');
$data[] = get_priority_name ($event['criticity']);
$data[] = io_safe_output($event['user_name']);
$data[] = '<font style="font-size: 6pt;">' .
$event['timestamp'] .
'</font>';
array_push ($table->data, $data);
}
if ($html) {
return html_print_table ($table, $return);
}
else {
return false;
return $table;
}
}

View File

@ -756,7 +756,8 @@ foreach ($contents as $content) {
$content_report = " <event_report_group/>\n";
$result = fwrite($file, $content_report);
fclose($file);
} else if ($data_count <= $limit) {
}
else if ($data_count <= $limit) {
$content_report = " <event_report_group>\n";
$result = fwrite($file, $content_report);
fclose($file);
@ -773,7 +774,8 @@ foreach ($contents as $content) {
$content_report = " </event_report_group>\n";
$result = fwrite($file, $content_report);
} else {
}
else {
$content_report = " <event_report_group>\n";
$result = fwrite($file, $content_report);
fclose($file);