Merge branch 'ent-3121-Report-tipo-general-salida-de-datos-booleanos' into 'develop'

Visual change in the data of general type reports

Closes pandora_enterprise#3121

See merge request artica/pandorafms!2113

Former-commit-id: f12dc3ad2cf11d1b48db42b4de8288073011f635
This commit is contained in:
Alejandro Fraguas 2019-02-12 16:35:55 +01:00
commit 3f3c527c3b
5 changed files with 126 additions and 88 deletions

View File

@ -472,11 +472,12 @@ function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnT
DB column mapping table used by tree_agents (and get module_properties)
*/
// agent related field mappings (output field => column designation for 'tagente')
/*
* Agent related field mappings (output field => column designation for 'tagente').
* agent_id is not in this list (because it is mandatory).
* agent_id_group is not in this list.
*/
$agent_field_column_mapping = [
/*
agent_id is not in this list (because it is mandatory) */
// agent_id_group is not in this list
'agent_name' => 'nombre as agent_name',
'agent_direction' => 'direccion as agent_direction',
'agent_comentary' => 'comentarios as agent_comentary',
@ -496,8 +497,8 @@ $agent_field_column_mapping = [
];
// module related field mappings 1/2 (output field => column for 'tagente_modulo')
// module_id_agent_modulo is not in this list
$module_field_column_mampping = [
// module_id_agent_modulo is not in this list
'module_id_agent' => 'id_agente as module_id_agent',
'module_id_module_type' => 'id_tipo_modulo as module_id_module_type',
'module_description' => 'descripcion as module_description',
@ -541,8 +542,8 @@ $module_field_column_mampping = [
];
// module related field mappings 2/2 (output field => column for 'tagente_estado')
// module_id_agent_modulo is not in this list
$estado_fields_to_columns_mapping = [
// module_id_agent_modulo is not in this list
'module_id_agent_state' => 'id_agente_estado as module_id_agent_state',
'module_data' => 'datos as module_data',
'module_timestamp' => 'timestamp as module_timestamp',
@ -14610,57 +14611,66 @@ function api_get_users($thrash1, $thrash2, $other, $returnType)
}
/**
* Resets module counts and alert counts in the agents
*
* @param $id id of the agent you want to synchronize. Add "All" to synchronize all agents
* @param $trash1
* @param $trash2
* @param $trash3
*
* Example:
*
* Example:
* api.php?op=set&op2=reset_agent_counts&apipass=1234&user=admin&pass=pandora&id=All
*/
function api_set_reset_agent_counts ($id, $thrash1, $thrash2, $thrash3)
function api_set_reset_agent_counts($id, $thrash1, $thrash2, $thrash3)
{
global $config;
global $config;
if (!check_acl($config['id_user'], 0, "AW")) {
returnError('forbidden', 'string');
return;
}
if (!check_acl($config['id_user'], 0, 'AW')) {
returnError('forbidden', 'string');
return;
}
if ($id == '' || !$id) {
returnError('error_parameter', __('Error. Agent cannot be left blank.'));
return;
}
if ($id == '' || !$id) {
returnError('error_parameter', __('Error. Agent cannot be left blank.'));
return;
}
if ($id != "All"){
$agent = db_get_row_filter('tagente', array('id_agente' => $id));
if (empty ($agent)){
returnError('error_agent', __('This agent does not exist.'));
return;
}else {
$return = db_process_sql_update ('tagente',
array ('update_module_count' => 1, 'update_alert_count' => 1),
array('id_agente' => $id)
);
}
}
else {
$return = db_process_sql_update ('tagente',
array ('update_module_count' => 1, 'update_alert_count' => 1)
);
}
if ($id != 'All') {
$agent = db_get_row_filter('tagente', ['id_agente' => $id]);
if (empty($agent)) {
returnError('error_agent', __('This agent does not exist.'));
return;
} else {
$return = db_process_sql_update(
'tagente',
[
'update_module_count' => 1,
'update_alert_count' => 1,
],
['id_agente' => $id]
);
}
} else {
$return = db_process_sql_update(
'tagente',
[
'update_module_count' => 1,
'update_alert_count' => 1,
]
);
}
$data = __('Successfully updated module/alert count in id agent %d.', $id);
if ($id == 'All') {
$data = __('Successfully updated module/alert count in all agents');
}
$data = __('Successfully updated module/alert count in id agent %d.', $id);
if ($id == "All")
$data = __('Successfully updated module/alert count in all agents');
if ($return === false)
returnError('error_reset_agent_counts', 'Could not be updated module/alert counts in id agent %d.', $id);
else
returnData('string', array('type' => 'string', 'data' => $data));
if ($return === false) {
returnError('error_reset_agent_counts', 'Could not be updated module/alert counts in id agent %d.', $id);
} else {
returnData('string', ['type' => 'string', 'data' => $data]);
}
}

View File

@ -1183,12 +1183,11 @@ function reporting_SLA(
}
}
// SLA items sorted descending ()
if ($content['top_n'] == 2) {
// SLA items sorted descending ()
arsort($return['data']['']);
}
// SLA items sorted ascending
else if ($content['top_n'] == 1) {
} else if ($content['top_n'] == 1) {
// SLA items sorted ascending
asort($sla_showed_values);
}
@ -6724,7 +6723,7 @@ function reporting_general($report, $content)
'id_agente_modulo',
$row['id_agent_module']
);
$id_module_type = db_get_value('id_tipo_modulo', 'tagente_modulo', 'nombre', $mod_name);
if ($content['period'] == 0) {
$data_res[$index] = modules_get_last_value($row['id_agent_module']);
} else {
@ -6771,16 +6770,31 @@ function reporting_general($report, $content)
$agent_name[$index] = $ag_name;
$module_name[$index] = $mod_name;
$units[$index] = $unit;
$id_module_types[$index] = $id_module_type;
$operations[$index] = $row['operation'];
break;
case REPORT_GENERAL_GROUP_BY_AGENT:
$id_module_types[$index] = $id_module_type;
if ($id_module_types[$index] == 2 || $id_module_types[$index] == 6 || $id_module_types[$index] == 9 || $id_module_types[$index] == 18) {
$data_res[$index] = round($data_res[$index], 0, PHP_ROUND_HALF_DOWN);
}
if ($id_module_types[$index] == 2 || $id_module_types[$index] == 6 || $id_module_types[$index] == 9 || $id_module_types[$index] == 18) {
if ($data_res[$index] == 1) {
$data_res[$index] = 'Up';
} else if ($data_res[$index] == 0) {
$data_res[$index] = 'Down';
}
}
if ($data_res[$index] === false) {
$return['data'][$ag_name][$mod_name] = null;
} else {
if (!is_numeric($data_res[$index])) {
$return['data'][$ag_name][$mod_name] = $data_res[$index];
} else {
hd($data_res[$index], true);
$return['data'][$ag_name][$mod_name] = format_for_graph($data_res[$index], 2).' '.$unit;
}
}
@ -6896,7 +6910,7 @@ function reporting_general($report, $content)
$data['module'] = $module_name[$i];
$data['id_agent_module'] = $id_agent_module[$i];
$data['id_agent'] = agents_get_agent_id_by_module_id($id_agent_module[$i]);
$data['id_module_type'] = $id_module_types[$i];
$data['operator'] = '';
if ($content['period'] != 0) {
switch ($operations[$i]) {

View File

@ -2629,21 +2629,6 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0)
}
function get_agent_first_time($agent_name)
{
$id = agents_get_agent_id($agent_name, true);
$utimestamp = db_get_all_rows_sql(
'SELECT utimestamp FROM tagente_datos WHERE id_agente_modulo IN
(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '.$id.')
ORDER BY utimestamp ASC LIMIT 1'
);
$utimestamp = $utimestamp[0]['utimestamp'];
return $utimestamp;
}
function reporting_html_general(&$table, $item)
{
if (!empty($item['data'])) {
@ -2676,6 +2661,16 @@ function reporting_html_general(&$table, $item)
// End - Order by agent
foreach ($item['data'] as $row) {
if ($row['id_module_type'] == 6 || $row['id_module_type'] == 9 || $row['id_module_type'] == 18 || $row['id_module_type'] == 2) {
$row['formated_value'] = round($row['formated_value'], 0, PHP_ROUND_HALF_DOWN);
}
if (($row['id_module_type'] == 6 || $row['id_module_type'] == 9 || $row['id_module_type'] == 18 || $row['id_module_type'] == 2) && $row['formated_value'] == 1) {
$row['formated_value'] = 'Up';
} else if (($row['id_module_type'] == 6 || $row['id_module_type'] == 9 || $row['id_module_type'] == 18 || $row['id_module_type'] == 2) && $row['formated_value'] == 0) {
$row['formated_value'] = 'Down';
}
if ($item['date']['period'] != 0) {
$table1->data[] = [
$row['agent'],
@ -2738,13 +2733,11 @@ function reporting_html_general(&$table, $item)
}
$list_modules = array_keys($list_modules);
$table1->width = '99%';
$table1->data = [];
$table1->head = array_merge([__('Agent')], $list_modules);
foreach ($item['data'] as $agent => $modules) {
$row = [];
$row['agent'] = $agent;
$table1->style['agent'] = 'text-align: center;';
foreach ($list_modules as $name) {
@ -2804,6 +2797,21 @@ function reporting_html_general(&$table, $item)
}
function get_agent_first_time($agent_name)
{
$id = agents_get_agent_id($agent_name, true);
$utimestamp = db_get_all_rows_sql(
'SELECT utimestamp FROM tagente_datos WHERE id_agente_modulo IN
(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '.$id.')
ORDER BY utimestamp ASC LIMIT 1'
);
$utimestamp = $utimestamp[0]['utimestamp'];
return $utimestamp;
}
function reporting_html_sql(&$table, $item)
{
if (!$item['correct']) {

View File

@ -3897,25 +3897,31 @@ function visual_map_get_user_layouts(
return $retval;
}
function visual_map_translate_agent_status ($agent_status) {
switch ($agent_status) {
case AGENT_STATUS_NORMAL:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
default:
return VISUAL_MAP_STATUS_NORMAL;
case AGENT_STATUS_CRITICAL:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
return VISUAL_MAP_STATUS_CRITICAL_BAD;
case AGENT_STATUS_WARNING:
case AGENT_MODULE_STATUS_WARNING_ALERT:
return VISUAL_MAP_STATUS_WARNING;
case AGENT_STATUS_NOT_INIT:
case AGENT_STATUS_UNKNOWN:
case -1:
return VISUAL_MAP_STATUS_UNKNOWN;
case AGENT_STATUS_ALERT_FIRED:
return VISUAL_MAP_STATUS_CRITICAL_ALERT;
}
function visual_map_translate_agent_status($agent_status)
{
switch ($agent_status) {
case AGENT_STATUS_NORMAL:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
default:
return VISUAL_MAP_STATUS_NORMAL;
case AGENT_STATUS_CRITICAL:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
return VISUAL_MAP_STATUS_CRITICAL_BAD;
case AGENT_STATUS_WARNING:
case AGENT_MODULE_STATUS_WARNING_ALERT:
return VISUAL_MAP_STATUS_WARNING;
case AGENT_STATUS_NOT_INIT:
case AGENT_STATUS_UNKNOWN:
case -1:
return VISUAL_MAP_STATUS_UNKNOWN;
case AGENT_STATUS_ALERT_FIRED:
return VISUAL_MAP_STATUS_CRITICAL_ALERT;
}
}

View File

@ -112,8 +112,8 @@
</div>
<div style='height: 10px'>
<?php
$version = '7.0NG.731';
$build = '190212';
$version = '7.0NG.731';
$build = '190212';
$banner = "v$version Build $build";
error_reporting(0);