Merge branch 'ent-12178-metaconsola-los-servidores-de-nodo-no-desaparecen-de-la-vista-al-convertilo-en-metaconsola' into 'develop'
not show servers in metaconsole pandora_enterprise#12178 See merge request artica/pandorafms!6793
This commit is contained in:
commit
6aab32bb42
|
@ -54,7 +54,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
|
|||
// ======= Servers List ===============================================
|
||||
if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) {
|
||||
$servers = [];
|
||||
$servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
|
||||
$servers['all'] = (int) count((servers_get_info() ?? []));
|
||||
if ($servers['all'] != 0) {
|
||||
$servers['up'] = (int) servers_check_status();
|
||||
$servers['down'] = ($servers['all'] - $servers['up']);
|
||||
|
|
|
@ -1510,17 +1510,42 @@ class ConsoleSupervisor
|
|||
{
|
||||
global $config;
|
||||
|
||||
$types_sql = sprintf(
|
||||
' AND (
|
||||
`server_type` != %d AND
|
||||
`server_type` != %d
|
||||
)',
|
||||
SERVER_TYPE_AUTOPROVISION,
|
||||
SERVER_TYPE_MIGRATION
|
||||
);
|
||||
if (is_metaconsole() === true && isset($config['ndbh']) === false) {
|
||||
$types_sql = sprintf(
|
||||
' AND (
|
||||
`server_type` = %d OR
|
||||
`server_type` = %d OR
|
||||
`server_type` = %d OR
|
||||
`server_type` = %d
|
||||
)',
|
||||
SERVER_TYPE_AUTOPROVISION,
|
||||
SERVER_TYPE_EVENT,
|
||||
SERVER_TYPE_MIGRATION,
|
||||
SERVER_TYPE_PREDICTION
|
||||
);
|
||||
}
|
||||
|
||||
$servers = db_get_all_rows_sql(
|
||||
'SELECT
|
||||
id_server,
|
||||
name,
|
||||
server_type,
|
||||
server_keepalive,
|
||||
status,
|
||||
unix_timestamp() - unix_timestamp(keepalive) as downtime
|
||||
FROM tserver
|
||||
WHERE
|
||||
unix_timestamp() - unix_timestamp(keepalive) > server_keepalive'
|
||||
sprintf(
|
||||
'SELECT id_server,
|
||||
`name`,
|
||||
server_type,
|
||||
server_keepalive,
|
||||
`status`,
|
||||
unix_timestamp() - unix_timestamp(keepalive) as downtime
|
||||
FROM tserver
|
||||
WHERE unix_timestamp() - unix_timestamp(keepalive) > server_keepalive
|
||||
%s',
|
||||
$types_sql
|
||||
)
|
||||
);
|
||||
|
||||
if ($servers === false) {
|
||||
|
|
|
@ -12546,7 +12546,7 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru
|
|||
$table_ind = html_get_predefined_table();
|
||||
|
||||
$servers = [];
|
||||
$servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
|
||||
$servers['all'] = (int) count((servers_get_info() ?? []));
|
||||
$servers['up'] = (int) servers_check_status();
|
||||
$servers['down'] = ($servers['all'] - $servers['up']);
|
||||
if ($servers['all'] == 0) {
|
||||
|
@ -12607,7 +12607,7 @@ function reporting_get_stats_indicators_mobile($data, $width=280, $height=20, $h
|
|||
$table_ind = html_get_predefined_table();
|
||||
|
||||
$servers = [];
|
||||
$servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
|
||||
$servers['all'] = (int) count((servers_get_info() ?? []));
|
||||
$servers['up'] = (int) servers_check_status();
|
||||
$servers['down'] = ($servers['all'] - $servers['up']);
|
||||
if ($servers['all'] == 0) {
|
||||
|
|
|
@ -615,7 +615,7 @@ function servers_get_rate($avg_interval, $num_modules)
|
|||
* This function will get all the server information in an array
|
||||
* or a specific server.
|
||||
*
|
||||
* @param integer $id_server An optional integer or array of integers
|
||||
* @param integer|array $id_server An optional integer or array of integers
|
||||
* to select specific servers.
|
||||
*
|
||||
* @return mixed False in case the server doesn't exist or an array with info.
|
||||
|
@ -624,28 +624,63 @@ function servers_get_info($id_server=-1, $sql_limit=-1)
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (is_array($id_server)) {
|
||||
$select_id = ' WHERE id_server IN ('.implode(',', $id_server).')';
|
||||
$select_id = '';
|
||||
if (is_array($id_server) === true) {
|
||||
$select_id = ' AND id_server IN ('.implode(',', $id_server).')';
|
||||
} else if ($id_server > 0) {
|
||||
$select_id = ' WHERE id_server IN ('.(int) $id_server.')';
|
||||
} else {
|
||||
$select_id = '';
|
||||
$select_id = ' AND id_server IN ('.(int) $id_server.')';
|
||||
}
|
||||
|
||||
$sql = '
|
||||
SELECT *
|
||||
FROM tserver '.$select_id.'
|
||||
ORDER BY server_type';
|
||||
$types_sql = sprintf(
|
||||
' AND (
|
||||
`server_type` != %d AND
|
||||
`server_type` != %d
|
||||
)',
|
||||
SERVER_TYPE_AUTOPROVISION,
|
||||
SERVER_TYPE_MIGRATION
|
||||
);
|
||||
if (is_metaconsole() === true && isset($config['ndbh']) === false) {
|
||||
$types_sql = sprintf(
|
||||
' AND (
|
||||
`server_type` = %d OR
|
||||
`server_type` = %d OR
|
||||
`server_type` = %d OR
|
||||
`server_type` = %d
|
||||
)',
|
||||
SERVER_TYPE_AUTOPROVISION,
|
||||
SERVER_TYPE_EVENT,
|
||||
SERVER_TYPE_MIGRATION,
|
||||
SERVER_TYPE_PREDICTION
|
||||
);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT *
|
||||
FROM tserver
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
ORDER BY server_type',
|
||||
$select_id,
|
||||
$types_sql
|
||||
);
|
||||
|
||||
if ($sql_limit !== -1) {
|
||||
$sql = '
|
||||
SELECT *
|
||||
FROM tserver '.$select_id.'
|
||||
ORDER BY server_type'.$sql_limit;
|
||||
$sql = sprintf(
|
||||
'SELECT *
|
||||
FROM tserver
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
ORDER BY server_type
|
||||
%s',
|
||||
$select_id,
|
||||
$types_sql,
|
||||
$sql_limit
|
||||
);
|
||||
}
|
||||
|
||||
$result = db_get_all_rows_sql($sql);
|
||||
$time = get_system_time();
|
||||
|
||||
if (empty($result)) {
|
||||
return false;
|
||||
|
@ -1445,6 +1480,12 @@ function servers_get_server_string_name(int $server)
|
|||
case SERVER_TYPE_NCM:
|
||||
return __('NCM server');
|
||||
|
||||
case SERVER_TYPE_AUTOPROVISION:
|
||||
return __('Autoprovision server');
|
||||
|
||||
case SERVER_TYPE_MIGRATION:
|
||||
return __('Migration server');
|
||||
|
||||
default:
|
||||
return __('N/A');
|
||||
}
|
||||
|
|
|
@ -58,6 +58,9 @@ my $Restart = 0;
|
|||
# Controlled exit
|
||||
my $Running = 0;
|
||||
|
||||
# License
|
||||
my $License;
|
||||
|
||||
########################################################################
|
||||
# Print the given message with a preceding timestamp.
|
||||
########################################################################
|
||||
|
@ -359,6 +362,27 @@ sub ha_update_server($$) {
|
|||
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Restart pandora server on demand.
|
||||
###############################################################################
|
||||
sub ha_restart_server($$) {
|
||||
my ($config, $dbh) = @_;
|
||||
my $OSNAME = $^O;
|
||||
|
||||
my $current_license;
|
||||
if (!defined($License)) {
|
||||
$License = get_db_value($dbh, 'SELECT `value` FROM `tupdate_settings` WHERE `key` = "customer_key"');
|
||||
$current_license = $License;
|
||||
} else {
|
||||
$current_license = get_db_value($dbh, 'SELECT `value` FROM `tupdate_settings` WHERE `key` = "customer_key"');
|
||||
}
|
||||
|
||||
if($License ne $current_license) {
|
||||
ha_restart_pandora($config);
|
||||
$License = $current_license;
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Dump the list of known databases to disk.
|
||||
################################################################################
|
||||
|
@ -691,6 +715,9 @@ sub ha_main_pandora($) {
|
|||
# Check if there are updates pending.
|
||||
ha_update_server($conf, $dbh);
|
||||
|
||||
# Check restart server on demand.
|
||||
ha_restart_server($conf, $dbh);
|
||||
|
||||
# Keep pandora running
|
||||
ha_keep_pandora_running($conf, $dbh);
|
||||
|
||||
|
|
Loading…
Reference in New Issue