WIP Cluster references updated

This commit is contained in:
fbsanchez 2020-05-22 12:14:01 +02:00
parent b0e8287c61
commit e66f33fd37
8 changed files with 100 additions and 36 deletions

View File

@ -556,9 +556,18 @@ if ($agents !== false) {
$agent['alias'] = $agent['nombre']; $agent['alias'] = $agent['nombre'];
} }
if ($agent['id_os'] == 100) { if ($agent['id_os'] == CLUSTER_OS_ID) {
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']); if (enterprise_installed()) {
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.$agent['alias'].'</a>'; $cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
echo '<a href="'.$url.'">'.$agent['alias'].'</a>';
}
} else { } else {
echo '<a alt ='.$agent['nombre']." href='index.php?sec=gagente& echo '<a alt ='.$agent['nombre']." href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=$main_tab& sec2=godmode/agentes/configurar_agente&tab=$main_tab&
@ -594,10 +603,18 @@ if ($agents !== false) {
echo '</span><div class="left actions" style="visibility: hidden; clear: left">'; echo '</span><div class="left actions" style="visibility: hidden; clear: left">';
if ($check_aw) { if ($check_aw) {
if ($agent['id_os'] == 100) { if ($agent['id_os'] == CLUSTER_OS_ID) {
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']); if (enterprise_installed()) {
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.__('Edit').'</a>'; $cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
echo ' | '; $agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
echo '<a href="'.$url.'">'.__('Edit').'</a>';
}
} else { } else {
echo '<a href="index.php?sec=gagente& echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main& sec2=godmode/agentes/configurar_agente&tab=main&
@ -618,8 +635,18 @@ if ($agents !== false) {
id_agente='.$agent['id_agente'].'">'.__('Alerts').'</a>'; id_agente='.$agent['id_agente'].'">'.__('Alerts').'</a>';
echo ' | '; echo ' | ';
if ($agent['id_os'] == 100) { if ($agent['id_os'] == CLUSTER_OS_ID) {
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id='.$cluster['id'].'">'.__('View').'</a>'; if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=view&id='.$cluster->id()
);
echo '<a href="'.$url.'">'.__('View').'</a>';
}
} else { } else {
echo '<a href="index.php?sec=estado echo '<a href="index.php?sec=estado
&sec2=operation/agentes/ver_agente &sec2=operation/agentes/ver_agente

View File

@ -1537,14 +1537,15 @@ class NetworkMap
/** /**
* Returns target color to be used based on the status received. * Returns target color to be used based on the status received.
* *
* @param integer $status Source information. * @param integer $status Source information.
* @param boolean $force_module It's a module.
* *
* @return string HTML tag for color. * @return string HTML tag for color.
*/ */
public static function getColorByStatus($status) public static function getColorByStatus($status, ?bool $force_module=false)
{ {
include_once __DIR__.'/../functions_modules.php'; include_once __DIR__.'/../functions_modules.php';
return modules_get_color_status($status); return modules_get_color_status($status, $force_module);
} }
@ -1661,6 +1662,10 @@ class NetworkMap
case NODE_MODULE: case NODE_MODULE:
$item['id_module'] = $node['source_data']; $item['id_module'] = $node['source_data'];
$item['color'] = self::getColorByStatus(
$source_data['status'],
true
);
break; break;
case NODE_PANDORA: case NODE_PANDORA:
@ -1687,7 +1692,8 @@ class NetworkMap
$item['color'] = $source_data['color']; $item['color'] = $source_data['color'];
} else { } else {
$item['color'] = self::getColorByStatus( $item['color'] = self::getColorByStatus(
$node['status'] $node['status'],
(bool) $node['id_module']
); );
} }
break; break;

View File

@ -667,13 +667,22 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
if ($user_access_node && check_acl($config['id_user'], $agent['id_grupo'], 'AW')) { if ($user_access_node && check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {
$go_to_agent = '<div style="text-align: right;">'; $go_to_agent = '<div style="text-align: right;">';
if ($agent['id_os'] != 100) { if ($agent['id_os'] == CLUSTER_OS_ID) {
if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
$go_to_agent .= '<a target="_blank" href="'.$url.'">';
$go_to_agent .= html_print_submit_button(__('Edit cluster'), 'upd_button', false, 'class="sub config"', true);
}
} else {
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">'; $go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
$go_to_agent .= html_print_submit_button(__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true); $go_to_agent .= html_print_submit_button(__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
} else {
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$id_agente);
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1='.$id_agente.'">';
$go_to_agent .= html_print_submit_button(__('Edit cluster'), 'upd_button', false, 'class="sub config"', true);
} }
$go_to_agent .= '</a>'; $go_to_agent .= '</a>';

View File

@ -88,17 +88,6 @@ class Agent extends Entity
} }
/**
* Returns current object as array.
*
* @return array Of fields.
*/
public function toArray()
{
return $this->fields;
}
/** /**
* Overrides Entity method. * Overrides Entity method.
* *

View File

@ -131,6 +131,17 @@ abstract class Entity
} }
/**
* Returns current object as array.
*
* @return array Of fields.
*/
public function toArray()
{
return $this->fields;
}
/** /**
* Saves current object definition to database. * Saves current object definition to database.
* *

View File

@ -791,8 +791,18 @@ foreach ($agents as $agent) {
$data[0] .= '<div class="agentleft_'.$agent['id_agente'].'" style="visibility: hidden; clear: left;">'; $data[0] .= '<div class="agentleft_'.$agent['id_agente'].'" style="visibility: hidden; clear: left;">';
if ($agent['id_os'] == 100) { if ($agent['id_os'] == CLUSTER_OS_ID) {
$data[0] .= '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id='.$cluster['id'].'">'.__('View').'</a>'; if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=view&id='.$cluster->id()
);
echo '<a href="'.$url.'">'.__('View').'</a>';
}
} else { } else {
$data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'">'.__('View').'</a>'; $data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'">'.__('View').'</a>';
} }
@ -800,8 +810,18 @@ foreach ($agents as $agent) {
if (check_acl($config['id_user'], $agent['id_grupo'], 'AW')) { if (check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {
$data[0] .= ' | '; $data[0] .= ' | ';
if ($agent['id_os'] == 100) { if ($agent['id_os'] == CLUSTER_OS_ID) {
$data[0] .= '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.__('Edit').'</a>'; if (enterprise_installed()) {
$cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId(
$agent['id_agente']
);
$url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR;
$url .= '/operation/cluster/cluster';
$url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id()
);
echo '<a href="'.$url.'">'.__('Edit').'</a>';
}
} else { } else {
$data[0] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$agent['id_agente'].'">'.__('Edit').'</a>'; $data[0] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$agent['id_agente'].'">'.__('Edit').'</a>';
} }

View File

@ -148,8 +148,10 @@ $sort = get_parameter('sort', 'up');
$modules_not_init = agents_monitor_notinit($id_agente); $modules_not_init = agents_monitor_notinit($id_agente);
if (!empty($modules_not_init)) { if (empty($modules_not_init) === false) {
$help_not_init = clippy_context_help('modules_not_init'); $help_not_init = ui_print_warning_message(
__('No initialized modules found.')
);
} else { } else {
$help_not_init = ''; $help_not_init = '';
} }

View File

@ -463,7 +463,7 @@ $autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console';
$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map'; $autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map';
$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console'; $autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console';
$autorefresh_list_out['operation/events/events'] = 'Events'; $autorefresh_list_out['operation/events/events'] = 'Events';
$autorefresh_list_out['enterprise/godmode/reporting/cluster_view'] = 'Cluster view'; $autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view';
if (enterprise_installed()) { if (enterprise_installed()) {
$autorefresh_list_out['general/sap_view'] = 'SAP view'; $autorefresh_list_out['general/sap_view'] = 'SAP view';
} }