Merge branch 'develop' into feature#new-iface-names

This commit is contained in:
Ramon Novoa 2017-03-03 08:32:31 +01:00
commit 540d076c9f
12 changed files with 138 additions and 201 deletions

View File

@ -594,14 +594,14 @@ switch ($action) {
if (check_acl ($config["id_user"], $report["id_group"], "RW") || check_acl ($config["id_user"], $report["id_group"], "RM")) {
$data[0] = '<a href="' . $config['homeurl'] . 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&action=edit&id_report='.
$report['id_report'].'&pure='.$pure.'">'.$report['name'].'</a>';
$report['id_report'].'&pure='.$pure.'">'.ui_print_truncate_text($report['name'], 70).'</a>';
}
else {
$data[0] = $report['name'];
$data[0] = ui_print_truncate_text($report['name'], 70);
}
$data[1] = $report['description'];
$data[1] = ui_print_truncate_text($report['description'], 70);
//Remove html and xml button if items are larger than limit
$item_count = db_get_num_rows ('SELECT * FROM treport_content WHERE id_report=' . $report['id_report']);

View File

@ -89,13 +89,24 @@ function visual_map_main() {
});
$('.labelpos').click(function(event) {
$("#labelposup img").attr('src','images/label_up.png');
$("#labelposdown img").attr('src','images/label_down.png');
$("#labelposleft img").attr('src','images/label_left.png');
$("#labelposright img").attr('src','images/label_right.png');
$('.labelpos').attr('sel','no');
$("#"+$(this).attr('id')+" img").attr('src','images/label_'+$(this).attr('id').replace('labelpos','')+'_2.png');
$("#"+$(this).attr('id')).attr('sel','yes');
if($("#hidden-metaconsole").val() == 1){
$("#labelposup img").attr('src','../../images/label_up.png');
$("#labelposdown img").attr('src','../../images/label_down.png');
$("#labelposleft img").attr('src','../../images/label_left.png');
$("#labelposright img").attr('src','../../images/label_right.png');
$('.labelpos').attr('sel','no');
$("#"+$(this).attr('id')+" img").attr('src','../../images/label_'+$(this).attr('id').replace('labelpos','')+'_2.png');
$("#"+$(this).attr('id')).attr('sel','yes');
}
else{
$("#labelposup img").attr('src','images/label_up.png');
$("#labelposdown img").attr('src','images/label_down.png');
$("#labelposleft img").attr('src','images/label_left.png');
$("#labelposright img").attr('src','images/label_right.png');
$('.labelpos').attr('sel','no');
$("#"+$(this).attr('id')+" img").attr('src','images/label_'+$(this).attr('id').replace('labelpos','')+'_2.png');
$("#"+$(this).attr('id')).attr('sel','yes');
}
});
@ -982,13 +993,24 @@ function loadFieldsFromDB(item) {
}
if (key == 'label_position') {
$('#labelposup'+" img").attr('src','images/label_up.png');
$('#labelposdown'+" img").attr('src','images/label_down.png');
$('#labelposleft'+" img").attr('src','images/label_left.png');
$('#labelposright'+" img").attr('src','images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
if($("#hidden-metaconsole").val() == 1){
$('#labelposup'+" img").attr('src','../../images/label_up.png');
$('#labelposdown'+" img").attr('src','../../images/label_down.png');
$('#labelposleft'+" img").attr('src','../../images/label_left.png');
$('#labelposright'+" img").attr('src','../../images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','../../images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
else{
$('#labelposup'+" img").attr('src','images/label_up.png');
$('#labelposdown'+" img").attr('src','images/label_down.png');
$('#labelposleft'+" img").attr('src','images/label_left.png');
$('#labelposright'+" img").attr('src','images/label_right.png');
$('.labelpos').attr('sel','no');
$('#labelpos'+val+" img").attr('src','images/label_'+$('#labelpos'+val).attr('id').replace('labelpos','')+'_2.png');
$('#labelpos'+val).attr('sel','yes');
}
}
if (key == 'image') {

View File

@ -465,11 +465,11 @@ if ($list_modules) {
switch ($sort) {
case 'up':
$selectTypeUp = $selected;
$order = array('field' => 'tagente_modulo.id_tipo_modulo', 'order' => 'ASC');
$order = array('field' => 'tagente_modulo.id_modulo', 'order' => 'ASC');
break;
case 'down':
$selectTypeDown = $selected;
$order = array('field' => 'tagente_modulo.id_tipo_modulo', 'order' => 'DESC');
$order = array('field' => 'tagente_modulo.id_modulo', 'order' => 'DESC');
break;
}
break;
@ -634,7 +634,6 @@ if ($list_modules) {
else
$count_modules = 0;
//Get monitors/modules
// Get all module from agent
switch ($config["dbtype"]) {
@ -652,7 +651,7 @@ if ($list_modules) {
AND %s %s
AND tagente_estado.estado != %d
AND tagente_modulo.%s
ORDER BY tmodule_group.name , %s %s",
ORDER BY tmodule_group.name , %s %s",
$id_agente, $status_text_monitor_sql,$status_module_group_filter,$status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA,
$status_module_group_filter, $order['field'], $order['order']);

View File

@ -239,7 +239,7 @@ function process_user_login_remote ($login, $pass, $api = false) {
$return = enterprise_hook ('prepare_permissions_groups_of_user_ad',
array ($login, $pass, false, true));
array ($login, $pass, false, true, defined('METACONSOLE')));
if ($return === "error_permissions") {
$config["auth_error"] =
@ -337,15 +337,28 @@ function process_user_login_remote ($login, $pass, $api = false) {
$servers = metaconsole_get_servers();
foreach ($servers as $server) {
$perfil_maestro = db_get_row('tperfil',
'id_perfil', $config['default_remote_profile']);
if (metaconsole_connect($server) == NOERR ) {
if (!profile_exist($perfil_maestro['name'])) {
unset($perfil_maestro['id_perfil']);
$id_profile = db_process_sql_insert('tperfil', $perfil_maestro);
}
else {
$id_profile = db_get_value('id_perfil', 'tperfil', 'name', $perfil_maestro['name']);
}
if (create_user ($login, $pass,
array ('fullname' => $login,
'comments' => 'Imported from ' . $config['auth'])
) === false)
continue;
profile_create_user_profile ($login, $config['default_remote_profile'],
profile_create_user_profile ($login, $id_profile,
$config['default_remote_group'], false, $config['default_assign_tags']);
}
metaconsole_restore_db();
}
}

View File

@ -1783,7 +1783,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
//Work around for fixed the agents name with huge size chars.
$fixed_font_size = $config['font_size'] - 2;
$fixed_font_size = $config['font_size'];
//Set graph color

View File

@ -3200,8 +3200,6 @@ function reporting_monitor_report($report, $content) {
metaconsole_connect($server);
}
$module = modules_get_agentmodule ($content['id_agent_module']);
$module_name = io_safe_output(
modules_get_agentmodule_name($content['id_agent_module']));
$agent_name = io_safe_output(
@ -3209,22 +3207,16 @@ function reporting_monitor_report($report, $content) {
$return['agent_name'] = $agent_name;
$return['module_name'] = $module_name;
$value = reporting_get_agentmodule_monitor(
$content['id_agent_module'],
$content['period'],
$module['min_critical'],
$module['max_critical'],
$report["datetime"]);
if ($value === __('Unknown')) {
// All values (except id module and report time) by default
$report = reporting_advanced_sla ($content['id_agent_module'],
$report["datetime"] - $content['period'], $report["datetime"]);
if ($report['time_total'] === $report['time_unknown'] || empty($content['id_agent_module'])) {
$return['data']['unknown'] = 1;
}
else {
$return['data']['unknown'] = 0;
$return["data"]["ok"]["value"] = $value;
$return["data"]["ok"]["formated_value"] = format_numeric($value, 2);
} else {
$return["data"]["ok"]["value"] = $report['SLA'];
$return["data"]["ok"]["formated_value"] = $report['SLA_fixed'];
$return["data"]["fail"]["value"] = 100 - $return["data"]["ok"]["value"];
$return["data"]["fail"]["formated_value"] = (100 - $return["data"]["ok"]["formated_value"]);
@ -3498,7 +3490,7 @@ function reporting_projection_graph($report, $content,
$content['period'],
$width,
$height,
'Projection%20Sample%20Graph',
'',
'',
0,
0,
@ -8383,149 +8375,6 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
}
/**
* Get Monitor report of a module.
* if (($min_value < $data['datos'])OR ($max_value > 0 AND
($data['datos'] > $min_value AND $data['datos'] < $max_value)))
* @param int Agent module to calculate monitor report
* @param int Period to check the SLA compliance.
* @param int Minimum data value the module in the right interval
* @param int Maximum data value the module in the right interval. False will
* ignore max value
* @param int Beginning date of the report in UNIX time (current date by default).
*
* @return float Monitor percentage of the requested module. False if no data were
* found
*/
function reporting_get_agentmodule_monitor ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0) {
global $config;
if (empty($id_agent_module))
return false;
// Set initial conditions
$bad_period = 0;
// Limit date to start searching data
$datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit);
// Initialize variables
if (empty ($date)) {
$date = get_system_time ();
}
if ($daysWeek === null) {
$daysWeek = array();
}
// Calculate the SLA for large time without hours
// Get interval data
$sql = sprintf ('SELECT *
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp > %d AND utimestamp <= %d',
$id_agent_module, $datelimit, $date);
$sql .= ' ORDER BY utimestamp ASC';
$interval_data = db_get_all_rows_sql ($sql, $search_in_history_db);
if ($interval_data === false) {
$interval_data = array ();
}
// Calculate planned downtime dates
$downtime_dates = reporting_get_planned_downtimes_intervals(
$id_agent_module, $datelimit, $date);
// Get previous data
$previous_data = modules_get_previous_data ($id_agent_module, $datelimit);
if ($previous_data !== false) {
$previous_data['utimestamp'] = $datelimit;
array_unshift ($interval_data, $previous_data);
}
// Get next data
$next_data = modules_get_next_data ($id_agent_module, $date);
if ($next_data !== false) {
$next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data);
}
else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data);
array_push ($interval_data, $next_data);
$next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data);
}
if (count ($interval_data) < 2) {
return false;
}
$first_data = array_shift ($interval_data);
// Do not count the empty start of an interval as 0
if ($first_data['utimestamp'] != $datelimit) {
$period = $date - $first_data['utimestamp'];
}
$previous_utimestamp = $first_data['utimestamp'];
if (($max_value > 0 AND $min_value > 0 ) AND ($data['datos'] > $min_value
AND $data['datos'] < $max_value)) {
$previous_status = 1;
foreach ($downtime_dates as $date_dt) {
if (($date_dt['date_from'] <= $previous_utimestamp) AND
($date_dt['date_to'] >= $previous_utimestamp)) {
$previous_status = 0;
}
}
}
else {
$previous_status = 0;
}
foreach ($interval_data as $data) {
// Previous status was critical
if ($previous_status == 1) {
$bad_period += $data['utimestamp'] - $previous_utimestamp;
}
if (array_key_exists('datos', $data)) {
// Re-calculate previous status for the next data
if (($max_value > 0) AND ($data['datos'] > $min_value
AND $data['datos'] < $max_value)) {
$previous_status = 1;
foreach ($downtime_dates as $date_dt) {
if (($date_dt['date_from'] <= $data['utimestamp']) AND ($date_dt['date_to'] >= $data['utimestamp'])) {
$previous_status = 0;
}
}
}
else {
$previous_status = 0;
}
}
$previous_utimestamp = $data['utimestamp'];
}
// Return the percentage of SLA compliance
return (float) (100 - ($bad_period / $period) * 100);
}
/**
* Get the time intervals where an agentmodule is affected by the planned downtimes.
*

View File

@ -817,12 +817,39 @@ else{
}
}
//data
$module_value = db_get_sql ('SELECT datos
FROM tagente_estado
WHERE id_agente_modulo = ' . $id_module);
//state
$module_status = db_get_sql ('SELECT estado
FROM tagente_estado
WHERE id_agente_modulo = ' . $id_module);
if (empty($module_value) || $module_value == 0) {
$colorStatus = COL_UNKNOWN;
}
else{
switch ($module_status) {
case 0: //Normal
$colorStatus = COL_NORMAL;
break;
case 1: //Critical
$colorStatus = COL_CRITICAL;
break;
case 2: //Warning
$colorStatus = COL_WARNING;
break;
case 4: //Not_INIT
$colorStatus = COL_NOTINIT;
break;
case 3: //Unknown
default:
$colorStatus = COL_UNKNOWN;
break;
}
}
$value_text = false;
if ($layoutData['image'] == 'percent') {
$value_text = false;
@ -944,13 +971,24 @@ else{
$homeurl = $config['homeurl'];
else
$homeurl = '';
if (get_parameter('action') == 'edit') {
if ( (get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap') ) {
if($width == 0 || $height == 0){
$img = '<img src="images/console/signes/module_graph.png" style="width:300px;height:180px;'.$imgpos.'">';
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/module_graph.png" style="width:300px;height:180px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/module_graph.png" style="width:300px;height:180px;'.$imgpos.'">';
}
}
else{
$img = '<img src="images/console/signes/module_graph.png" style="width:'.$width.'px;height:'.$height.'px;'.$imgpos.'">';
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/module_graph.png" style="width:'.$width.'px;height:'. $height.'px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/module_graph.png" style="width:'.$width.'px;height:'. $height.'px;'.$imgpos.'">';
}
}
}
else {
@ -1005,7 +1043,7 @@ else{
false, 1, false, 0, '', 0, 0, true,
$only_image, '', 1, false, '', false,
false, false, $layoutData['image'],
null, true, false, $type_graph);
null, false, true, $type_graph);
}
}
}

View File

@ -1577,7 +1577,6 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
}
var stack = 0, bars = true, lines = false, steps = false;
var plot = $.plot($('#' + graph_id), datas, options);
// Re-calculate the graph height with the legend height
@ -1760,7 +1759,6 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
if (serie_types[i] != 'points' && series.label != $('#hidden-unknown_text').val()) {
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).html(label_aux + '= ' + parseFloat(y).toFixed(precision_graph) + how_bigger + ' ' + unit);
console.log($('#legend_' + graph_id + ' .legendLabel'));
}
$('#legend_' + graph_id + ' .legendLabel')

View File

@ -121,9 +121,12 @@ if ($severity != -1) {
// In metaconsole mode the agent search is performed by name
if ($meta) {
if (($text_agent != __('All')) && ($text_agent !== '')) {
$text_agent = get_parameter("text_agent","");
$id_agent = get_parameter('id_agent',0);
if($id_agent){
$sql_post .= " AND agent_name IN (SELECT nombre FROM tmetaconsole_agent WHERE
id_tagente =".$id_agent." AND alias LIKE '".io_safe_input($text_agent)."')";
$filter_resume['agent'] = $text_agent;
$sql_post .= " AND agent_name LIKE '%$text_agent%'";
}
}
else {

View File

@ -271,6 +271,10 @@ else {
$show_validate_button = false;
$idx = 0;
if($meta){
$alias_array = array();
}
//Arrange data. We already did ACL's in the query
foreach ($result as $event) {
$data = array ();
@ -427,12 +431,17 @@ else {
if ($event["id_agente"] > 0) {
// Agent name
if ($meta) {
if(!empty($event["agent_name"])){
if(!array_key_exists($event["agent_name"],$alias_array)){
$alias_array [$event["agent_name"]] = db_get_value("alias","tmetaconsole_agent","nombre",$event["agent_name"]);
}
}
$agent_link = '<a href="'.$event["server_url"].'/index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=' . $event["id_agente"] . $event["server_url_hash"] . '">';
if (can_user_access_node ()) {
$data[$i] = '<b>' . $agent_link . $event["agent_name"] . '</a></b>';
$data[$i] = '<b>' . $agent_link . $alias_array [$event["agent_name"]] . '</a></b>';
}
else {
$data[$i] = $event["agent_name"];
$data[$i] = $alias_array [$event["agent_name"]] ;
}
}
else {

View File

@ -417,11 +417,9 @@ $params['return'] = true;
if ($meta) {
$params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax';
}
else {
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent';
$params['hidden_input_idagent_value'] = $id_agent;
}
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent';
$params['hidden_input_idagent_value'] = $id_agent;
$data[1] .= ui_print_agent_autocomplete_input($params);
$table_advanced->data[] = $data;

View File

@ -282,6 +282,8 @@ sub pandora_load_config {
$pa_config->{"sync_retries"} = 2; # 7.0
$pa_config->{"sync_timeout"} = 5; # 7.0
$pa_config->{"dynamic_updates"} = 5; # 7.0
$pa_config->{"dynamic_warning"} = 25; # 7.0
$pa_config->{"dynamic_constant"} = 10; # 7.0
# Internal MTA for alerts, each server need its own config.
$pa_config->{"mta_address"} = '127.0.0.1'; # Introduced on 2.0
@ -1012,6 +1014,12 @@ sub pandora_load_config {
elsif ($parametro =~ m/^dynamic_updates\s+([0-9]*)/i) {
$pa_config->{'dynamic_updates'}= clean_blank($1);
}
elsif ($parametro =~ m/^dynamic_warning\s+([0-9]*)/i) {
$pa_config->{'dynamic_warning'}= clean_blank($1);
}
elsif ($parametro =~ m/^dynamic_constant\s+([0-9]*)/i) {
$pa_config->{'dynamic_constant'}= clean_blank($1);
}
} # end of loop for parameter #
# Set to RDBMS' standard port