Merge branch 'ent-7063-Informes-de-servicio-en-Meta' into 'develop'

report SLA services to metaconsole pandora_enterprise#7063

See merge request artica/pandorafms!4678
This commit is contained in:
Daniel Rodriguez 2022-03-23 10:44:01 +00:00
commit 38b71b3de7
3 changed files with 101 additions and 9 deletions

View File

@ -27,6 +27,8 @@
* ============================================================================
*/
use PandoraFMS\Enterprise\Metaconsole\Synchronizer;
global $config;
@ -3839,7 +3841,12 @@ function print_SLA_list($width, $action, $idItem=null)
[$item['id_agent_module']]
);
echo '<td class="sla_list_service_col">';
echo printSmallFont($nameService);
if ($meta && $server_name != '') {
echo $server_name.' &raquo; '.$nameService;
} else {
echo $nameService;
}
echo '</th>';
}
@ -3986,8 +3993,8 @@ function print_SLA_list($width, $action, $idItem=null)
<?php
}
if (enterprise_installed()
&& $report_item_type == 'SLA_services'
if (enterprise_installed() === true
&& $report_item_type === 'SLA_services'
) {
enterprise_include_once(
'include/functions_services.php'
@ -4006,8 +4013,9 @@ function print_SLA_list($width, $action, $idItem=null)
],
]
);
if (!empty($services_tmp)
&& $services_tmp != ENTERPRISE_NOT_HOOK
if (empty($services_tmp) === false
&& $services_tmp !== ENTERPRISE_NOT_HOOK
) {
foreach ($services_tmp as $service) {
$check_module_sla = modules_check_agentmodule_exists(
@ -4016,14 +4024,89 @@ function print_SLA_list($width, $action, $idItem=null)
$check_module_sla_value = modules_check_agentmodule_exists(
$service['sla_value_id_module']
);
if ($check_module_sla
&& $check_module_sla_value
if ($check_module_sla === true
&& $check_module_sla_value === true
) {
$services[$service['id']] = $service['name'];
}
}
}
if (is_metaconsole() === true) {
$sc = new Synchronizer();
$node_services = $sc->apply(
function ($node) {
try {
$node->connect();
$services_tmp = enterprise_hook(
'services_get_services',
[
false,
[
'id',
'name',
'description',
'sla_id_module',
'sla_value_id_module',
],
]
);
$all_services = [];
if (empty($services_tmp) === false
&& $services_tmp !== ENTERPRISE_NOT_HOOK
) {
foreach ($services_tmp as $service) {
$check_module_sla = modules_check_agentmodule_exists(
$service['sla_id_module']
);
$check_module_sla_value = modules_check_agentmodule_exists(
$service['sla_value_id_module']
);
if ($check_module_sla === true
&& $check_module_sla_value === true
) {
$all_services[$service['id']] = $service;
}
}
}
$node->disconnect();
} catch (\Exception $e) {
$all_services = false;
}
if ($all_services !== false) {
return array_reduce(
$all_services,
function ($carry, $item) use ($node) {
$carry[] = [
'id' => $node->id().'|'.$item['id'],
'name' => io_safe_output(
$node->server_name().' &raquo; '.$item['name']
),
];
return $carry;
},
[]
);
}
return [];
},
false
);
foreach ($node_services as $ns) {
foreach ($ns as $k => $ser) {
$services[$ser['id']] = $ser['name'];
}
}
}
echo '<td class="sla_list_service_col">';
echo html_print_select(
$services,
@ -5334,6 +5417,11 @@ function addSLARow() {
var slaMax = $("input[name=sla_max]").val();
var slaLimit = $("input[name=sla_limit]").val();
var serviceId = $("select#id_service>option:selected").val();
if(serviceId != '' && serviceId.split('|').length > 1 ) {
var ids = serviceId.split('|');
serverId = ids[0];
serviceId = ids[1];
}
var serviceName = $("select#id_service>option:selected").text();
if ((((idAgent != '') && (idAgent > 0))

View File

@ -653,7 +653,8 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Graphs'),
'name' => __('Custom graph'),
];
// Only pandora managers have access to the whole database
// Only pandora managers have access to the whole database.
if (check_acl($config['id_user'], 0, 'PM')) {
$types['sql_graph_vbar'] = [
'optgroup' => __('Graphs'),
@ -711,7 +712,7 @@ function reports_get_report_types($template=false, $not_editor=false)
'name' => __('Hourly S.L.A.'),
];
if (!$config['metaconsole'] && !$template) {
if ($template === false) {
$types['SLA_services'] = [
'optgroup' => __('SLA'),
'name' => __('Services S.L.A.'),

View File

@ -1040,6 +1040,7 @@ function adjustTextUnits(name) {
"selected",
true
);
$("#" + name + "_units").trigger("change");
$("#text-" + name + "_text").val(restPrev);
unitsSelected = true;
}
@ -1048,7 +1049,9 @@ function adjustTextUnits(name) {
});
if (unitsSelected == false) {
//$("#" + name + "_units option:last").prop("selected", true);
$("#" + name + "_units option:last").prop("selected", true);
$("#" + name + "_units").trigger("change");
$("#text-" + name + "_text").val(restPrev);
}