2010-07-02 Sergio Martin <sergio.martin@artica.es>

* operation/events/events_rss.php
	operation/events/events_marquee.php
	operation/events/events.php: Fixed several bugs into
	events viewer and events rss file. Apply Ip restriction
	to API Ip's List to rss and marquee files.
	Bugfix: 3017263



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2948 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-07-02 12:21:39 +00:00
parent 35f8c5ef83
commit ab1708fac5
4 changed files with 78 additions and 41 deletions

View File

@ -1,3 +1,12 @@
2010-07-02 Sergio Martin <sergio.martin@artica.es>
* operation/events/events_rss.php
operation/events/events_marquee.php
operation/events/events.php: Fixed several bugs into
events viewer and events rss file. Apply Ip restriction
to API Ip's List to rss and marquee files.
Bugfix: 3017263
2010-07-01 Sergio Martin <sergio.martin@artica.es>
* include/functions_db.php: Fixed the notice when

View File

@ -138,9 +138,7 @@ $pagination = (int) get_parameter ("pagination", $config["block_size"]);
$groups = get_user_groups ($config["id_user"], "IR");
$event_view_hr = (int) get_parameter ("event_view_hr", $config["event_view_hr"]);
$id_user_ack = get_parameter ("id_user_ack", 0);
$group_rep = (int) get_parameter ("group_rep", 1);
/* Show always the system events */
$groups[0] = __('System');
$group_rep = (int) get_parameter ("group_rep", 0);
$delete = (bool) get_parameter ("delete");
$validate = (bool) get_parameter ("validate");
@ -153,7 +151,6 @@ if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) {
if (is_user_admin ($config["id_user"])) {
//Do nothing if you're admin, you get full access
$sql_post = "";
$groups[0] = __('System Events');
} else {
//Otherwise select all groups the user has rights to.
$sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")";
@ -177,7 +174,7 @@ if ($event_type != ""){
$sql_post .= " AND event_type LIKE '%$event_type%' ";
}
elseif ($event_type == "not_normal"){
$sql_post .= " AND event_type LIKE '%warning%' OR LIKE '%critical%' ";
$sql_post .= " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' ";
}
else
$sql_post .= " AND event_type = '".$event_type."'";
@ -207,11 +204,25 @@ $url = "index.php?sec=eventos&amp;sec2=operation/events/events&amp;search=" .
$pagination . "&amp;group_rep=" . $group_rep . "&amp;event_view_hr=" .
$event_view_hr . "&amp;id_user_ack=" . $id_user_ack;
// Header
if ($config["pure"] == 0)
print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, '<a target="_top" href="'.$url.'&amp;pure=1"><img src="images/fullscreen.png"></a>');
if ($config["pure"] == 0) {
$buttons = array(
'fullscreen' => array('active' => false,
'text' => '<a href="'.$url.'&amp;pure=1">' .
print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .'</a>'),
'rss' => array('active' => false,
'text' => '<a href="operation/events/events_rss.php?ev_group='.$ev_group.'&amp;event_type='.$event_type.'&amp;search='.rawurlencode ($search).'&amp;severity='.$severity.'&amp;status='.$status.'&amp;event_view_hr='.$event_view_hr.'&amp;id_agent='.$id_agent.'">' .
print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .'</a>'),
'marquee' => array('active' => false,
'text' => '<a href="operation/events/events_marquee.php">' .
print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .'</a>'),
'csv' => array('active' => false,
'text' => '<a href="operation/events/export_csv.php?ev_group='.$ev_group.'&amp;event_type='.$event_type.'&amp;search='.rawurlencode ($search).'&amp;severity='.$severity.'&amp;status='.$status.'&amp;event_view_hr='.$event_view_hr.'&amp;id_agent='.$id_agent.'">' .
print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .'</a>')
);
print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false,$buttons);
}
else {
// Fullscreen
echo "<h2>".__('Events')." &raquo; ".__('Main event view'). "&nbsp;";
@ -265,9 +276,11 @@ echo "</td>";
// Event type
echo "<td>".__('Event type')."</td><td>";
print_select (get_event_types (), 'event_type', $event_type, '', __('All'), '');
$types = get_event_types ();
// Expand standard array to add not_normal (not exist in the array, used only for searches)
$event_type["not_normal"] = __("Not normal");
$types["not_normal"] = __("Not normal");
print_select ($types, 'event_type', $event_type, '', __('All'), '');
echo "</td></tr><tr>";
@ -342,19 +355,6 @@ echo '<tr><td colspan="4" style="text-align:right">';
//The buttons
print_submit_button (__('Update'), '', false, 'class="sub upd"');
// CSV
echo '&nbsp;&nbsp;&nbsp;<a href="operation/events/export_csv.php?ev_group='.$ev_group.'&amp;event_type='.$event_type.'&amp;search='.rawurlencode ($search).'&amp;severity='.$severity.'&amp;status='.$status.'&amp;id_agent='.$id_agent.'">';
print_image ("images/disk.png", false, array ("title" => __('Export to CSV file')));
echo '</a>';
// Marquee
echo '&nbsp;<a target="_top" href="operation/events/events_marquee.php">';
print_image ("images/heart.png", false, array ("title" => __('Marquee display')));
echo '</a>';
// RSS
echo '&nbsp;<a target="_top" href="operation/events/events_rss.php?ev_group='.$ev_group.'&amp;event_type='.$event_type.'&amp;search='.rawurlencode ($search).'&amp;severity='.$severity.'&amp;status='.$status.'&amp;id_agent='.$id_agent.'">';
print_image ("images/rss.png", false, array ("title" => __('RSS Events')));
echo '</a>';
echo "</td></tr></table></form>"; //This is the filter div
echo '<div style="width:220px; float:left;">';
if ($config['flash_charts']) {

View File

@ -26,6 +26,10 @@ $output = "";
require_once "../../include/config.php";
require_once "../../include/functions.php";
require_once "../../include/functions_db.php";
require_once "../../include/functions_api.php";
if(!isInACL($_SERVER['REMOTE_ADDR']))
exit;
$sql = "SELECT evento, timestamp, id_agente FROM tevento ORDER BY utimestamp DESC LIMIT 0 , $MAX_MARQUEE_EVENTS";

View File

@ -20,14 +20,12 @@ require_once "../../include/functions.php";
require_once "../../include/functions_db.php";
require_once "../../include/functions_api.php";
$ipOrigin = $_SERVER['REMOTE_ADDR'];
// Uncoment this to activate ACL on RSS Events
/*
if (!isInACL($ipOrigin)) {
if (!isInACL($ipOrigin))
exit;
}
*/
header("Content-Type: application/xml; charset=UTF-8"); //Send header before starting to output
@ -61,18 +59,32 @@ $severity = (int) get_parameter ("severity", -1); // -1 all
$status = (int) get_parameter ("status", 0); // -1 all, 0 only red, 1 only green
$id_agent = (int) get_parameter ("id_agent", -1);
$id_event = (int) get_parameter ("id_event", -1); //This will allow to select only 1 event (eg. RSS)
$event_view_hr = (int) get_parameter ("event_view_hr", 0);
$sql_post = "";
if ($event_view_hr > 0) {
$unixtime = (int) (get_system_time () - ($event_view_hr * 3600)); //Put hours in seconds
$sql_post .= " AND `tevento`.`utimestamp` > ".$unixtime;
}
if ($ev_group > 1)
$sql_post .= " AND `tevento`.`id_grupo` = $ev_group";
if ($status == 1)
$sql_post .= " AND `tevento`.`estado` = 1";
if ($status == 0)
$sql_post .= " AND `tevento`.`estado` = 0";
if ($status >= 0)
$sql_post .= " AND `tevento`.`estado` = ".$status;
if ($search != "")
$sql_post .= " AND `tevento`.`evento` LIKE '%$search%'";
if ($event_type != "")
$sql_post .= " AND `tevento`.`event_type` = '$event_type'";
if ($event_type != ""){
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
// for the user so for him is presented only "warning, critical and normal"
if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal"){
$sql_post .= " AND `tevento`.`event_type` LIKE '%$event_type%' ";
}
elseif ($event_type == "not_normal"){
$sql_post .= " AND `tevento`.`event_type` LIKE '%warning%' OR `tevento`.`event_type` LIKE '%critical%' OR `tevento`.`event_type` LIKE '%unknown%' ";
}
else
$sql_post .= " AND `tevento`.`event_type` = '".$event_type."'";
}
if ($severity != -1)
$sql_post .= " AND `tevento`.`criticity` >= ".$severity;
if ($id_agent != -1)
@ -81,13 +93,14 @@ if ($id_event != -1)
$sql_post .= " AND id_evento = ".$id_event;
$sql="SELECT `tevento`.`id_evento` AS event_id,
`tagente`.`nombre` AS agent_name,
`tevento`.`id_agente` AS id_agent,
`tevento`.`id_usuario` AS validated_by,
`tevento`.`estado` AS validated,
`tevento`.`evento` AS event_descr,
`tevento`.`utimestamp` AS unix_timestamp
FROM tevento, tagente
WHERE `tevento`.`id_agente` = `tagente`.`id_agente` ".$sql_post."
`tevento`.`utimestamp` AS unix_timestamp,
`tevento`.`event_type` AS event_type
FROM tevento
WHERE 1 = 1".$sql_post."
ORDER BY utimestamp DESC LIMIT 0 , 30";
$result= get_db_all_rows_sql ($sql);
@ -117,15 +130,26 @@ if (empty ($result)) {
}
foreach ($result as $row) {
if ($row["event_type"] == "system") {
$agent_name = __('System');
}
elseif ($row["id_agent"] > 0) {
// Agent name
$agent_name = get_agent_name ($row["id_agent"]);
}
else {
$agent_name = __('Alert').__('SNMP');
}
//This is mandatory
$rss_feed .= '<item><guid>';
$rss_feed .= safe_input ($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row['event_id']);
$rss_feed .= '</guid><title>';
$rss_feed .= safe_input ($row['agent_name']);
$rss_feed .= $agent_name;
$rss_feed .= '</title><description>';
$rss_feed .= safe_input ($row['event_descr']);
if($row['validated'] == 1) {
$rss_feed .= '<br /><br />Validated by ' . safe_input ($row['validated_by']);
$rss_feed .= safe_input ('<br /><br />').'Validated by ' . safe_input ($row['validated_by']);
}
$rss_feed .= '</description><link>';
$rss_feed .= safe_input ($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row["event_id"]);