2012-12-06 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_agents.php,
	operation/integria_incidents/incident.php,
	godmode/massive/massive_delete_modules.php,
	godmode/modules/manage_network_templates_form.php,
	godmode/modules/manage_network_components_form_plugin.php,
	godmode/agentes/fields_manager.php,
	godmode/agentes/module_manager.php, godmode/users/profile_list.php,
	godmode/events/event_filter.php: cleaned source code style.
	
	* operation/tree.php: fixed the url to childrem consoles from the
	metaconsole tree.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7234 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-12-06 12:52:01 +00:00
parent 2dcd884f15
commit c422f1a9b5
11 changed files with 178 additions and 104 deletions

View File

@ -1,3 +1,17 @@
2012-12-06 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_agents.php,
operation/integria_incidents/incident.php,
godmode/massive/massive_delete_modules.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_network_components_form_plugin.php,
godmode/agentes/fields_manager.php,
godmode/agentes/module_manager.php, godmode/users/profile_list.php,
godmode/events/event_filter.php: cleaned source code style.
* operation/tree.php: fixed the url to childrem consoles from the
metaconsole tree.
2012-12-05 Ramon Novoa <rnovoa@artica.es>
* pandoradb_data.sql,

View File

@ -55,7 +55,7 @@ if ($create_field) {
/* Update field */
if ($update_field) {
/*Check if name field is empty*/
if( $name != "") {
if( $name != "") {
$values = array('name' => $name, 'display_on_front' => $display_on_front);
$result = db_process_sql_update('tagent_custom_fields', $values, array('id_field' => $id_field));

View File

@ -136,7 +136,8 @@ if ($multiple_delete) {
if (db_process_sql("UPDATE tagente_modulo
SET nombre = 'pendingdelete', disabled = 1, delete_pending = 1 WHERE id_agente_modulo = ".$id_agent_module_del, "affected_rows", '', true, $status, false) === false) {
$error++;
} else {
}
else {
// Update module status count
if ($module !== false) {
if ($module['utimestamp'] == 0) {
@ -152,7 +153,7 @@ if ($multiple_delete) {
}
db_process_sql ('UPDATE tagente SET total_count=total_count-1 WHERE id_agente=' . $module['id_agente']);
}
}
}
switch ($config["dbtype"]) {
case "mysql":
@ -184,7 +185,7 @@ if ($multiple_delete) {
if ($result === false)
$error++;
} // Trick to detect if we are deleting components of synthetics modules (avg or arithmetic)
else{
else {
$result_components = enterprise_hook('modules_get_synthetic_components', array($id_agent_module_del));
$count_components = 1;
if (!empty($result_components)){

View File

@ -77,7 +77,7 @@ if ($multiple_delete) {
db_process_sql_begin();
foreach ($ids as $id) {
foreach ($ids as $id) {
$result = db_process_sql_delete ('tevent_filter',
array ('id_filter' => $id));
@ -117,7 +117,7 @@ $table->head[2] = __('Event type');
$table->head[3] = __('Event status');
$table->head[4] = __('Severity');
$table->head[5] = __('Action') .
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->align = array ();
@ -156,7 +156,7 @@ foreach ($filters as $filter) {
array_push ($table->data, $data);
}
if(isset($data)) {
if (isset($data)) {
echo "<form method='post' action='index.php?sec=geventos&sec2=godmode/events/event_filter'>";
html_print_input_hidden('multiple_delete', 1);
html_print_table ($table);

View File

@ -96,14 +96,14 @@ $selection_mode = get_parameter('selection_mode', 'modules');
$recursion = get_parameter('recursion');
if ($delete) {
if($selection_mode == 'modules') {
if ($selection_mode == 'modules') {
$force = get_parameter('force_type', false);
if($agents_select == false) {
if ($agents_select == false) {
$agents_select = array();
$agents_ = array();
}
foreach($agents_select as $agent_name) {
$agents_[] = agents_get_agent_id($agent_name);
}
@ -111,40 +111,40 @@ if ($delete) {
}
else if($selection_mode == 'agents') {
$force = get_parameter('force_group', false);
$agents_ = $agents_id;
$modules_ = $modules_select;
}
$count = 0;
$success = 0;
// If the option to select all of one group or module type is checked
if($force) {
if($force == 'type') {
if ($force) {
if ($force == 'type') {
$condition = '';
if($module_type != 0)
if ($module_type != 0)
$condition = ' AND t2.id_tipo_modulo = '.$module_type;
$agents_ = db_get_all_rows_sql('SELECT DISTINCT(t1.id_agente)
FROM tagente t1, tagente_modulo t2
WHERE t1.id_agente = t2.id_agente');
foreach($agents_ as $id_agent) {
foreach ($agents_ as $id_agent) {
$module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent, 'id_tipo_modulo' => $module_type),'nombre');
if($module_name == false) {
if ($module_name == false) {
$module_name = array();
}
foreach($module_name as $mod_name) {
foreach ($module_name as $mod_name) {
$result = process_manage_delete ($mod_name['nombre'], $id_agent['id_agente']);
$count ++;
$success += (int)$result;
}
}
}
else if($force == 'group') {
else if ($force == 'group') {
$agents_ = array_keys (agents_get_group_agents ($group_select, false, "none"));
foreach($agents_ as $id_agent) {
foreach ($agents_ as $id_agent) {
$module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent),'nombre');
if($module_name == false) {
$module_name = array();
@ -291,7 +291,7 @@ echo '<h3 class="error invisible" id="message"> </h3>';
ui_require_jquery_file ('form');
ui_require_jquery_file ('pandora.controls');
if($selection_mode == 'modules'){
if ($selection_mode == 'modules'){
$modules_row = '';
$agents_row = 'none';
}
@ -378,7 +378,7 @@ $(document).ready (function () {
}
$('input[type=checkbox]').change (
function () {
function () {
if(this.id == "checkbox-force_type"){
if(this.checked) {
$(".select_modules_row_2").css('display', 'none');

View File

@ -42,19 +42,19 @@ $table->rowstyle['macro_field'] = 'display:none';
push_table_row ($data, 'macro_field');
// If there are $macros, we create the form fields
if(!empty($macros)) {
if (!empty($macros)) {
$macros = json_decode($macros, true);
foreach($macros as $k => $m) {
foreach ($macros as $k => $m) {
$data = array ();
$data[0] = $m['desc'];
if(!empty($m['help'])) {
if (!empty($m['help'])) {
$data[0] .= ui_print_help_tip ($m['help'], true);
}
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 15, 60, true);
$table->colspan['macro'.$m['macro']][1] = 3;
$table->rowclass['macro'.$m['macro']] = 'macro_field';
push_table_row ($data, 'macro'.$m['macro']);
}
}

View File

@ -75,7 +75,7 @@ if (isset ($_GET["create"]) || isset ($_GET["update"])) {
//Submitted form
$name = get_parameter_post ("name");
$description = get_parameter_post ("description");
if ($name != "") {
if ($name != "") {
if ($id_np > 0) {
//Profile exists
$values = array(
@ -120,7 +120,7 @@ if (isset ($_GET["create"]) || isset ($_GET["update"])) {
elseif ($id_np > 0) {
//Profile exists
$row = db_get_row ("tnetwork_profile", "id_np", $id_np);
$description = $row["description"];
$name = $row["name"];

View File

@ -61,7 +61,7 @@ if ($delete_profile) {
if ($ret === false) {
ui_print_error_message(__('There was a problem deleting the profile'));
}
else {
else {
db_pandora_audit("Profile management",
"Delete profile ". $profile['name']);
@ -117,7 +117,7 @@ if ($update_profile) {
}
}
else {
ui_print_error_message(__('Profile name cannot be empty'));
ui_print_error_message(__('Profile name cannot be empty'));
}
$id_profile = 0;
}
@ -151,7 +151,7 @@ if ($create_profile) {
if ($name) {
$ret = db_process_sql_insert('tperfil', $values);
if ($ret !== false) {
ui_print_success_message(__('Successfully created'));
@ -169,7 +169,7 @@ if ($create_profile) {
}
}
else {
ui_print_error_message(__('There was a problem creating this profile'));
ui_print_error_message(__('There was a problem creating this profile'));
}
$id_profile = 0;
}
@ -202,7 +202,7 @@ $table->align = array_fill (1, 11, "center");
$table->size = array_fill (1, 10, 40);
$profiles = db_get_all_rows_in_table ("tperfil");
if($profiles === false) {
if ($profiles === false) {
$profiles = array();
}
@ -224,19 +224,18 @@ foreach ($profiles as $profile) {
$data[11] .= '&nbsp;&nbsp;<a href="index.php?sec=gusuarios&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile["id_perfil"].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'. html_print_image("images/cross.png", true) . '</a>';
array_push ($table->data, $data);
}
echo '<form method="post" action="index.php?sec=gusuarios&sec2=godmode/users/configure_profile">';
if(isset($data)) {
html_print_table ($table);
}
else {
echo "<div class='nf'>".__('There are no defined profiles')."</div>";
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden ('new_profile', 1);
html_print_submit_button (__('Create'), "crt", false, 'class="sub next"');
echo "</div>";
echo '</form>';
unset ($table);
?>
echo '<form method="post" action="index.php?sec=gusuarios&sec2=godmode/users/configure_profile">';
if (isset($data)) {
html_print_table ($table);
}
else {
echo "<div class='nf'>".__('There are no defined profiles')."</div>";
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden ('new_profile', 1);
html_print_submit_button (__('Create'), "crt", false, 'class="sub next"');
echo "</div>";
echo '</form>';
unset ($table);
?>

View File

@ -359,27 +359,32 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
switch ($filter['status']) {
// Normal
case 0:
$status_sql = "normal_count=total_count";
$status_sql =
"normal_count = total_count";
break;
// Warning
case 2:
$status_sql = "critical_count=0 AND warning_count>0";
$status_sql =
"critical_count = 0 AND warning_count > 0";
break;
// Critical
case 1:
$status_sql = "critical_count>0";
$status_sql =
"critical_count > 0";
break;
// Unknown
case 3:
$status_sql = "critical_count=0 AND warning_count=0 AND unknown_count>0";
$status_sql =
"critical_count = 0 AND warning_count = 0
AND unknown_count > 0";
break;
// Not normal
case 4:
$status_sql = "normal_count<>total_count";
$status_sql = "normal_count <> total_count";
break;
// Not init
case 5:
$status_sql = "notinit_count=total_count";
$status_sql = "notinit_count = total_count";
break;
}
unset($filter['status']);
@ -459,10 +464,12 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
}
if ($extra) {
$where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s', $sql_extra, $where, $where_nogroup, $status_sql, $search);
$where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s',
$sql_extra, $where, $where_nogroup, $status_sql, $search);
}
else {
$where = sprintf('%s AND %s AND (%s) %s', $where, $where_nogroup, $status_sql, $search);
$where = sprintf('%s AND %s AND (%s) %s',
$where, $where_nogroup, $status_sql, $search);
}
$sql = sprintf('SELECT %s
FROM tagente

View File

@ -35,46 +35,46 @@ $update_incident = get_parameter('update_incident', 0);
$integria_api = $config['integria_url']."/include/api.php?return_type=xml&user=".$config['id_user']."&pass=".$config['integria_api_password'];
// Header
if($tab == 'list' || $tab == 'editor') {
if ($tab == 'list' || $tab == 'editor') {
$buttons = array(
'list' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=list">' .
html_print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .'</a>'),
'editor' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=editor">' .
html_print_image ("images/add.png", true, array ("title" => __('New Incident'))) .'</a>'));
'list' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=list">' .
html_print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .'</a>'),
'editor' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=editor">' .
html_print_image ("images/add.png", true, array ("title" => __('New Incident'))) .'</a>'));
}
else {
$buttons = array(
'list' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=list">' .
html_print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .'</a>'),
'incident' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=incident&id_incident='.$id_incident.'">' .
html_print_image ("images/eye.png", true, array ("title" => __('Incident details'))) .'</a>'),
'workunits' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=workunits&id_incident='.$id_incident.'">' .
html_print_image ("images/computer.png", true, array ("title" => __('Workunits'))) .'</a>'),
'files' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=files&id_incident='.$id_incident.'"">' .
html_print_image ("images/file.png", true, array ("title" => __('Files'))) .'</a>'),
'tracking' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=tracking&id_incident='.$id_incident.'"">' .
html_print_image ("images/comments.png", true, array ("title" => __('Tracking'))) .'</a>'));
'list' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=list">' .
html_print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .'</a>'),
'incident' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=incident&id_incident='.$id_incident.'">' .
html_print_image ("images/eye.png", true, array ("title" => __('Incident details'))) .'</a>'),
'workunits' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=workunits&id_incident='.$id_incident.'">' .
html_print_image ("images/computer.png", true, array ("title" => __('Workunits'))) .'</a>'),
'files' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=files&id_incident='.$id_incident.'"">' .
html_print_image ("images/file.png", true, array ("title" => __('Files'))) .'</a>'),
'tracking' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=tracking&id_incident='.$id_incident.'"">' .
html_print_image ("images/comments.png", true, array ("title" => __('Tracking'))) .'</a>'));
}
$buttons[$tab]['active'] = true;
ui_print_page_header (__('Incident management'), "images/book_edit.png", false, "", false, $buttons);
if($update_incident == 1) {
if ($update_incident == 1) {
$values[0] = $id_incident;
$values[1] = urlencode(io_safe_output(get_parameter('title')));
$values[2] = urlencode(io_safe_output(get_parameter('description')));
@ -105,7 +105,7 @@ if($update_incident == 1) {
$create_incident = get_parameter('create_incident', 0);
if($create_incident == 1) {
if ($create_incident == 1) {
$values[0] = urlencode(io_safe_output(get_parameter('title')));
$values[1] = get_parameter('group');
@ -132,8 +132,8 @@ if($create_incident == 1) {
$attach_file = get_parameter('attach_file', 0);
if($attach_file == 1) {
if($_FILES['new_file']['name'] != "" && $_FILES['new_file']['error'] == 0) {
if ($attach_file == 1) {
if ($_FILES['new_file']['name'] != "" && $_FILES['new_file']['error'] == 0) {
$file_content = file_get_contents($_FILES["new_file"]["tmp_name"]);
$values[0] = $id_incident;
@ -172,6 +172,7 @@ if($attach_file == 1) {
break;
default:
ui_print_error_message (__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')');
break;
}
}
}

View File

@ -44,6 +44,7 @@ if (is_ajax ())
if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) {
$enterpriseEnable = true;
require_once ('enterprise/include/functions_policies.php');
require_once ('enterprise/meta/include/functions_ui_meta.php');
}
$type = get_parameter('type');
@ -59,10 +60,11 @@ if (is_ajax ())
$server = metaconsole_get_connection ($server_name);
metaconsole_connect($server);
$console_url = $server['server_url'] . '/';
} else {
}
else {
$console_url = '';
}
treeview_printTable($id_agente, $console_url);
if (defined ('METACONSOLE')) {
@ -123,7 +125,7 @@ if (is_ajax ())
metaconsole_restore_db();
}
$countRows = count ($rows);
//Empty Branch
if ($countRows === 0) {
echo "<ul style='margin: 0; padding: 0;'>\n";
@ -144,7 +146,7 @@ if (is_ajax ())
foreach ($rows as $row) {
$count++;
$agent_info["monitor_alertsfired"] = $row["fired_count"];
$agent_info["monitor_critical"] = $row["critical_count"];
$agent_info["monitor_warning"] = $row["warning_count"];
@ -223,7 +225,7 @@ if (is_ajax ())
if ($agent_info["monitor_normal"] > 0)
echo ' : <span class="green">'.$agent_info["monitor_normal"].'</span>';
echo ")";
if ($row['quiet']) {
echo "&nbsp;";
html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
@ -244,7 +246,7 @@ if (is_ajax ())
case 'agent_module':
case 'agent_tag':
$fatherType = str_replace('agent_', '', $type);
if (defined ('METACONSOLE')) {
$server = metaconsole_get_connection ($server_name);
if (metaconsole_connect($server) != NOERR) {
@ -258,7 +260,7 @@ if (is_ajax ())
if (defined ('METACONSOLE')) {
metaconsole_restore_db();
}
if ($countRows === 0) {
echo "<ul style='margin: 0; padding: 0;'>\n";
echo "<li style='margin: 0; padding: 0;'>";
@ -356,14 +358,64 @@ if (is_ajax ())
if (defined ('METACONSOLE')) {
$console_url = $server['server_url'] . '/';
} else {
}
else {
$console_url = '';
}
$link ="winopeng('" . $console_url . "operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$row["id_agente_modulo"]."&label=".base64_encode($row["nombre"])."&refresh=600','day_".$win_handle."')";
echo '<a href="javascript:'.$link.'">' . html_print_image ("images/chart_curve.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . '</a>';
//Icon and link to the Module graph.
if (defined('METACONSOLE')) {
$url_module_graph = ui_meta_get_url_console_child(
$server['id'], null, null, null, null,
"operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=86400&" .
"id=" . $row["id_agente_modulo"] . "&" .
"label=" . base64_encode($row["nombre"]) . "&" .
"refresh=600");
}
else {
$url_module_graph = $console_url .
"operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=86400&" .
"id=" . $row["id_agente_modulo"] . "&" .
"label=" . base64_encode($row["nombre"]) . "&" .
"refresh=600";
}
$link ="winopeng('" . $url_module_graph . "','day_".$win_handle."')";
echo '<a href="javascript: '.$link.'">' . html_print_image ("images/chart_curve.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . '</a>';
echo " ";
echo "<a href='" . $console_url . "index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=" . $row['id_agente'] . "&tab=data_view&period=86400&id=".$row["id_agente_modulo"]."'>" . html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>";
//Icon and link to the Module data.
if (defined('METACONSOLE')) {
$url_module_data = ui_meta_get_url_console_child(
$server['id'],
"estado", "operation/agentes/ver_agente",
"id_agente=" . $row['id_agente'] . "&" .
"tab=data_view&" .
"period=86400&" .
"id=" . $row["id_agente_modulo"]);
}
else {
$url_module_data = $console_url .
"index.php?" .
"sec=estado&" .
"sec2=operation/agentes/ver_agente&" .
"id_agente=" . $row['id_agente'] . "&" .
"tab=data_view&" .
"period=86400&" .
"id=" . $row["id_agente_modulo"];
}
echo "<a href='" . $url_module_data . "'>" . html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>";
echo " ";
echo io_safe_output($row['nombre']);
if ($row['quiet']) {
echo "&nbsp;";