fixed errors

This commit is contained in:
Daniel Barbero Martin 2019-11-13 15:52:09 +01:00
parent 7103317bc2
commit a0db941b1e

View File

@ -70,6 +70,7 @@ class Diagnostics extends Wizard
$this->ajaxController = $page; $this->ajaxController = $page;
$this->pdf = $pdf; $this->pdf = $pdf;
$this->product_name = io_safe_output(get_product_name());
} }
@ -126,7 +127,7 @@ class Diagnostics extends Wizard
// Header. // Header.
ui_print_page_header( ui_print_page_header(
__('Pandora FMS Diagnostic tool'), __('%s Diagnostic tool', $this->product_name),
'images/gm_massive_operations.png', 'images/gm_massive_operations.png',
false, false,
'diagnostic_tool_tab', 'diagnostic_tool_tab',
@ -190,7 +191,7 @@ class Diagnostics extends Wizard
foreach ($infoMethods as $key => $method) { foreach ($infoMethods as $key => $method) {
switch ($method) { switch ($method) {
case 'getStatusInfo': case 'getStatusInfo':
$title = __('Info status pandoraFms'); $title = __('Info status %s', $this->product_name);
break; break;
case 'getPHPSetup': case 'getPHPSetup':
@ -219,16 +220,17 @@ class Diagnostics extends Wizard
case 'getTablesFragmentation': case 'getTablesFragmentation':
$title = __( $title = __(
'Tables fragmentation in the Pandora FMS database' 'Tables fragmentation in the %s database',
$this->product_name
); );
break; break;
case 'getPandoraFMSLogsDates': case 'getPandoraFMSLogsDates':
$title = __('Pandora FMS logs dates'); $title = __('%s logs dates', $this->product_name);
break; break;
case 'getLicenceInformation': case 'getLicenceInformation':
$title = __('Pandora FMS Licence Information'); $title = __('%s Licence Information', $this->product_name);
break; break;
case 'getAttachmentFolder': case 'getAttachmentFolder':
@ -240,7 +242,7 @@ class Diagnostics extends Wizard
break; break;
case 'getServerThreads': case 'getServerThreads':
$title = __('Pandora FMS server threads'); $title = __('%s server threads', $this->product_name);
break; break;
case 'getShowEngine': case 'getShowEngine':
@ -399,11 +401,11 @@ class Diagnostics extends Wizard
'error' => false, 'error' => false,
'data' => [ 'data' => [
'buildVersion' => [ 'buildVersion' => [
'name' => __('Pandora FMS Build'), 'name' => __('%s Build', $this->product_name),
'value' => $build_version, 'value' => $build_version,
], ],
'version' => [ 'version' => [
'name' => __('Pandora FMS Version'), 'name' => __('%s Version', $this->product_name),
'value' => $pandora_version, 'value' => $pandora_version,
], ],
'mr' => [ 'mr' => [
@ -512,7 +514,7 @@ class Diagnostics extends Wizard
'error' => false, 'error' => false,
'data' => [ 'data' => [
'countAgents' => [ 'countAgents' => [
'name' => __('Total agentsy'), 'name' => __('Total agents'),
'value' => $countAgents, 'value' => $countAgents,
], ],
'countModules' => [ 'countModules' => [
@ -586,7 +588,10 @@ class Diagnostics extends Wizard
$pandoraDbLastRun = __('Pandora DB has never been executed'); $pandoraDbLastRun = __('Pandora DB has never been executed');
if ($dateDbMantenaince !== false) { if ($dateDbMantenaince !== false) {
$difference = ($currentTime - $dateDbMantenaince); $difference = ($currentTime - $dateDbMantenaince);
$pandoraDbLastRun = human_time_comparation($difference); $pandoraDbLastRun = human_time_description_raw(
$difference,
true
);
$pandoraDbLastRun .= ' '.__('Ago'); $pandoraDbLastRun .= ' '.__('Ago');
} }
@ -953,10 +958,10 @@ class Diagnostics extends Wizard
$unit = 'M'; $unit = 'M';
$pathServerLogs = 'var/log/pandora/pandora_server.log'; $pathServerLogs = '/var/log/pandora/pandora_server.log';
$servers = $this->getLogInfo($pathServerLogs); $servers = $this->getLogInfo($pathServerLogs);
$pathErrLogs = 'var/log/pandora/pandora_server.error'; $pathErrLogs = '/var/log/pandora/pandora_server.error';
$errors = $this->getLogInfo($pathErrLogs); $errors = $this->getLogInfo($pathErrLogs);
$pathConsoleLogs = $config['homedir'].'/pandora_console.log'; $pathConsoleLogs = $config['homedir'].'/pandora_console.log';
@ -1018,6 +1023,7 @@ class Diagnostics extends Wizard
$customerKey = db_get_value_sql($sql); $customerKey = db_get_value_sql($sql);
// Extract Info license. // Extract Info license.
enterprise_include_once('include/functions_license.php');
$license = enterprise_hook('license_get_info'); $license = enterprise_hook('license_get_info');
// Agent Capacity. // Agent Capacity.
@ -1050,6 +1056,7 @@ class Diagnostics extends Wizard
WHERE id_tipo_modulo WHERE id_tipo_modulo
BETWEEN 6 AND 18' BETWEEN 6 AND 18'
); );
$totalModuleIntervalTime = db_get_value_sql( $totalModuleIntervalTime = db_get_value_sql(
'SELECT SUM(module_interval) 'SELECT SUM(module_interval)
FROM tagente_modulo FROM tagente_modulo
@ -1060,26 +1067,26 @@ class Diagnostics extends Wizard
$averageTime = 0; $averageTime = 0;
if ($totalModuleIntervalTime !== false) { if ($totalModuleIntervalTime !== false) {
$averageTime = number_format( $averageTime = number_format(
((int) $totalModuleIntervalTime / (int) $totalNetworkModules), ((int) $totalNetworkModules / (int) $totalModuleIntervalTime),
3 3
); );
} }
$moduleNetworkmsg = __( $moduleNetworkmsg = __(
sprintf( sprintf(
'The system is not overloaded (average time %d)', 'The system is not overloaded (average time %f)',
$average_time $averageTime
) )
); );
$moduleNetworkst = 1; $moduleNetworkst = 1;
if ($average_time === 0) { if ($averageTime === 0) {
$moduleNetworkmsg = __('The system has no load'); $moduleNetworkmsg = __('The system has no load');
$moduleNetworkst = 0; $moduleNetworkst = 0;
} else if ($averageTime < 180) { } else if ($averageTime > 180) {
$moduleNetworkmsg = __( $moduleNetworkmsg = __(
sprintf( sprintf(
'The system is overloaded (average time %d) and a very fine configuration is required', 'The system is overloaded (average time %f) and a very fine configuration is required',
$average_time $averageTime
) )
); );
$moduleNetworkst = 0; $moduleNetworkst = 0;
@ -1673,7 +1680,7 @@ class Diagnostics extends Wizard
'status' => 0, 'status' => 0,
]; ];
if (is_file($path) === true) { if (file_exists($path) === true) {
$fileSize = filesize($path); $fileSize = filesize($path);
$sizeServerLog = number_format($fileSize); $sizeServerLog = number_format($fileSize);
$sizeServerLog = (0 + str_replace(',', '', $sizeServerLog)); $sizeServerLog = (0 + str_replace(',', '', $sizeServerLog));
@ -1872,7 +1879,7 @@ class Diagnostics extends Wizard
$mail_feedback = 'feedback@artica.es'; $mail_feedback = 'feedback@artica.es';
$email = $mail_feedback; $email = $mail_feedback;
$subject = 'PandoraFMS Report '.$config['pandora_uid']; $subject = $this->product_name.' Report '.$config['pandora_uid'];
$text = get_parameter('what-happened', ''); $text = get_parameter('what-happened', '');
$attachment = get_parameter_switch('include_installation_data', 0); $attachment = get_parameter_switch('include_installation_data', 0);
$email_from = get_parameter_switch('email', ''); $email_from = get_parameter_switch('email', '');