2012-04-26 Miguel de Dios <miguel.dedios@artica.es>

* operation/agentes/exportdata.php,
	operation/events/events_list.php: cleaned source code style.
	
	* include/functions_events.php,
	include/functions_network_components.php,
	include/functions_api.php: fixed some things, the function
	"events_validate_event" when can't update as validate any event
	return false, into the file "functions_network_components" added
	$config['homedir'] for situations where include in a other path that
	index. And show error when make a bad validate event.
	
	MERGED FROM 4.0.2




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6197 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-04-26 14:42:48 +00:00
parent da5f54ffd8
commit c440b53603
6 changed files with 103 additions and 82 deletions

View File

@ -1,3 +1,18 @@
2012-04-26 Miguel de Dios <miguel.dedios@artica.es>
* operation/agentes/exportdata.php,
operation/events/events_list.php: cleaned source code style.
* include/functions_events.php,
include/functions_network_components.php,
include/functions_api.php: fixed some things, the function
"events_validate_event" when can't update as validate any event
return false, into the file "functions_network_components" added
$config['homedir'] for situations where include in a other path that
index. And show error when make a bad validate event.
MERGED FROM 4.0.2
2012-04-26 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/styles/pandora_forms.css

View File

@ -14,6 +14,8 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
//Set character encoding to UTF-8 - fixes a lot of multibyte character headaches
require_once('functions_agents.php');
@ -4410,7 +4412,7 @@ function set_validate_events($id_event, $trash1, $other, $return_type, $user_in_
returnData('string', array('type' => 'string', 'data' => 'Correct validation'));
}
else {
returnError('error_validate_event', 'Error in validation operation.');
returnError('Error in validation operation.');
}
}
@ -4530,25 +4532,25 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d
$sql_post .= " AND id_alert_am = ".$id_alert_am;
if ($id_event != -1)
$sql_post .= " AND id_evento = ".$id_event;
$sql_post .= " AND id_evento = " . $id_event;
if ($id_user_ack != "0")
$sql_post .= " AND id_usuario = '".$id_user_ack."'";
$sql_post .= " AND id_usuario = '" . $id_user_ack . "'";
if ($utimestamp_upper != 0)
$sql_post .= " AND utimestamp >= ".$utimestamp_upper;
$sql_post .= " AND utimestamp >= " . $utimestamp_upper;
if ($utimestamp_bottom != 0)
$sql_post .= " AND utimestamp <= ".$utimestamp_bottom;
$sql_post .= " AND utimestamp <= " . $utimestamp_bottom;
if ($event_view_hr > 0) {
$unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds
$sql_post .= " AND (utimestamp > ".$unixtime . " OR estado = 2)";
$sql_post .= " AND (utimestamp > " . $unixtime . " OR estado = 2)";
}
//Search by tag
if ($tag != "") {
$sql_post .= " AND tags LIKE '%".io_safe_input($tag)."%'";
$sql_post .= " AND tags LIKE '%" . io_safe_input($tag) . "%'";
}
if ($group_rep == 0) {
@ -4557,12 +4559,12 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d
if ($filter['total']) {
$sql = "SELECT COUNT(*)
FROM tevento
WHERE 1=1 ".$sql_post;
WHERE 1=1 " . $sql_post;
}
else if ($filter['more_criticity']) {
$sql = "SELECT criticity
FROM tevento
WHERE 1=1 ".$sql_post." ORDER BY criticity DESC LIMIT 1";
WHERE 1=1 " . $sql_post . " ORDER BY criticity DESC LIMIT 1";
}
else {
$sql = "SELECT *,
@ -4570,7 +4572,7 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d
(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;
WHERE 1=1 " . $sql_post . " ORDER BY utimestamp DESC LIMIT " . $offset . "," . $pagination;
}
break;
case "postgresql":
@ -4580,7 +4582,7 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d
(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;
WHERE 1=1 " . $sql_post . " ORDER BY utimestamp DESC LIMIT " . $pagination . " OFFSET " . $offset;
break;
case "oracle":
//TODO TOTAL
@ -4652,7 +4654,7 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d
}
//html_debug_print($filter, true);
$result = db_get_all_rows_sql ($sql);
//html_debug_print($sql);
//html_debug_print($sql, true);
if (($result !== false) && (!$filter['total']) && (!$filter['more_criticity'])) {
//Add the description and image

View File

@ -166,10 +166,10 @@ function events_validate_event ($id_event, $similars = true, $comment = '', $new
}
$id_event = array_unique($id_event);
}
db_process_sql_begin ();
switch($new_status) {
switch ($new_status) {
case 1:
$new_status_string = __('Validated');
break;
@ -183,9 +183,10 @@ function events_validate_event ($id_event, $similars = true, $comment = '', $new
$comment = str_replace(array("\r\n", "\r", "\n"), '<br>', $comment);
if($comment != '') {
if ($comment != '') {
$commentbox = '<div style="border:1px dotted #CCC; min-height: 10px;">'.$comment.'</div>';
}else {
}
else {
$commentbox = '';
}
@ -196,7 +197,7 @@ function events_validate_event ($id_event, $similars = true, $comment = '', $new
$comment = '<b>-- '.$new_status_string.' '.__('by').' '.$config['id_user'].' '.'['.date ($config["date_format"]).'] --</b><br>'.$commentbox;
$fullevent = events_get_event($event);
if($fullevent['user_comment'] != ''){
if ($fullevent['user_comment'] != '') {
$comment .= '<br>'.$fullevent['user_comment'];
}
@ -209,11 +210,13 @@ function events_validate_event ($id_event, $similars = true, $comment = '', $new
'id_usuario' => $config['id_user'],
'user_comment' => $comment);
$ret = db_process_sql_update('tevento', $values, array('id_evento' => $event), 'AND', false);
if ($ret === false) {
process_sql_rollback ();
$ret = db_process_sql_update('tevento', $values,
array('id_evento' => $event), 'AND', false);
if (($ret === false) || ($ret === 0)) {
db_process_sql_rollback ();
return false;
}
}
}
/*
@ -222,6 +225,7 @@ function events_validate_event ($id_event, $similars = true, $comment = '', $new
}
*/
db_process_sql_commit ();
return true;
}

View File

@ -18,12 +18,14 @@
* @subpackage Network components
*/
global $config;
/**
* Include modules functions
*/
include_once ($config['homedir'].'/include/functions_modules.php');
include_once ($config['homedir'].'/include/functions_agents.php');
include_once ($config['homedir'].'/include/functions_users.php');
include_once ($config['homedir'] . 'include/functions_modules.php');
include_once ($config['homedir'] . 'include/functions_agents.php');
include_once ($config['homedir'] . 'include/functions_users.php');
/**
* Get a list of network components.
@ -43,7 +45,7 @@ include_once ($config['homedir'].'/include/functions_users.php');
*/
function network_components_get_network_components ($id_module, $filter = false, $fields = false) {
global $config;
if (! is_array ($filter))
$filter = array ();
if (! empty ($id_module))
@ -55,18 +57,17 @@ function network_components_get_network_components ($id_module, $filter = false,
$components = db_get_all_rows_filter ('tnetwork_component',
$filter, $fields);
break;
case "oracle":
case "oracle":
if (count ($fields) > 1) {
$fields = implode(',',$fields);
}
}
if (isset($filter['offset'])) {
$components = oracle_recode_query ('SELECT ' . $fields . ' FROM tnetwork_component', $filter, 'AND', false);
if ($components != false) {
for ($i=0; $i < count($components); $i++) {
unset($components[$i]['rnum']);
unset($components[$i]['rnum']);
}
}
}
}
else {
$components = db_get_all_rows_filter ('tnetwork_component',
@ -76,6 +77,7 @@ function network_components_get_network_components ($id_module, $filter = false,
}
if ($components === false)
return array ();
return $components;
}
@ -235,14 +237,15 @@ function network_components_get_network_component ($id_network_component, $filte
*/
function network_components_create_network_component ($name, $type, $id_group, $values = false) {
global $config;
switch ($config['dbtype']) {
case "oracle":
if (empty($values['tcp_rcv']))
$values['tcp_rcv'] = " ";
return;
return;
break;
}
if (empty ($name))
return false;
if (empty ($type))
@ -374,31 +377,31 @@ function network_components_duplicate_network_component ($id_local_component) {
return false;
$name = __('Copy of').' '.$network['name'];
$networkCopy['description'] = $network['description'];
$networkCopy['max'] = $network['max'];
$networkCopy['min'] = $network['min'];
$networkCopy['module_interval'] = $network['module_interval'];
$networkCopy['tcp_port'] = $network['tcp_port'];
$networkCopy['tcp_send'] = $network['tcp_send'];
$networkCopy['tcp_rcv'] = $network['tcp_rcv'];
$networkCopy['snmp_community'] = $network['snmp_community'];
$networkCopy['snmp_oid'] = $network['snmp_oid'];
$networkCopy['id_module_group'] = $network['id_module_group'];
$networkCopy['id_modulo'] = $network['id_modulo'];
$networkCopy['id_plugin'] = $network['id_plugin'];
$networkCopy['plugin_user'] = $network['plugin_user'];
$networkCopy['plugin_pass'] = $network['plugin_pass'];
$networkCopy['plugin_parameter'] = $network['plugin_parameter'];
$networkCopy['max_timeout'] = $network['max_timeout'];
$networkCopy['history_data'] = $network['history_data'];
$networkCopy['min_warning'] = $network['min_warning'];
$networkCopy['max_warning'] = $network['max_warning'];
$networkCopy['str_warning'] = $network['str_warning'];
$networkCopy['min_critical'] = $network['min_critical'];
$networkCopy['max_critical'] = $network['max_critical'];
$networkCopy['str_critical'] = $network['str_critical'];
$networkCopy['min_ff_event'] = $network['min_ff_event'];
$networkCopy['description'] = $network['description'];
$networkCopy['max'] = $network['max'];
$networkCopy['min'] = $network['min'];
$networkCopy['module_interval'] = $network['module_interval'];
$networkCopy['tcp_port'] = $network['tcp_port'];
$networkCopy['tcp_send'] = $network['tcp_send'];
$networkCopy['tcp_rcv'] = $network['tcp_rcv'];
$networkCopy['snmp_community'] = $network['snmp_community'];
$networkCopy['snmp_oid'] = $network['snmp_oid'];
$networkCopy['id_module_group'] = $network['id_module_group'];
$networkCopy['id_modulo'] = $network['id_modulo'];
$networkCopy['id_plugin'] = $network['id_plugin'];
$networkCopy['plugin_user'] = $network['plugin_user'];
$networkCopy['plugin_pass'] = $network['plugin_pass'];
$networkCopy['plugin_parameter'] = $network['plugin_parameter'];
$networkCopy['max_timeout'] = $network['max_timeout'];
$networkCopy['history_data'] = $network['history_data'];
$networkCopy['min_warning'] = $network['min_warning'];
$networkCopy['max_warning'] = $network['max_warning'];
$networkCopy['str_warning'] = $network['str_warning'];
$networkCopy['min_critical'] = $network['min_critical'];
$networkCopy['max_critical'] = $network['max_critical'];
$networkCopy['str_critical'] = $network['str_critical'];
$networkCopy['min_ff_event'] = $network['min_ff_event'];
return network_components_create_network_component ($name, $network['type'], $network['id_group'], $networkCopy);
}

View File

@ -462,7 +462,6 @@ $(document).ready (function () {
}
$("select#export_type").trigger('change');
});
$("select#export_type").change (function () {
@ -479,7 +478,7 @@ $("select#export_type").change (function () {
case 'data':
f.action = "index.php?sec=reporting&sec2=operation/agentes/exportdata";
break;
}
}
});
function submit_group() {
@ -487,6 +486,5 @@ function submit_group() {
f.action = "index.php?sec=reporting&sec2=operation/agentes/exportdata";
f.form.submit();
}
/* ]]> */
</script>

View File

@ -127,7 +127,7 @@ $tag = get_parameter("tag", "");
if ($id_agent == -2) {
$text_agent = (string) get_parameter("text_agent", __("All"));
switch ($text_agent)
{
case __('All'):
@ -176,7 +176,7 @@ else {
// Skip system messages if user is not PM
if (!check_acl ($config["id_user"], 0, "PM")) {
$sql_post .= " AND id_grupo != 0";
$sql_post .= " AND id_grupo != 0";
}
switch($status) {
@ -455,7 +455,7 @@ else {
case "mysql":
db_process_sql ('SET group_concat_max_len = 9999999');
$sql = "SELECT *, MAX(id_evento) AS id_evento, GROUP_CONCAT(DISTINCT user_comment SEPARATOR '') AS user_comment,
MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep
MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep
FROM tevento
WHERE 1=1 ".$sql_post."
GROUP BY evento, id_agentmodule
@ -463,7 +463,7 @@ else {
break;
case "postgresql":
$sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '') AS user_comment,
MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep
MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep
FROM tevento
WHERE 1=1 ".$sql_post."
GROUP BY evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra
@ -499,7 +499,7 @@ if (($config['dbtype'] == 'oracle') && ($result !== false)) {
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
}
}
if ($group_rep == 0) {
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 ".$sql_post;
@ -909,14 +909,14 @@ foreach ($result as $event) {
$string .= '<td align="left" valign="top" width="25%" border="solid 1px">';
$string .= '<b>' . __('Event name') . '</b></td><td align="left">';
$string .= io_safe_output($event["evento"]);
$string .= '</td></tr><tr>';
$string .= '</td></tr><tr>';
$string .= '<td align="left" valign="top" width="15%">';
$string .= '<b>' . __('Severity') . '</b></td><td align="left">';
$string .= html_print_image ($img_sev, true,
array ("class" => "image_status",
"width" => 12,
"height" => 12,
"title" => get_priority_name ($event["criticity"])));
array ("class" => "image_status",
"width" => 12,
"height" => 12,
"title" => get_priority_name ($event["criticity"])));
$string .= ' '.get_priority_name ($event["criticity"]);
$string .= '</td></tr><tr style="border-left: solid 1px; #D3D3D3;" class="rowOdd">';
$string .= '<td align="left" valign="top" width="15%">';
@ -934,7 +934,7 @@ foreach ($result as $event) {
}
else {
$string .= date ($config["date_format"], strtotime($event["timestamp"]));
}
}
$string .= '</td></tr><tr>';
$odd = 'rowOdd';
@ -966,9 +966,10 @@ foreach ($result as $event) {
$string .= '<a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;status=-1&amp;modulegroup=' . $id_module_group . '">';
$string .= $module_group;
$string .= '</a></td></tr><tr class="' . $odd . '">';
$odd = ($odd == '')? 'rowOdd' : '';
} else {
}
else {
$string .= '<td align="left" valign="top" width="15%">';
$string .= '<b>' . __('Agent module') . '</b></td><td align="left">';
$string .= '<i>- ' . __('Empty') . ' -</i>';
@ -995,17 +996,17 @@ foreach ($result as $event) {
$string .= html_print_image ("images/bell_pause.png", true,
array ("title" => __('Go to data overview')));
}
$sql = 'SELECT name
FROM talert_templates
WHERE id IN (SELECT id_alert_template
FROM talert_template_modules
WHERE id = ' . $event["id_alert_am"] . ');';
$templateName = db_get_sql($sql);
$string .= $templateName;
$string .= '</a></td></tr><tr class="' . $odd . '">';
$odd = ($odd == '')? 'rowOdd' : '';
@ -1114,15 +1115,14 @@ if (!empty ($table->data)) {
echo '<form method="post" id="form_events" action="'.$url.'&amp;section=validate">';
echo "<input type='hidden' name='delete' id='hidden_delete_events' value='0' />";
html_print_table ($table);
echo '<div style="width:'.$table->width.';" class="action-buttons">';
if (check_acl ($config["id_user"], 0, "IW") == 1) {
html_print_submit_button (__('Update'), 'validate_btn', false, 'class="sub ok"');
}
if (check_acl ($config["id_user"], 0,"IM") == 1) {
html_print_button(__('Delete'), 'delete_button', false, 'submit_delete();', 'class="sub delete"');
?>
<script type="text/javascript">
@ -1134,7 +1134,6 @@ if (!empty ($table->data)) {
<?php
}
echo '</div></form>';
}
else {
echo '<div class="nf">'.__('No events').'</div>';