2011-09-14 Miguel de Dios <miguel.dedios@artica.es>
* include/functions.php: cleaned source code style. * include/functions_events.php: added the parameter to return only url in function "events_print_type_img". * include/functions_api.php: now the api in getevents return more data. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4954 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
159c96b971
commit
f8b3bba7aa
|
@ -1,4 +1,13 @@
|
|||
2011-09-08 Miguel de Dios <miguel.dedios@artica.es>
|
||||
2011-09-14 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions.php: cleaned source code style.
|
||||
|
||||
* include/functions_events.php: added the parameter to return only url
|
||||
in function "events_print_type_img".
|
||||
|
||||
* include/functions_api.php: now the api in getevents return more data.
|
||||
|
||||
2011-09-14 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_api.php: added in the output of get events the agent
|
||||
name and group name.
|
||||
|
|
|
@ -902,16 +902,22 @@ function get_priority_name ($priority) {
|
|||
switch ($priority) {
|
||||
case 0:
|
||||
return __('Maintenance');
|
||||
break;
|
||||
case 1:
|
||||
return __('Informational');
|
||||
break;
|
||||
case 2:
|
||||
return __('Normal');
|
||||
break;
|
||||
case 3:
|
||||
return __('Warning');
|
||||
break;
|
||||
case 4:
|
||||
return __('Critical');
|
||||
break;
|
||||
default:
|
||||
return __('All');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ require_once('functions_agents.php');
|
|||
require_once('functions_modules.php');
|
||||
include_once($config['homedir'] . "/include/functions_profile.php");
|
||||
include_once($config['homedir'] . "/include/functions.php");
|
||||
include_once($config['homedir'] . "/include/functions_events.php");
|
||||
|
||||
/**
|
||||
* Parse the "other" parameter.
|
||||
|
@ -1574,14 +1575,16 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d
|
|||
case "mysql":
|
||||
$sql = "SELECT *,
|
||||
(SELECT t1.nombre FROM tagente AS t1 WHERE t1.id_agente = tevento.id_agente) AS agent_name,
|
||||
(SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name
|
||||
(SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name,
|
||||
(SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination;
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = "SELECT *,
|
||||
(SELECT t1.nombre FROM tagente AS t1 WHERE t1.id_agente = tevento.id_agente) AS agent_name,
|
||||
(SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name
|
||||
(SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name,
|
||||
(SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$pagination." OFFSET ".$offset;
|
||||
break;
|
||||
|
@ -1591,7 +1594,8 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d
|
|||
$set['offset'] = $offset;
|
||||
$sql = "SELECT *,
|
||||
(SELECT t1.nombre FROM tagente AS t1 WHERE t1.id_agente = tevento.id_agente) AS agent_name,
|
||||
(SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name
|
||||
(SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name,
|
||||
(SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon
|
||||
FROM tevento
|
||||
WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC";
|
||||
$sql = oracle_recode_query ($sql, $set);
|
||||
|
@ -1654,6 +1658,46 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d
|
|||
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
|
||||
if ($result !== false) {
|
||||
//Add the description and image
|
||||
foreach ($result as $key => $row) {
|
||||
$row['description_event'] = events_print_type_description($row["event_type"], true);
|
||||
$row['img_description'] = events_print_type_img ($row["event_type"], true, true);
|
||||
$row['criticity_name'] = get_priority_name ($row["criticity"]);
|
||||
if ($config['https']) {
|
||||
$urlImage = 'https://';
|
||||
}
|
||||
else {
|
||||
$urlImage = "http://";
|
||||
}
|
||||
|
||||
$urlImage = $urlImage.$_SERVER['HTTP_HOST'].$config["homeurl"];
|
||||
switch ($row["criticity"]) {
|
||||
default:
|
||||
case 0:
|
||||
$img_sev = $urlImage . "/images/status_sets/default/severity_maintenance.png";
|
||||
break;
|
||||
case 1:
|
||||
$img_sev = $urlImage . "/images/status_sets/default/severity_informational.png";
|
||||
break;
|
||||
case 2:
|
||||
$img_sev = $urlImage . "/images/status_sets/default/severity_normal.png";
|
||||
break;
|
||||
case 3:
|
||||
$img_sev = $urlImage . "/images/status_sets/default/severity_warning.png";
|
||||
break;
|
||||
case 4:
|
||||
$img_sev = $urlImage . "/images/status_sets/default/severity_critical.png";
|
||||
break;
|
||||
}
|
||||
$row['img_criticy'] = $img_sev;
|
||||
|
||||
$result[$key] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
//html_debug_print($result);
|
||||
|
||||
$data['type'] = 'array';
|
||||
$data['data'] = $result;
|
||||
|
||||
|
|
|
@ -452,59 +452,126 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret
|
|||
*
|
||||
* @param string $type Event type from SQL
|
||||
* @param bool $return Whether to return or print
|
||||
* @param bool $only_url Flag to return only url of image, by default false.
|
||||
*
|
||||
* @return string HTML with img
|
||||
*/
|
||||
function events_print_type_img ($type, $return = false) {
|
||||
function events_print_type_img ($type, $return = false, $only_url = false) {
|
||||
global $config;
|
||||
|
||||
$output = '';
|
||||
|
||||
if ($config['https']) {
|
||||
$urlImage = 'https://';
|
||||
}
|
||||
else {
|
||||
$urlImage = "http://";
|
||||
}
|
||||
|
||||
$urlImage = $urlImage.$_SERVER['HTTP_HOST'].$config["homeurl"];
|
||||
|
||||
switch ($type) {
|
||||
case "alert_recovered":
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/error.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/error.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "alert_manual_validation":
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/eye.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/eye.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "going_up_warning":
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/b_yellow.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/b_yellow.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "going_down_critical":
|
||||
case "going_up_critical": //This is to be backwards compatible
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/b_red.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/b_red.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "going_up_normal":
|
||||
case "going_down_normal": //This is to be backwards compatible
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/b_green.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/b_green.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "going_down_warning":
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/b_yellow.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/b_yellow.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "alert_fired":
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/bell.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/bell.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "system";
|
||||
case "system":
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/cog.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/cog.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "recon_host_detected";
|
||||
case "recon_host_detected":
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/network.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/network.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "new_agent";
|
||||
case "new_agent":
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/wand.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/wand.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
case "unknown":
|
||||
default:
|
||||
if ($only_url) {
|
||||
$output = $urlImage . "/" . "images/err.png";
|
||||
}
|
||||
else {
|
||||
$output .= html_print_image ("images/err.png", true,
|
||||
array ("title" => events_print_type_description($type, true)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue