From 2b71513d2a052b604e9be4a91ddac8d8c5f3430d Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 25 Jan 2010 19:47:38 +0000 Subject: [PATCH] 2010-01-25 Sancho Lerena * include/functions.php: Fixed problem in show_event_type() function who mades events.php to do a invalid filtering by event status. * operation/events/events_rss.php: Added optional (commented code) support for filtering RSS request by the API ACL. need to implement a switch in the config array to use here ACLs or not. * operation/events/events.php: Fixed problem filterings events by status (warning, critical, normal and not-normal). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 +++++++++++++ pandora_console/include/functions.php | 7 +++++-- pandora_console/operation/events/events.php | 19 +++++++++++++++++-- .../operation/events/events_rss.php | 17 ++++++++++++----- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 76c9c54637..5e733633ec 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2010-01-25 Sancho Lerena + + * include/functions.php: Fixed problem in show_event_type() function + who mades events.php to do a invalid filtering by event status. + + * operation/events/events_rss.php: Added optional (commented code) + support for filtering RSS request by the API ACL. need to implement a switch + in the config array to use here ACLs or not. + + * operation/events/events.php: Fixed problem filterings events by status + (warning, critical, normal and not-normal). + + 2010-01-25 Pablo de la ConcepciĆ³n * extras/pandoradb_migrate_v3.0_to_v3.1.sql: Added group column to control diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 5271192e03..f3ff30224e 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -720,8 +720,11 @@ function is_module_data_string ($module_name) { function get_event_types () { $types = array (); $types['unknown'] = __('Unknown'); - $types['monitor_up'] = __('Monitor up'); - $types['monitor_down'] = __('Monitor down'); + + $types['critical'] = __('Monitor Critical'); + $types['warning'] = __('Monitor Warning'); + $types['normal'] = __('Monitor Normal'); + $types['alert_fired'] = __('Alert fired'); $types['alert_recovered'] = __('Alert recovered'); $types['alert_ceased'] = __('Alert ceased'); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 0526ed70d9..2fcc84ae0c 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -174,8 +174,20 @@ if ($status == 1) { if ($search != "") $sql_post .= " AND evento LIKE '%".$search."%'"; -if ($event_type != "") - $sql_post .= " AND 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 event_type LIKE '%$event_type%' "; + } + elseif ($event_type == "not_normal"){ + $sql_post .= " AND event_type LIKE '%warning%' OR LIKE '%critical%' "; + } + else + $sql_post .= " AND event_type = '".$event_type."'"; + +} if ($severity != -1) $sql_post .= " AND criticity >= ".$severity; if ($id_agent != -1) @@ -238,6 +250,9 @@ echo ""; // Event type echo "".__('Event type').""; print_select (get_event_types (), 'event_type', $event_type, '', __('All'), ''); +// Expand standard array to add not_normal (not exist in the array, used only for searches) +$event_type["not_normal"] = __("Not normal"); + echo ""; // Severity diff --git a/pandora_console/operation/events/events_rss.php b/pandora_console/operation/events/events_rss.php index 1c3ba077fe..d3d2901248 100644 --- a/pandora_console/operation/events/events_rss.php +++ b/pandora_console/operation/events/events_rss.php @@ -13,16 +13,23 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - - ini_set ('display_errors', 0); //Don't display other errors, messes up XML -header("Content-Type: application/xml; charset=UTF-8"); //Send header before starting to output - - require_once "../../include/config.php"; 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)) { + exit; +} +*/ + +header("Content-Type: application/xml; charset=UTF-8"); //Send header before starting to output function rss_error_handler ($errno, $errstr, $errfile, $errline) { global $config;