2009-01-05 Evi Vanoost <vanooste@rcbi.rochester.edu>

* godmode/agentes/alert_manager_editor.php, 
	godmode/snmpconsole/snmp_alert.php, include/functions_reporting.php,
	include/functions_reporting.php:
	Function updates
	
	* include/functions.php: show_alert_show_view is now format_alert_row
	
	* include/functions_db.php: get_simple_alerts_in_agent is now 
	get_agent_alerts_simple; get_combined_alerts_in_agent is now 
	get_agent_alerts_combined; get_alerts_in_agent is now get_agent_alerts;
	dame_nombre_alerta is now get_alert_type; get_alerts_in_group is now
	get_group_alerts; dame_id_grupo set to deprecated; Added 
	process_alerts_validate to validate alerts passed to it.
	
	* index.php: Set UTF-8 encoding standard for multibyte functions
	
	* operation/agentes/estado_alertas.php: Rewritten
	
	* operation/agentes/ver_agente.php: Put alert validation in a function

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1316 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2009-01-05 18:41:14 +00:00
parent 92013f9c30
commit 00915dcc00
9 changed files with 332 additions and 330 deletions

View File

@ -1,3 +1,25 @@
2009-01-05 Evi Vanoost <vanooste@rcbi.rochester.edu>
* godmode/agentes/alert_manager_editor.php,
godmode/snmpconsole/snmp_alert.php, include/functions_reporting.php,
include/functions_reporting.php:
Function updates
* include/functions.php: show_alert_show_view is now format_alert_row
* include/functions_db.php: get_simple_alerts_in_agent is now
get_agent_alerts_simple; get_combined_alerts_in_agent is now
get_agent_alerts_combined; get_alerts_in_agent is now get_agent_alerts;
dame_nombre_alerta is now get_alert_type; get_alerts_in_group is now
get_group_alerts; dame_id_grupo set to deprecated; Added
process_alerts_validate to validate alerts passed to it.
* index.php: Set UTF-8 encoding standard for multibyte functions
* operation/agentes/estado_alertas.php: Rewritten
* operation/agentes/ver_agente.php: Put alert validation in a function
2009-01-05 Jorge Gonzalez <jorgegonz@artica.es>
* include/languages/es.po, include/languages/es.mo: Updated Spanish

View File

@ -84,7 +84,7 @@ pandora_help ("alert_type");
echo '</td>';
echo '<td class="datos"><select name="tipo_alerta">';
if (isset($tipo_alerta)){
echo "<option value='".$tipo_alerta."'>".dame_nombre_alerta($tipo_alerta)."</option>";
echo "<option value='".$tipo_alerta."'>".get_alert_type ($tipo_alerta)."</option>";
}
$sql1 = 'SELECT id_alerta, nombre FROM talerta ORDER BY nombre';
$result = mysql_query ($sql1);

View File

@ -295,7 +295,7 @@ if (isset ($_GET["update_alert"])) {
foreach ($result as $row) {
$data = array ();
$data[0] = dame_nombre_alerta ($row["id_alert"]);
$data[0] = get_alert_type ($row["id_alert"]);
$data[1] = __('N/A');
$data[2] = __('N/A');
$data[3] = __('N/A');

View File

@ -799,130 +799,76 @@ function show_alert_row_edit ($row2, $tdcolor = "datos", $id_tipo_modulo = 1, $c
}
/**
* Formats a row from the alert table and returns an array usable in the table function
*
* @param $alert (array) A valid (non empty) row from the alert table
* @param $agent (bool) Whether to print the agent information with the module information
* @param $combined (bool) Whether or not this is a combined alert
*
* @param data
* @param tdcolor
* @param combined
*
* @return
* @return (array) A formatted array with proper html for use in $table -> 7 columns
*/
function show_alert_show_view ($data, $tdcolor = "datos", $combined = 0) {
global $config;
global $lang_label;
if ($combined == 0) {
$id_agente = give_agent_id_from_module_id ($data["id_agente_modulo"]);
$agent_name = get_agent_name ($id_agente);
$module_name = get_agentmodule_name ($data["id_agente_modulo"]);
} else {
$id_agente = $data["id_agent"];
$agent_name = get_agent_name ($id_agente);
function format_alert_row ($alert, $combined = 0, $agent = 1) {
if (empty ($alert)) {
return array ("", "", "", "", "", "", "");
}
$alert_name = dame_nombre_alerta ($data["id_alerta"]);
echo '<td class="'.$tdcolor.'f9" title="'.$alert_name.'">'.substr($alert_name,0,15).'</td>';
$data = array ();
$data[0] = get_alert_type ($alert["id_alerta"]);
if ($combined == 0) {
echo '<td class="'.$tdcolor.'">'.substr ($module_name,0,12).'</td>';
if ($combined == 1) {
$data[1] = print_agent_name ($alert["id_agente"], true, 20);
} elseif ($agent == 0) {
$data[1] = mb_substr (get_agentmodule_name ($alert["id_agente_modulo"]), 0, 20);
} else {
echo '<td class="'.$tdcolor.'">';
// More details EYE tooltip (combined)
echo '<a href="#" class="info_table"><img class="top" src="images/eye.png" alt=""><span>';
echo show_alert_row_mini ($data["id_aam"]);
echo '</span></a>';
echo substr($agent_name,0,16).'</td>';
}
// Description
echo '<td class="'.$tdcolor.'">'.$data["descripcion"].'</td>';
// Extended info
echo '<td class="'.$tdcolor.'">';
// Has recovery notify activated ?
if ($data["recovery_notify"] > 0) {
$recovery_notify = __('Yes');
} else {
$recovery_notify = __('No');
$data[1] = print_agent_name (get_agentmodule_agent ($alert["id_agente_modulo"]), true, 20);
}
// calculate priority
$priority = get_alert_priority ($data["priority"]);
// calculare firing conditions
if ($data["alert_text"] != ""){
$firing_cond = __('Text')." (".substr($data["alert_text"],0,12).")";
} else {
$firing_cond = $data["min_alerts"]." / ".$data["max_alerts"];
}
$data[2] = mb_substr (safe_input ($alert["descripcion"]), 0, 35);
// calculate days
$firing_days = get_alert_days ($data);
// More details EYE tooltip
echo '<a href="#" class="info"><img class="top" src="images/eye.png" alt="">';
// Add float info table
echo '<span>
<table cellspacing="2" cellpadding="0" style="margin-left:2px;">
<tr><th colspan="2" width="91">'.__('Recovery').'</th></tr>
<tr><td colspan="2" class="datos" align="center"><b>'.$recovery_notify.'</b></td></tr>
<tr><th colspan="2" width="91">'.__('Priority').'</th></tr>
<tr><td colspan="2" class="datos" align="center"><b>'.$priority.'</b></td></tr>
<tr><th colspan="2" width="91">'.__('Alert Ctrl.').'</th></tr>
<tr><td colspan="2" class="datos" align="center"><b>'.$firing_cond.'</b></td></tr>
<tr><th colspan="2" width="91">'.__('Firing days').'</th></tr>
<tr><td colspan="2" class="datos" align="center"><b>'.$firing_days.'</b></td></tr>
</table></span></a>';
$mytempdata = fmod ($data["dis_min"], 1);
if ($mytempdata == 0) {
$mymin = intval($data["dis_min"]);
//Eye tooltip
$data[3] = '<a class="info"><img class="top" src="images/eye.png" alt="detail tooltip" />';
$data[3] .= '<span><table cellspacing="2" cellpadding="0" style="margin-left:2px;">
<tr><th colspan="2" width="91">'.__('Recovery').'</th></tr>
<tr><td colspan="2" class="datos" align="center"><b>'.($alert["recovery_notify"] == 1 ? __('Yes') : __('No')).'</b></td></tr>
<tr><th colspan="2" width="91">'.__('Priority').'</th></tr>
<tr><td colspan="2" class="datos" align="center"><b>'.get_alert_priority ($alert["priority"]).'</b></td></tr>
<tr><th colspan="2" width="91">'.__('Fires every').'</th></tr><tr><td colspan="2" class="datos" align="center"><b>';
if ($alert["min_alerts"] > 0) {
$data[3] .= human_time_description_raw ($alert["time_threshold"] / $alert["min_alerts"]);
} else {
$mymin = $data["dis_min"];
$data[3] .= human_time_description_raw ($alert["time_threshold"]);
}
$mymin = format_for_graph ($mymin);
$mytempdata = fmod ($data["dis_max"], 1);
if ($mytempdata == 0) {
$mymax = intval($data["dis_max"]);
$data[3] .= '</b></td></tr>
<tr><th colspan="2" width="91">'.__('Firing days').'</th></tr>
<tr><td colspan="2" class="datos" align="center"><b>'.get_alert_days ($alert).'</b></td></tr>
<tr><th colspan="2" width="91">'.__('Firing times').'</th></tr>
<tr><td colspan="2" class="datos" align="center"><b>'.($alert["time_from"] == $alert["time_to"] ? __('Always') : $alert["time_from"].' - '.$alert["time_to"]).'</b></td></tr>
</table></span></a>';
//Min. and Max. - maybe move this to the span
$data[4] = format_numeric ($alert["dis_min"], 2).' / '.format_numeric ($alert["dis_max"], 2);
$data[5] = print_timestamp ($alert["last_fired"], true);
$options = array ();
$options["height"] = 9;
$options["width"] = 20;
if ($alert["times_fired"] > 0) {
$options["src"] = "images/pixel_red.png";
$options["title"] = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
} elseif ($alert["disable"] > 0) {
$options["src"] = "images/pixel_gray.png";
$options["title"] = __('Alert disabled');
} else {
$mymax = $data["dis_max"];
$options["src"] = "images/pixel_green.png";
$options["title"] = __('Alert not fired');
}
$mymax = format_for_graph($mymax);
$data[6] = print_image ($options["src"], true, $options);
// Text alert ?
if ($data["alert_text"] != "") {
echo '<td class="'.$tdcolor.'" colspan="2">'.__('Text').'</td>';
} else {
echo '<td class="'.$tdcolor.'">'.$mymin.'</td>';
echo '<td class="'.$tdcolor.'">'.$mymax.'</td>';
}
$data[7] = print_checkbox ("validate[]", $alert["id_aam"], false, true);
echo '<td align="center" class="'.$tdcolor.'">'.human_time_description ($data["time_threshold"]).'</td>';
if ($data["last_fired"] == "0000-00-00 00:00:00") {
echo '<td align="center" class="'.$tdcolor.'f9">'.__('Never').'</td>';
} else {
echo '<td align="center" class="'.$tdcolor.'f9">'.human_time_comparation ($data["last_fired"]).'</td>';
}
echo '<td align="center" class="'.$tdcolor.'">'.$data["times_fired"].'</td>';
if ($data["times_fired"] != 0) {
echo '<td class="'.$tdcolor.'" align="center"><img width="20" height="9" src="images/pixel_red.png" title="'.__('Alert fired').'"></td>';
$id_grupo_alerta = dame_id_grupo ($id_agente);
if (give_acl($config["id_user"], $id_grupo_alerta, "AW") == 1) {
echo '<td align="center" class="'.$tdcolor.'">';
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&validate_alert='.$data["id_aam"].'"><img src="images/ok.png"></a>';
echo '</td>';
}
} else {
echo '<td class="'.$tdcolor.'" align="center"><img width="20" height="9" src="images/pixel_green.png" title="'.__('Alert not fired').'"></td>';
}
return $data;
}
/**

View File

@ -293,11 +293,26 @@ function get_agent_modules ($id_agent, $details = false) {
* Get all the simple alerts of an agent.
*
* @param $id_agent Agent id
*
* @param $filter Filter on "fired", "notfired" or "disabled"
* @param $limit Limit the return to a certain number
* @param $offset Offset to start the limit from
* @return An array with all simple alerts defined for an agent.
*/
function get_simple_alerts_in_agent ($id_agent) {
$sql = sprintf ("SELECT talerta_agente_modulo.* FROM talerta_agente_modulo, tagente_modulo WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente = %d", $id_agent);
function get_agent_alerts_simple ($id_agent, $filter = false) {
switch ($filter) {
case "notfired":
$filter = ' AND times_fired = 0 AND disable = 0';
break;
case "fired":
$filter = ' AND times_fired > 0 AND disable = 0';
break;
case "disabled":
$filter = ' AND disable = 1';
break;
default:
$filter = '';
}
$sql = sprintf ("SELECT talerta_agente_modulo.* FROM talerta_agente_modulo, tagente_modulo WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente = %d%s", $id_agent, $filter);
$alerts = get_db_all_rows_sql ($sql);
if ($alerts === false)
@ -312,8 +327,22 @@ function get_simple_alerts_in_agent ($id_agent) {
*
* @return An array with all combined alerts defined for an agent.
*/
function get_combined_alerts_in_agent ($id_agent) {
$alerts = get_db_all_rows_field_filter ('talerta_agente_modulo', 'id_agent', (int) $id_agent);
function get_agent_alerts_combined ($id_agent, $filter = false) {
switch ($filter) {
case "notfired":
$filter = ' AND times_fired = 0 AND disable = 0';
break;
case "fired":
$filter = ' AND times_fired > 0 AND disable = 0';
break;
case "disabled":
$filter = ' AND disable = 1';
break;
default:
$filter = '';
}
$sql = sprintf ("SELECT * FROM talerta_agente_modulo WHERE id_agent = %d%s", $id_agent, $filter);
$alerts = get_db_all_rows_sql ($sql);
if ($alerts === false)
return array ();
@ -327,9 +356,9 @@ function get_combined_alerts_in_agent ($id_agent) {
*
* @return An array with all alerts defined for an agent.
*/
function get_alerts_in_agent ($id_agent) {
$simple_alerts = get_simple_alerts_in_agent ($id_agent);
$combined_alerts = get_combined_alerts_in_agent ($id_agent);
function get_agent_alerts ($id_agent, $filter = false) {
$simple_alerts = get_agent_alerts_simple ($id_agent, $filter);
$combined_alerts = get_agent_alerts_combined ($id_agent, $filter);
return array_merge ($simple_alerts, $combined_alerts);
}
@ -420,14 +449,14 @@ function get_user_password ($id_user) {
}
/**
* Get name of an alert
* Get type of an alert (e-mail, text, internal, ...)
*
* @param id_alert Alert id.
* @param id_alert Alert type id.
*
* @return Name of the alert.
* @return Type name of the alert.
*/
function dame_nombre_alerta ($id_alert) {
return (string) get_db_value ('nombre', 'talerta', 'id_alerta', (int) $id_alert);
function get_alert_type ($id_type) {
return (string) get_db_value ('nombre', 'talerta', 'id_alerta', (int) $id_type);
}
/**
@ -705,12 +734,12 @@ function get_alert_fires_in_period ($id_agent_module, $period, $date = 0) {
*
* @return An array with alerts dictionaries defined in a group.
*/
function get_alerts_in_group ($id_group) {
function get_group_alerts ($id_group) {
$alerts = array ();
$agents = get_group_agents ($id_group, false, "none");
foreach ($agents as $agent_id => $agent_name) {
$agent_alerts = get_alerts_in_agent ($agent_id);
$agent_alerts = get_agent_alerts ($agent_id);
$alerts = array_merge ($alerts, $agent_alerts);
}
@ -790,14 +819,10 @@ function get_moduletype_name ($id_type) {
}
/**
* Get group id of an agent.
*
* @param id_agent Agent id
*
* @return Group of the given agent
* DEPRECATED: USE get_agent_group ($id) now (fully compatible)
*/
function dame_id_grupo ($id_agent) {
return (int) get_db_value ('id_grupo', 'tagente', 'id_agente', $id_agent);
return get_agent_group ($id_agent);
}
/**
@ -2208,4 +2233,51 @@ function get_agent_group ($id_agent) {
function get_group_name ($id_group) {
return (string) get_db_value ('nombre', 'tgrupo', 'id_grupo', (int) $id_group);
}
/**
* @function process_alerts_validate
* @abstract Validates an alert id or an array of alert id's
* @param $alert_id Array of or single id
* @result True if it was successful, false if it doesn't
**/
function process_alerts_validate ($id_alert) {
global $config;
require_once ("include/functions_events.php");
if (!is_array ($id_alert)) {
$id_alert = (array) $id_alert;
}
$id_alert = safe_int ($id_alert, 1);
if (empty ($id_alert)) {
return false;
}
foreach ($id_alert as $id_aam) {
$alert = get_db_row ("talerta_agente_modulo", "id_aam", $id_aam);
if (empty ($alert["id_agent"])) {
//Simple alert
$agent_id = get_agentmodule_agent ($alert["id_agente_modulo"]);
$group_id = get_agentmodule_group ($alert["id_agente_modulo"]);
} else {
//Combined alert
$agent_id = $alert["id_agent"];
$group_id = get_agent_group ($agent_id);
}
if (give_acl ($config['id_user'], $group_id, "AW") == 0) {
continue;
}
$sql = sprintf ("UPDATE talerta_agente_modulo SET times_fired = 0, internal_counter = 0 WHERE id_aam = %d", $id_aam);
$result = process_sql ($sql);
if ($result > 0) {
create_event ("Manual validation of alert for ".$alert["descripcion"], $group_id, $agent_id, 1, $config["id_user"], "alert_manual_validation", 1, $alert["id_agente_modulo"], $id_aam);
} elseif ($result === false) {
return false;
}
}
return true;
}
?>

View File

@ -384,7 +384,7 @@ function get_fired_alerts_reporting_table ($alerts_fired) {
*/
function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) {
$output = '';
$alerts = get_alerts_in_group ($id_group);
$alerts = get_group_alerts ($id_group);
$alerts_fired = get_alerts_fired ($alerts, $period, $date);
$fired_percentage = 0;
@ -549,7 +549,7 @@ function get_agent_alerts_reporting_table ($id_agent, $period = 0, $date = 0) {
$table->head[5] = __('Last fired');
$table->head[6] = __('Times Fired');
$alerts = get_alerts_in_agent ($id_agent);
$alerts = get_agent_alerts ($id_agent);
foreach ($alerts as $alert) {
$fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date);
if (! $fires) {

View File

@ -25,6 +25,11 @@ $pandora_version="v2.1-dev";
global $build_version;
global $pandora_version;
//Set character encoding to UTF-8 - fixes a lot of multibyte character headaches
if (function_exists (mb_internal_encoding)) {
mb_internal_encoding ("UTF-8");
}
// Set to 1 to do not check for installer or config file (for development!).
$develop_bypass = 1;

View File

@ -17,197 +17,173 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Load global vars
require ("include/config.php");
require_once ("include/config.php");
check_login ();
if (! give_acl ($config["id_user"], 0, "AR") && ! give_acl ($config["id_user"], 0, "AW")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
"Trying to access alert view");
include ("general/noaccess.php");
exit;
}
$filter = get_parameter_get ("filter", "all");
$offset = (int) get_parameter_get ("offset", 0);
$id_group = (int) get_parameter ("ag_group", 1); //1 is the All group (selects all groups)
$sec2 = get_parameter_get ('sec2');
$sec2 = safe_url_extraclean ($sec2);
$sec = get_parameter_get ('sec');
$sec = safe_url_extraclean ($sec);
$url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&refr='.$config["refr"].'&filter='.$filter.'&ag_group='.$id_group;
// Show alerts for specific agent
if (isset($_GET["id_agente"])){
$id_agente = get_parameter_get ("id_agente");
$id_grupo_alerta = dame_id_grupo ($id_agente);
if (give_acl ($config["id_user"], $id_grupo_alerta, "AR") == 0) {
audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access alert view");
include ("general/noaccess.php");
exit;
}
if (isset ($_GET["tab"])){
echo "<h2>".__('Pandora Agents')." &gt; ".__('Full list of Alerts')."</h2>";
}
if (isset ($_GET["id_agente"])) {
$id_agent = (int) get_parameter_get ("id_agente", 0);
$url = $url.'&id_agente='.$id_agent;
$query = sprintf ("SELECT talerta_agente_modulo.* FROM talerta_agente_modulo, tagente_modulo WHERE
talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo AND
tagente_modulo.id_agente = %d",$id_agente);
$result = get_db_all_rows_sql ($query);
if ($result !== false) {
$id_group = get_group_agents ($id_agent);
if (!isset ($_GET["tab"])) {
echo "<h3>".__('Full list of Alerts')."</h3>";
}
echo '<table cellpadding="4" cellspacing="4" width="750" border="0" class="databox">';
echo "<tr><th>".__('Type')."</th>
<th>".__('Name')."</th>
<th>".__('Description')."</th>
<th>".__('Info')."</th>
<th>".__('Min.')."</th>
<th>".__('Max.')."</th>
<th>".__('Time threshold')."</th>
<th>".__('Last fired')."</th>
<th>".__('Times Fired')."</th>
<th>".__('Status')."</th>
<th>".__('Validate') ." " . pandora_help('alert_validation', true)."</th></tr>";
$color = 1;
foreach ($result as $data) {
if ($color == 1){
$tdcolor = "datos";
$color = 0;
} else {
$tdcolor = "datos2";
$color = 1;
}
echo "<tr>";
show_alert_show_view ($data, $tdcolor, 0);
echo "</tr>";
}
// Show combined alerts for this agent
$sql = sprintf ("SELECT * FROM talerta_agente_modulo WHERE id_agent = %d",$id_agente);
$result = get_db_all_rows_sql ($sql);
if ($result !== false) {
echo '<tr><td colspan="11" class="datos3"><center>'.__('Combined alerts').'</center>';
foreach ($result as $data) {
//$color comes from the previous one
if ($color == 1) {
$tdcolor = "datos";
$color = 0;
} else {
$tdcolor = "datos2";
$color = 1;
}
echo "<tr>";
show_alert_show_view ($data, $tdcolor, 1);
echo "</tr>";
}
}
echo '</table>';
} else {
echo '<div class="nf">'.__('This agent doesn\'t have any alert').'</div>';
}
// Show alert for no defined agent
} else {
// -------------------------------
// SHOW ALL ALERTS (GENERAL PAGE)
// -------------------------------
echo "<h2>".__('Pandora Agents')." &gt; ".__('Full list of Alerts')."</h2>";
$iduser_temp = $config["id_user"];
$ag_group = get_parameter ("ag_group", -1);
if (give_acl ($config["id_user"], $ag_group, "AR") == 0) {
audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access alert view");
if (give_acl ($config["id_user"], $id_group, "AR") == 0) {
audit_db ($config["id_user"], $config["remote_addr"], "ACL Violation","Trying to access alert view");
require ("general/noaccess.php");
exit;
}
if ($ag_group != -1) {
echo '<form method="post" action="index.php?sec=estado&sec2=operation/agentes/estado_alertas&refr=60&ag_group='.$ag_group.'">';
} else {
echo '<form method="post" action="index.php?sec=estado&sec2=operation/agentes/estado_alertas&refr=60">';
$alerts_simple = get_agent_alerts_simple ($id_agent, $filter);
$alerts_combined = get_agent_alerts_combined ($id_agent, $filter);
$print_agent = 0;
} else {
if (give_acl ($config["id_user"], $id_group, "AR") == 0) {
audit_db ($config["id_user"], $config["remote_addr"], "ACL Violation","Trying to access alert view");
require ("general/noaccess.php");
exit;
}
$alerts_simple = array ();
$alerts_combined = array ();
$agents = array_keys (get_group_agents ($id_group));
foreach ($agents as $id_agent) {
$simple = get_agent_alerts_simple ($id_agent, $filter);
$combined = get_agent_alerts_combined ($id_agent, $filter);
$alerts_simple = array_merge ($alerts_simple, $simple);
$alerts_combined = array_merge ($alerts_combined, $combined);
}
$print_agent = 1;
}
$tab = get_parameter_get ("tab");
if ($tab != '') {
echo "<h2>".__('Pandora Agents')." &gt; ".__('Full list of Alerts')."</h2>";
$url = $url.'&tab='.$tab;
} else {
echo "<h3>".__('Full list of alerts').'</h3>';
}
echo '<form method="post" action="'.$url.'">';
if (isset ($_POST["alert_validate"])) {
$validate = get_parameter_post ("validate", array ());
$result = process_alerts_validate ($validate);
print_error_message ($result, __('Alert(s) validated'), __('Error processing alert(s)'));
}
if ($print_agent == 1) {
echo '<table cellpadding="4" cellspacing="4" class="databox">';
echo '<tr><td>'.__('Group').'</td><td valign="middle">';
//Select box
$fields = get_user_groups ($iduser_temp);
print_select ($fields, "ag_group", $ag_group, 'javascript:this.form.submit();" class="w150','');
$fields = get_user_groups ($config["id_user"]);
print_select ($fields, "ag_group", $id_group, 'javascript:this.form.submit();" class="w150','');
//And submit button
echo '</td><td valign="middle"><noscript><input name="uptbutton" type="submit" class="sub" value="'.__('Show').'"></noscript></td>';
//And finish the table here
echo '<td class="f9" style="padding-left:30px;"><img src="images/pixel_red.png" width="18" height="18">&nbsp;'.__('Alert fired').'</td>';
echo '<td class="f9" style="padding-left:30px;"><img src="images/pixel_green.png" width="18" height="18">&nbsp;'.__('Alert not fired').'</td>';
echo '<td class="f9" style="padding-left:30px; vertical-align:bottom;">(*) '.__('Combined alert').'</tr></table></form>';
// Agent group selector
if ($ag_group > 1) {
$result = get_group_agents ($ag_group, false, "upper");
} else {
//Fields is an array with all the groups the user has access to
$result = get_group_agents (array_keys ($fields), false, "upper");
}
$color = 1;
$string = '';
echo '<td class="f9" style="padding-left:30px;'.($filter == "fired" ? ' font-weight: bold;' : '').'"><a href="'.$url.'&filter=fired"><img src="images/pixel_red.png" width="18" height="18" title="'.__('Click to filter').'"></a>&nbsp;'.__('Alert fired').'</td>';
echo '<td class="f9" style="padding-left:30px;'.($filter == "notfired" ? ' font-weight: bold;' : '').'"><a href="'.$url.'&filter=notfired"><img src="images/pixel_green.png" width="18" height="18" title="'.__('Click to filter').'"></a>&nbsp;'.__('Alert not fired').'</td>';
echo '<td class="f9" style="padding-left:30px;'.($filter == "disabled" ? ' font-weight: bold;' : '').'"><a href="'.$url.'&filter=disabled"><img src="images/pixel_gray.png" width="18" height="18" title="'.__('Click to filter').'"></a>&nbsp;'.__('Alert disabled').'</td></tr></table>';
}
if ($result === false) {
$result = array();
} else {
$table->head = array(); //Reset table head
$table->head[0] = __('Agent');
$table->head[1] = __('Status');
$table->head[2] = __('Type');
$table->head[3] = __('Description');
$table->head[4] = __('Last fired');
$table->head[5] = __('Times Fired');
$table->align = array();
$table->align[1] = "center";
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = 700;
$table->class = "databox";
$table->data = array(); //Reset table data
$idx = 0; //row index
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = 750;
$table->border = 0;
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Type');
$table->head[1] = ''; //Placeholder for name
$table->head[2] = __('Description');
$table->head[3] = __('Info');
$table->head[4] = __('Min').'/'.__('Max');
$table->head[5] = __('Last fired');
$table->head[6] = __('Status');
$table->head[7] = __('Validate') . pandora_help('alert_validation', true);
$table->align = array ();
$table->align[0] = "center";
$table->align[3] = "center";
$table->align[4] = "center";
$table->align[5] = "center";
$table->align[6] = "center";
$table->align[7] = "center";
$table->title = __('Single alerts');
if ($print_agent == 0) {
$table->head[1] = __('Module name');
} else {
$table->head[1] = __('Agent name');
}
$table->data = array ();
$counter[0] = 0; //Dual counter. This one counts the total number of alerts
$counter[1] = 0; //Dual counter. This one counts only the printed alerts
foreach ($alerts_simple as $alert) {
$counter[0]++;
if (empty ($alert) || $counter[1] >= $config["block_size"] || $counter[0] <= $offset) {
continue;
}
//This result is the array with agents
foreach ($result as $id_agente => $nombre_agente) {
$result_alerts = get_alerts_in_agent ($id_agente);
if ($result_alerts === false)
$result_alerts = array();
foreach ($result_alerts as $data) {
$table->data[$idx] = array(); //init array
$table->data[$idx][0] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'"><b>'.$nombre_agente.'</b>';
if ($data["times_fired"] != 0) {
$table->data[$idx][1] = '<img src="images/pixel_red.png" width="40" height="18" title="'.__('Alert fired').'">';
} else {
$table->data[$idx][1] = '<img src="images/pixel_green.png" width="40" height="18" title="'.__('Alert not fired').'">';
}
$table->data[$idx][2] = dame_nombre_alerta ($data["id_alerta"]);
$table->data[$idx][3] = $data["descripcion"];
if ($data["last_fired"] == "0000-00-00 00:00:00") {
$table->data[$idx][4] = __('Never');
} else {
$table->data[$idx][4] = human_time_comparation ($data["last_fired"]);
}
$table->data[$idx][5] = $data["times_fired"];
$idx++; //increment the index counter
} //end foreach (data)
} //end foreach (agent)
if (!empty ($result) && !empty ($table->data)) {
print_table ($table);
} else {
echo '<div class="nf">'.__('No agent included in this group has any assigned alert').'</div>';
$counter[1]++;
array_push ($table->data, format_alert_row ($alert, 0, $print_agent));
}
if (!empty ($table->data)) {
pagination ($counter[0], $url, $offset);
print_table ($table);
} else {
echo '<div class="nf">'.__('No simple alerts found').'</div>';
}
$table->title = __('Combined alerts');
$table->head[1] = __('Agent name');
$table->data = array ();
$counter[2] = 0;
$counter[3] = 0;
foreach ($alerts_combined as $alert) {
$counter[2]++;
if (empty ($alert) || $counter[3] >= $config["block_size"] || $counter[2] <= $offset) {
continue;
}
unset ($table); //throw away table
} // Main alert view
$counter[3]++;
array_push ($table->data, format_alert_row ($alert, 1, $print_agent));
}
if (!empty ($table->data)) {
pagination ($counter[0], $url, $offset);
print_table ($table);
} else {
echo '<div class="nf">'.__('No combined alerts found').'</div>';
}
if ($counter[1] > 0 || $counter[2] > 0) {
echo '<div style="text-align: right; width: 750px;">';
print_submit_button (__('Validate'), 'alert_validate', false, 'class="sub upd"', false);
echo '</div>';
}
echo '</form>';
?>

View File

@ -18,7 +18,6 @@
// Load global vars
require_once ("include/config.php");
require_once ("include/functions_events.php");
enterprise_include ('operation/agentes/ver_agente.php');
@ -127,8 +126,8 @@ if (defined ('AJAX')) {
exit ();
}
$id_agente = (int) get_parameter ("id_agente");
if (! $id_agente) {
$id_agente = (int) get_parameter ("id_agente", 0);
if (empty ($id_agente)) {
return;
}
@ -142,28 +141,10 @@ if (! give_acl ($config['id_user'], $id_grupo, "AR")) {
}
// Check for validate alert request
$validate_alert = get_parameter ("validate_alert");
if ($validate_alert != ""){
if (give_acl ($config['id_user'], $id_grupo, "AW") == 1) {
$alert_row = get_db_row ("talerta_agente_modulo", "id_aam", $validate_alert);
if ($alert_row["id_agente_modulo"] != 0){
$am_row = get_db_row ("tagente_modulo", "id_agente_modulo", $alert_row["id_agente_modulo"]);
$ag_row = get_db_row ("tagente", "id_agente", $am_row["id_agente"]);
} else {
$ag_row = get_db_row ("tagente", "id_agente", $alert_row ["id_agent"]);
}
$alert_name = $alert_row["descripcion"];
// Single alerts
if ($alert_row["id_agente_modulo"] != 0){
create_event ("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $am_row["id_agente"], 1, $config["id_user"], "alert_manual_validation", 1, $alert_row["id_agente_modulo"], $validate_alert);
// Combined alerts
} else {
create_event ("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $alert_row ["id_agent"], 1, $config["id_user"], "alert_manual_validation", 1, 0, $validate_alert);
}
$sql='UPDATE talerta_agente_modulo SET times_fired = 0, internal_counter = 0 WHERE id_aam = '.$validate_alert;
$result=mysql_query($sql);
}
$validate_alert = get_parameter ("validate_alert", 0);
if ($validate_alert > 0) {
$result = process_alerts_validate ($validate_alert);
print_error_message ($result, __('Alert(s) validated'), __('Error processing alert(s)'));
}
// Check for Network FLAG change request