mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Agent improvements
This commit is contained in:
parent
7a554f54f4
commit
8c852fb3df
@ -858,7 +858,8 @@ if ($delete_conf_file) {
|
||||
ui_print_result_message(
|
||||
$correct,
|
||||
__('Conf file deleted successfully'),
|
||||
__('Could not delete conf file')
|
||||
__('Could not delete conf file'),
|
||||
[ 'autoclose' => true ]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -36,10 +36,10 @@ $ag_group = get_parameter('ag_group_refresh', -1);
|
||||
$sortField = get_parameter('sort_field');
|
||||
$sort = get_parameter('sort', 'none');
|
||||
$recursion = (bool) get_parameter('recursion', false);
|
||||
$disabled = get_parameter('disabled', 0);
|
||||
$os = get_parameter('os', 0);
|
||||
$disabled = (int) get_parameter('disabled');
|
||||
$os = (int) get_parameter('os');
|
||||
|
||||
if ($ag_group == -1) {
|
||||
if ($ag_group === -1) {
|
||||
$ag_group = (int) get_parameter('ag_group', -1);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ require_once 'include/functions_agents.php';
|
||||
require_once 'include/functions_users.php';
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
|
||||
$search = get_parameter('search', '');
|
||||
$search = get_parameter('search');
|
||||
|
||||
// Prepare the tab system to the future.
|
||||
$tab = 'view';
|
||||
@ -133,20 +133,19 @@ $agent_to_delete = (int) get_parameter('borrar_agente');
|
||||
$enable_agent = (int) get_parameter('enable_agent');
|
||||
$disable_agent = (int) get_parameter('disable_agent');
|
||||
|
||||
if ($disable_agent != 0) {
|
||||
if ($disable_agent !== 0) {
|
||||
$server_name = db_get_row_sql(
|
||||
'select server_name from tagente where id_agente = '.$disable_agent
|
||||
);
|
||||
} else if ($enable_agent != 0) {
|
||||
} else if ($enable_agent !== 0) {
|
||||
$server_name = db_get_row_sql(
|
||||
'select server_name from tagente where id_agente = '.$enable_agent
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$result = null;
|
||||
|
||||
if ($agent_to_delete) {
|
||||
if ($agent_to_delete > 0) {
|
||||
$id_agente = $agent_to_delete;
|
||||
if (check_acl_one_of_groups(
|
||||
$config['id_user'],
|
||||
@ -230,7 +229,7 @@ if ($enable_agent > 0) {
|
||||
);
|
||||
}
|
||||
|
||||
if ($disable_agent) {
|
||||
if ($disable_agent > 0) {
|
||||
$result = db_process_sql_update('tagente', ['disabled' => 1], ['id_agente' => $disable_agent]);
|
||||
$alias = io_safe_output(agents_get_alias($disable_agent));
|
||||
|
||||
@ -273,28 +272,45 @@ if ($disable_agent) {
|
||||
);
|
||||
}
|
||||
|
||||
echo "<table cellpadding='4' cellspacing='4' class='databox filters font_bold margin-bottom-10' width='100%'>
|
||||
<tr>";
|
||||
echo "<form method='post'
|
||||
action='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente'>";
|
||||
|
||||
echo '<td>';
|
||||
|
||||
echo __('Group').' ';
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if (!$own_info['is_admin'] && !check_acl(
|
||||
if ((bool) $own_info['is_admin'] === false && (bool) check_acl(
|
||||
$config['id_user'],
|
||||
0,
|
||||
'AR'
|
||||
) && !check_acl($config['id_user'], 0, 'AW')
|
||||
) === false && (bool) check_acl($config['id_user'], 0, 'AW') === false
|
||||
) {
|
||||
$return_all_group = false;
|
||||
} else {
|
||||
$return_all_group = true;
|
||||
}
|
||||
|
||||
echo '<div class="w250px inline">';
|
||||
html_print_select_groups(
|
||||
$showAgentFields = [
|
||||
2 => __('Everyone'),
|
||||
1 => __('Only disabled'),
|
||||
0 => __('Only enabled'),
|
||||
];
|
||||
|
||||
$pre_fields = db_get_all_rows_sql(
|
||||
'select distinct(tagente.id_os),tconfig_os.name from tagente,tconfig_os where tagente.id_os = tconfig_os.id_os'
|
||||
);
|
||||
|
||||
$fields = [];
|
||||
|
||||
foreach ($pre_fields as $key => $value) {
|
||||
$fields[$value['id_os']] = $value['name'];
|
||||
}
|
||||
|
||||
// Filter table.
|
||||
$filterTable = new stdClass();
|
||||
$filterTable->class = 'fixed_filter_bar';
|
||||
$filterTable->data = [];
|
||||
$filterTable->cellstyle[0][0] = 'width:0';
|
||||
$filterTable->cellstyle[0][1] = 'width:0';
|
||||
$filterTable->cellstyle[0][2] = 'width:0';
|
||||
$filterTable->cellstyle[0][3] = 'width:0';
|
||||
|
||||
$filterTable->data[0][0] = __('Group');
|
||||
$filterTable->data[1][0] = html_print_select_groups(
|
||||
false,
|
||||
'AR',
|
||||
$return_all_group,
|
||||
@ -303,79 +319,78 @@ html_print_select_groups(
|
||||
'this.form.submit();',
|
||||
'',
|
||||
0,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
);
|
||||
echo '</div></td>';
|
||||
|
||||
// Recursion checkbox.
|
||||
echo '<td>';
|
||||
echo __('Recursion').' ';
|
||||
html_print_checkbox(
|
||||
$filterTable->data[0][1] = __('Recursion');
|
||||
$filterTable->data[1][1] = html_print_checkbox_switch(
|
||||
'recursion',
|
||||
1,
|
||||
$recursion,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
'this.form.submit()'
|
||||
);
|
||||
echo '</td>';
|
||||
echo '<td>';
|
||||
echo __('Show Agents').' ';
|
||||
$fields = [
|
||||
2 => __('Everyone'),
|
||||
1 => __('Only disabled'),
|
||||
0 => __('Only enabled'),
|
||||
];
|
||||
html_print_select(
|
||||
$fields,
|
||||
|
||||
$filterTable->data[0][2] = __('Show agents');
|
||||
$filterTable->data[1][2] = html_print_select(
|
||||
$showAgentFields,
|
||||
'disabled',
|
||||
$disabled,
|
||||
'this.form.submit()'
|
||||
);
|
||||
|
||||
echo '</td>';
|
||||
|
||||
echo '<td>';
|
||||
echo __('Operative System').' ';
|
||||
|
||||
$pre_fields = db_get_all_rows_sql(
|
||||
'select distinct(tagente.id_os),tconfig_os.name from tagente,tconfig_os where tagente.id_os = tconfig_os.id_os'
|
||||
);
|
||||
$fields = [];
|
||||
|
||||
foreach ($pre_fields as $key => $value) {
|
||||
$fields[$value['id_os']] = $value['name'];
|
||||
}
|
||||
|
||||
html_print_select($fields, 'os', $os, 'this.form.submit()', 'All', 0);
|
||||
|
||||
echo '</td><td>';
|
||||
echo __('Free search').' ';
|
||||
html_print_input_text('search', $search, '', 12);
|
||||
|
||||
echo ui_print_help_tip(
|
||||
__('Search filter by alias, name, description, IP address or custom fields content'),
|
||||
'this.form.submit()',
|
||||
'',
|
||||
0,
|
||||
true
|
||||
);
|
||||
|
||||
echo '</td><td>';
|
||||
html_print_submit_button(
|
||||
__('Search'),
|
||||
$filterTable->data[0][3] = __('Operating System');
|
||||
$filterTable->data[1][3] = html_print_select(
|
||||
$fields,
|
||||
'os',
|
||||
$os,
|
||||
'this.form.submit()',
|
||||
'All',
|
||||
0,
|
||||
true
|
||||
);
|
||||
|
||||
$filterTable->data[0][4] = __('Free search');
|
||||
$filterTable->data[0][4] .= ui_print_help_tip(
|
||||
__('Search filter by alias, name, description, IP address or custom fields content'),
|
||||
true
|
||||
);
|
||||
$filterTable->data[1][4] = html_print_input_text(
|
||||
'search',
|
||||
$search,
|
||||
'',
|
||||
12,
|
||||
255,
|
||||
true
|
||||
);
|
||||
|
||||
$filterTable->cellstyle[1][5] = 'vertical-align: bottom';
|
||||
$filterTable->data[1][5] = html_print_submit_button(
|
||||
__('Filter'),
|
||||
'srcbutton',
|
||||
false,
|
||||
[
|
||||
'icon' => 'search',
|
||||
'mode' => 'mini',
|
||||
]
|
||||
'icon' => 'search',
|
||||
'class' => 'float-right',
|
||||
'mode' => 'secondary mini',
|
||||
],
|
||||
true
|
||||
);
|
||||
echo '</form>';
|
||||
echo '<td>';
|
||||
echo '</tr></table>';
|
||||
|
||||
// Print filter table.
|
||||
echo '<form method=\'post\' action=\'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente\'>';
|
||||
html_print_table($filterTable);
|
||||
echo '</form>';
|
||||
|
||||
// Data table.
|
||||
$selected = true;
|
||||
$selectNameUp = false;
|
||||
$selectNameDown = false;
|
||||
@ -555,7 +570,7 @@ if ($disabled == 1) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($os != 0) {
|
||||
if ($os !== 0) {
|
||||
$search_sql .= ' AND id_os = '.$os;
|
||||
}
|
||||
|
||||
@ -564,7 +579,7 @@ $user_groups_to_sql = '';
|
||||
if ($ag_group > 0) {
|
||||
$ag_groups = [];
|
||||
$ag_groups = (array) $ag_group;
|
||||
if ($recursion) {
|
||||
if ($recursion === true) {
|
||||
$ag_groups = groups_get_children_ids($ag_group, true);
|
||||
}
|
||||
|
||||
@ -613,22 +628,14 @@ $sql = sprintf(
|
||||
|
||||
$agents = db_get_all_rows_sql($sql);
|
||||
|
||||
// Delete rnum row generated by oracle_recode_query() function.
|
||||
if (($config['dbtype'] == 'oracle') && ($agents !== false)) {
|
||||
for ($i = 0; $i < count($agents); $i++) {
|
||||
unset($agents[$i]['rnum']);
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare pagination.
|
||||
ui_pagination($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled&os=$os", $offset);
|
||||
|
||||
// ui_pagination($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled&os=$os", $offset);
|
||||
if ($agents !== false) {
|
||||
// Urls to sort the table.
|
||||
if ($config['language'] == 'ja'
|
||||
|| $config['language'] == 'zh_CN'
|
||||
|| $own_info['language'] == 'ja'
|
||||
|| $own_info['language'] == 'zh_CN'
|
||||
if ($config['language'] === 'ja'
|
||||
|| $config['language'] === 'zh_CN'
|
||||
|| $own_info['language'] === 'ja'
|
||||
|| $own_info['language'] === 'zh_CN'
|
||||
) {
|
||||
// Adds a custom font size for Japanese and Chinese language.
|
||||
$custom_font_size = 'custom_font_size';
|
||||
@ -643,38 +650,34 @@ if ($agents !== false) {
|
||||
$url_up_group = 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search.'&os='.$os.'&offset='.$offset.'&sort_field=group&sort=up&disabled=$disabled';
|
||||
$url_down_group = 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search.'&os='.$os.'&offset='.$offset.'&sort_field=group&sort=down&disabled=$disabled';
|
||||
|
||||
$tableAgents = new stdClass();
|
||||
$tableAgents->id = 'agent_list';
|
||||
$tableAgents->class = 'info_table tactical_table';
|
||||
$tableAgents->styleTable = 'margin: 0 10px';
|
||||
$tableAgents->head = [];
|
||||
$tableAgents->data = [];
|
||||
// Header.
|
||||
$tableAgents->head[0] = '<span>'.__('Agent name').'</span>';
|
||||
$tableAgents->head[0] .= ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectNameUp, $selectNameDown);
|
||||
$tableAgents->head[1] = '<span title=\''.__('Remote agent configuration').'\'>'.__('R').'</span>';
|
||||
$tableAgents->head[1] .= ui_get_sorting_arrows($url_up_remote, $url_down_remote, $selectRemoteUp, $selectRemoteDown);
|
||||
$tableAgents->head[2] = '<span>'.__('OS').'</span>';
|
||||
$tableAgents->head[2] .= ui_get_sorting_arrows($url_up_os, $url_down_os, $selectOsUp, $selectOsDown);
|
||||
$tableAgents->head[3] = '<span>'.__('Type').'</span>';
|
||||
$tableAgents->head[4] = '<span>'.__('Group').'</span>';
|
||||
$tableAgents->head[4] .= ui_get_sorting_arrows($url_up_group, $url_down_group, $selectGroupUp, $selectGroupDown);
|
||||
$tableAgents->head[5] = '<span>'.__('Description').'</span>';
|
||||
$tableAgents->head[6] = '<span>'.__('Actions').'</span>';
|
||||
// Body.
|
||||
foreach ($agents as $key => $agent) {
|
||||
// Begin Update tagente.remote with 0/1 values.
|
||||
$resultHasRemoteConfig = ((int) enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']]) > 0);
|
||||
db_process_sql_update(
|
||||
'tagente',
|
||||
['remote' => ((int) $resultHasRemoteConfig) ],
|
||||
'id_agente = '.$agent['id_agente'].''
|
||||
);
|
||||
|
||||
echo "<table cellpadding='0' id='agent_list' cellspacing='0' width='100%' class='info_table'>";
|
||||
echo '<thead><tr>';
|
||||
echo '<th>'.__('Agent name').ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectNameUp, $selectNameDown).'</th>';
|
||||
echo "<th title='".__('Remote agent configuration')."'>".__('R').ui_get_sorting_arrows($url_up_remote, $url_down_remote, $selectRemoteUp, $selectRemoteDown).'</th>';
|
||||
echo '<th>'.__('OS').ui_get_sorting_arrows($url_up_os, $url_down_os, $selectOsUp, $selectOsDown).'</th>';
|
||||
echo '<th>'.__('Type').'</th>';
|
||||
echo '<th>'.__('Group').ui_get_sorting_arrows($url_up_group, $url_down_group, $selectGroupUp, $selectGroupDown).'</th>';
|
||||
echo '<th>'.__('Description').'</th>';
|
||||
echo "<th class='context_help_body'>".__('Actions').'</th>';
|
||||
echo '</tr></thead>';
|
||||
$color = 1;
|
||||
|
||||
$rowPair = true;
|
||||
$iterator = 0;
|
||||
foreach ($agents as $agent) {
|
||||
// Begin Update tagente.remote 0/1 with remote agent function return.
|
||||
if (enterprise_hook(
|
||||
'config_agents_has_remote_configuration',
|
||||
[$agent['id_agente']]
|
||||
)
|
||||
) {
|
||||
db_process_sql_update(
|
||||
'tagente',
|
||||
['remote' => 1],
|
||||
'id_agente = '.$agent['id_agente'].''
|
||||
);
|
||||
} else {
|
||||
db_process_sql_update('tagente', ['remote' => 0], 'id_agente = '.$agent['id_agente'].'');
|
||||
}
|
||||
|
||||
// End Update tagente.remote 0/1 with remote agent function return.
|
||||
$all_groups = agents_get_all_groups_agent(
|
||||
$agent['id_agente'],
|
||||
$agent['id_grupo']
|
||||
@ -690,87 +693,66 @@ if ($agents !== false) {
|
||||
'AD'
|
||||
);
|
||||
|
||||
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']);
|
||||
$cluster = db_get_row_sql(
|
||||
'select id from tcluster where id_agent = '.$agent['id_agente']
|
||||
);
|
||||
|
||||
// Do not show the agent if there is not enough permissions.
|
||||
if (!$check_aw && !$check_ad) {
|
||||
if ($check_aw === false && $check_ad === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($color == 1) {
|
||||
$tdcolor = 'datos';
|
||||
$color = 0;
|
||||
if ((int) $agent['id_os'] === CLUSTER_OS_ID) {
|
||||
$cluster = PandoraFMS\Cluster::loadFromAgentId($agent['id_agente']);
|
||||
$agentNameUrl = sprintf(
|
||||
'index.php?sec=reporting&sec2=operation/cluster/cluster&op=update&id=%s',
|
||||
$cluster->id()
|
||||
);
|
||||
$agentViewUrl = sprintf(
|
||||
'index.php?sec=reporting&sec2=operation/cluster/cluster&op=view&id=%s',
|
||||
$cluster->id()
|
||||
);
|
||||
} else {
|
||||
$tdcolor = 'datos2';
|
||||
$color = 1;
|
||||
$main_tab = ($check_aw === true) ? 'main' : 'module';
|
||||
$agentNameUrl = sprintf(
|
||||
'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=%s&id_agente=%s',
|
||||
$main_tab,
|
||||
$agent['id_agente']
|
||||
);
|
||||
$agentViewUrl = sprintf(
|
||||
'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=%s',
|
||||
$agent['id_agente']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($rowPair) {
|
||||
$rowclass = 'rowPair';
|
||||
} else {
|
||||
$rowclass = 'rowOdd';
|
||||
}
|
||||
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
// Agent name.
|
||||
echo "<tr class='$rowclass'><td class='$tdcolor' width='40%'>";
|
||||
if ($agent['disabled']) {
|
||||
echo '<em>';
|
||||
}
|
||||
|
||||
echo '<span class="left">';
|
||||
echo '<strong>';
|
||||
|
||||
if ($check_aw) {
|
||||
$main_tab = 'main';
|
||||
} else {
|
||||
$main_tab = 'module';
|
||||
}
|
||||
|
||||
if ($agent['alias'] == '') {
|
||||
if (empty($agent['alias']) === true) {
|
||||
$agent['alias'] = $agent['nombre'];
|
||||
}
|
||||
|
||||
if ($agent['id_os'] == CLUSTER_OS_ID) {
|
||||
$cluster = PandoraFMS\Cluster::loadFromAgentId(
|
||||
$agent['id_agente']
|
||||
);
|
||||
$url = 'index.php?sec=reporting&sec2=';
|
||||
$url .= 'operation/cluster/cluster';
|
||||
$url = ui_get_full_url(
|
||||
$url.'&op=update&id='.$cluster->id()
|
||||
);
|
||||
echo '<a href="'.$url.'">'.ui_print_truncate_text($agent['alias'], 'agent_medium').'</a>';
|
||||
} else {
|
||||
echo '<a alt ='.$agent['nombre']." href='index.php?sec=gagente&
|
||||
sec2=godmode/agentes/configurar_agente&tab=$main_tab&
|
||||
id_agente=".$agent['id_agente']."'>".'<span class="'.$custom_font_size.' title ="'.$agent['nombre'].'">'.ui_print_truncate_text($agent['alias'], 'agent_medium').'</span>'.'</a>';
|
||||
}
|
||||
$additionalDataAgentName = [];
|
||||
|
||||
echo '</strong>';
|
||||
|
||||
$in_planned_downtime = db_get_sql(
|
||||
$inPlannedDowntime = db_get_sql(
|
||||
'SELECT executed FROM tplanned_downtime
|
||||
INNER JOIN tplanned_downtime_agents ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime
|
||||
WHERE tplanned_downtime_agents.id_agent = '.$agent['id_agente'].' AND tplanned_downtime.executed = 1
|
||||
AND tplanned_downtime.type_downtime <> "disable_agent_modules"'
|
||||
);
|
||||
|
||||
if ($agent['disabled']) {
|
||||
ui_print_help_tip(__('Disabled'));
|
||||
|
||||
if (!$in_planned_downtime) {
|
||||
echo '</em>';
|
||||
}
|
||||
if ($inPlannedDowntime !== false) {
|
||||
$additionalDataAgentName[] = ui_print_help_tip(
|
||||
__('Module in scheduled downtime'),
|
||||
true,
|
||||
'images/clock.svg'
|
||||
);
|
||||
}
|
||||
|
||||
if ($agent['quiet']) {
|
||||
echo ' ';
|
||||
html_print_image(
|
||||
if ((bool) $agent['disabled'] === true) {
|
||||
$additionalDataAgentName[] = ui_print_help_tip(__('Disabled'));
|
||||
}
|
||||
|
||||
if ((bool) $agent['quiet'] === true) {
|
||||
$additionalDataAgentName[] = html_print_image(
|
||||
'images/dot_blue.png',
|
||||
false,
|
||||
true,
|
||||
[
|
||||
'border' => '0',
|
||||
'title' => __('Quiet'),
|
||||
@ -779,171 +761,208 @@ if ($agents !== false) {
|
||||
);
|
||||
}
|
||||
|
||||
if ($in_planned_downtime) {
|
||||
ui_print_help_tip(
|
||||
__('Agent in scheduled downtime'),
|
||||
false,
|
||||
'images/minireloj-16.png'
|
||||
);
|
||||
// Agent name column (1). Agent name.
|
||||
$agentNameColumn = html_print_anchor(
|
||||
[
|
||||
'href' => ui_get_full_url($agentNameUrl),
|
||||
'title' => $agent['nombre'],
|
||||
'content' => ui_print_truncate_text($agent['alias'], 'agent_medium').implode('', $additionalDataAgentName),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
echo '</em>';
|
||||
$additionalOptionsAgentName = [];
|
||||
// Additional options generation.
|
||||
if ($check_aw === true) {
|
||||
$additionalOptionsAgentName[] = html_print_anchor(
|
||||
[
|
||||
'href' => ui_get_full_url($agentNameUrl),
|
||||
'content' => __('Edit'),
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
echo '</span><div class="left actions clear_left" style=" visibility: hidden">';
|
||||
if ($check_aw) {
|
||||
if ($agent['id_os'] == CLUSTER_OS_ID) {
|
||||
$cluster = PandoraFMS\Cluster::loadFromAgentId(
|
||||
$agent['id_agente']
|
||||
);
|
||||
$url = 'index.php?sec=reporting&sec2=';
|
||||
$url .= 'operation/cluster/cluster';
|
||||
$url = ui_get_full_url(
|
||||
$url.'&op=update&id='.$cluster->id()
|
||||
);
|
||||
echo '<a href="'.$url.'">'.__('Edit').'</a>';
|
||||
echo ' | ';
|
||||
} else {
|
||||
echo '<a href="index.php?sec=gagente&
|
||||
sec2=godmode/agentes/configurar_agente&tab=main&
|
||||
id_agente='.$agent['id_agente'].'">'.__('Edit').'</a>';
|
||||
echo ' | ';
|
||||
}
|
||||
if ((int) $agent['id_os'] !== 100) {
|
||||
$additionalOptionsAgentName[] = html_print_anchor(
|
||||
[
|
||||
'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$agent['id_agente']),
|
||||
'content' => __('Modules'),
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if ($agent['id_os'] != 100) {
|
||||
echo '<a href="index.php?sec=gagente&
|
||||
sec2=godmode/agentes/configurar_agente&tab=module&
|
||||
id_agente='.$agent['id_agente'].'">'.__('Modules').'</a>';
|
||||
echo ' | ';
|
||||
}
|
||||
$additionalOptionsAgentName[] = html_print_anchor(
|
||||
[
|
||||
'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$agent['id_agente']),
|
||||
'content' => __('Alerts'),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
echo '<a href="index.php?sec=gagente&
|
||||
sec2=godmode/agentes/configurar_agente&tab=alert&
|
||||
id_agente='.$agent['id_agente'].'">'.__('Alerts').'</a>';
|
||||
echo ' | ';
|
||||
$additionalOptionsAgentName[] = html_print_anchor(
|
||||
[
|
||||
'href' => ui_get_full_url($agentViewUrl),
|
||||
'content' => __('View'),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if ($agent['id_os'] == CLUSTER_OS_ID) {
|
||||
$cluster = PandoraFMS\Cluster::loadFromAgentId(
|
||||
$agent['id_agente']
|
||||
// Agent name column (2). Available options.
|
||||
$agentAvailableActionsColumn = html_print_div(
|
||||
[
|
||||
'class' => 'left actions clear_left w100p',
|
||||
'style' => 'visibility: hidden',
|
||||
'content' => implode(' | ', $additionalOptionsAgentName),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Remote Configuration column.
|
||||
if ($resultHasRemoteConfig === true) {
|
||||
$remoteConfigurationColumn = html_print_menu_button(
|
||||
[
|
||||
'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1'),
|
||||
'image' => 'images/remote-configuration@svg.svg',
|
||||
'title' => __('Edit remote config'),
|
||||
],
|
||||
true
|
||||
);
|
||||
$url = 'index.php?sec=reporting&sec2=';
|
||||
$url .= 'operation/cluster/cluster';
|
||||
$url = ui_get_full_url(
|
||||
$url.'&op=view&id='.$cluster->id()
|
||||
);
|
||||
echo '<a href="'.$url.'">'.__('View').'</a>';
|
||||
} else {
|
||||
echo '<a href="index.php?sec=estado
|
||||
&sec2=operation/agentes/ver_agente
|
||||
&id_agente='.$agent['id_agente'].'">'.__('View').'</a>';
|
||||
$remoteConfigurationColumn = '';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo '</td>';
|
||||
|
||||
echo '<td class="'.$tdcolor.'" align="left" valign="middle">';
|
||||
// Has remote configuration.
|
||||
if (enterprise_installed() === true) {
|
||||
if ((bool) enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']]) === true) {
|
||||
html_print_menu_button(
|
||||
[
|
||||
'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1',
|
||||
'image' => 'images/remote-configuration@svg.svg',
|
||||
'title' => __('Edit remote config'),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
|
||||
// Operating System icon.
|
||||
echo '<td class="'.$tdcolor.'" align="left" valign="middle">';
|
||||
html_print_div(
|
||||
// Operating System icon column.
|
||||
$osIconColumn = html_print_div(
|
||||
[
|
||||
'class' => 'main_menu_icon',
|
||||
'content' => ui_print_os_icon($agent['id_os'], false, true),
|
||||
]
|
||||
],
|
||||
true
|
||||
);
|
||||
echo '</td>';
|
||||
|
||||
// Type agent (Networt, Software or Satellite).
|
||||
echo '<td class="'.$tdcolor.'" align="left" valign="middle">';
|
||||
echo ui_print_type_agent_icon(
|
||||
// Agent type column.
|
||||
$agentTypeIconColumn = ui_print_type_agent_icon(
|
||||
$agent['id_os'],
|
||||
$agent['ultimo_contacto_remoto'],
|
||||
$agent['ultimo_contacto'],
|
||||
true,
|
||||
$agent['remote'],
|
||||
$agent['agent_version']
|
||||
);
|
||||
echo '</td>';
|
||||
|
||||
|
||||
// Group icon and name.
|
||||
echo '<td class="'.$tdcolor.'" align="left" valign="middle">';
|
||||
html_print_div(
|
||||
// Group icon and name column.
|
||||
$agentGroupIconColumn = html_print_div(
|
||||
[
|
||||
'class' => 'main_menu_icon',
|
||||
'content' => ui_print_group_icon($agent['id_grupo'], true),
|
||||
]
|
||||
],
|
||||
true
|
||||
);
|
||||
echo '</td>';
|
||||
|
||||
// Description.
|
||||
echo "<td class='".$tdcolor."f9'><span class='".$custom_font_size."'>".ui_print_truncate_text($agent['comentarios'], 'description', true, true, true, '[…]').'</span></td>';
|
||||
// Description column.
|
||||
$descriptionColumn = ui_print_truncate_text(
|
||||
$agent['comentarios'],
|
||||
'description',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'[…]'
|
||||
);
|
||||
|
||||
// Action
|
||||
// When there is only one element in page it's necesary go back page.
|
||||
if ((count($agents) == 1) && ($offset >= $config['block_size'])) {
|
||||
$offsetArg = ($offset - $config['block_size']);
|
||||
$agentActionButtons = [];
|
||||
|
||||
if ((bool) $agent['disabled'] === true) {
|
||||
$agentDisableEnableTitle = __('Enable agent');
|
||||
$agentDisableEnableAction = 'enable_agent';
|
||||
$agentDisableEnableCaption = __('You are going to enable a cluster agent. Are you sure?');
|
||||
$agentDisableEnableIcon = 'change-pause.svg';
|
||||
} else {
|
||||
$offsetArg = $offset;
|
||||
$agentDisableEnableTitle = __('Disable agent');
|
||||
$agentDisableEnableAction = 'disable_agent';
|
||||
$agentDisableEnableCaption = __('You are going to disable a cluster agent. Are you sure?');
|
||||
$agentDisableEnableIcon = 'change-active.svg';
|
||||
}
|
||||
|
||||
echo "<td class='$tdcolor table_action_buttons' align='left' width=7% valign='middle'>";
|
||||
$agentActionButtons[] = html_print_menu_button(
|
||||
[
|
||||
'href' => ui_get_full_url(
|
||||
sprintf(
|
||||
'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&%s_agent=%s&group_id=%s&recursion=%s&search=%s&offset=%s&sort_field=%s&sort=%s&disabled=%s',
|
||||
$agentDisableEnableAction,
|
||||
$agent['id_agente'],
|
||||
$ag_group,
|
||||
$recursion,
|
||||
$search,
|
||||
$offsetArg,
|
||||
$sortField,
|
||||
$sort,
|
||||
$disabled
|
||||
)
|
||||
),
|
||||
'onClick' => ($agent['id_os'] === CLUSTER_OS_ID) ? sprintf('if (!confirm(\'%s\')) return false', $agentDisableEnableCaption) : 'return true;',
|
||||
'image' => sprintf('images/%s', $agentDisableEnableIcon),
|
||||
'title' => $agentDisableEnableTitle,
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if ($agent['disabled']) {
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
|
||||
enable_agent=".$agent['id_agente']."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";
|
||||
|
||||
if ($agent['id_os'] != 100) {
|
||||
echo '>';
|
||||
if ($check_aw === true && is_management_allowed() === true) {
|
||||
if ($agent['id_os'] !== CLUSTER_OS_ID) {
|
||||
$onClickActionDeleteAgent = 'if (!confirm(\' '.__('Are you sure?').'\')) return false;';
|
||||
} else {
|
||||
echo ' onClick="if (!confirm(\' '.__('You are going to enable a cluster agent. Are you sure?').'\')) return false;">';
|
||||
$onClickActionDeleteAgent = 'if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;';
|
||||
}
|
||||
|
||||
echo html_print_image('images/lightbulb_off.png', true, ['alt' => __('Enable agent'), 'title' => __('Enable agent'), 'class' => 'filter_none']).'</a>';
|
||||
} else {
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
|
||||
disable_agent=".$agent['id_agente']."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";
|
||||
if ($agent['id_os'] != 100) {
|
||||
echo '>';
|
||||
} else {
|
||||
echo ' onClick="if (!confirm(\' '.__('You are going to disable a cluster agent. Are you sure?').'\')) return false;">';
|
||||
}
|
||||
|
||||
echo html_print_image('images/lightbulb.png', true, ['alt' => __('Disable agent'), 'title' => __('Disable agent'), 'class' => 'invert_filter']).'</a>';
|
||||
$agentActionButtons[] = html_print_menu_button(
|
||||
[
|
||||
'href' => ui_get_full_url(
|
||||
sprintf(
|
||||
'index.php?sec=gagente&sec2=godmode/agentes/borrar_agente&%s_agent=%s&group_id=%s&recursion=%s&search=%s&offset=%s&sort_field=%s&sort=%s&disabled=%s',
|
||||
$agentDisableEnableAction,
|
||||
$agent['id_agente'],
|
||||
$ag_group,
|
||||
$recursion,
|
||||
$search,
|
||||
$offsetArg,
|
||||
$sortField,
|
||||
$sort,
|
||||
$disabled
|
||||
)
|
||||
),
|
||||
'onClick' => $onClickActionDeleteAgent,
|
||||
'image' => sprintf('images/delete.svg'),
|
||||
'title' => __('Delete agent'),
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if ($check_aw && is_management_allowed() === true) {
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
|
||||
borrar_agente=".$agent['id_agente']."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";
|
||||
|
||||
if ($agent['id_os'] != 100) {
|
||||
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
} else {
|
||||
echo ' onClick="if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;">';
|
||||
}
|
||||
|
||||
echo html_print_image('images/cross.png', true, ['border' => '0', 'class' => 'invert_filter']).'</a>';
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
// Action buttons column.
|
||||
$actionButtonsColumn = implode('', $agentActionButtons);
|
||||
// Defined class for action buttons.
|
||||
$tableAgents->cellclass[$key][6] = 'table_action_buttons';
|
||||
// Row data.
|
||||
$tableAgents->data[$key][0] = $agentNameColumn;
|
||||
$tableAgents->data[$key][0] .= $agentAvailableActionsColumn;
|
||||
$tableAgents->data[$key][1] = $remoteConfigurationColumn;
|
||||
$tableAgents->data[$key][2] = $osIconColumn;
|
||||
$tableAgents->data[$key][3] = $agentTypeIconColumn;
|
||||
$tableAgents->data[$key][4] = $agentGroupIconColumn;
|
||||
$tableAgents->data[$key][5] = $descriptionColumn;
|
||||
$tableAgents->data[$key][6] = $actionButtonsColumn;
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
ui_pagination($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled&os=$os", $offset);
|
||||
echo "<table width='100%'><tr><td align='right'>";
|
||||
html_print_table($tableAgents);
|
||||
|
||||
/*
|
||||
ui_pagination(
|
||||
$total_agents,
|
||||
"index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled&os=$os",
|
||||
$offset
|
||||
);
|
||||
*/
|
||||
} else {
|
||||
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined agents') ]);
|
||||
}
|
||||
@ -968,7 +987,6 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
echo '</td></tr></table>';
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -1064,9 +1064,12 @@ foreach ($modules as $module) {
|
||||
// This module is initialized ? (has real data).
|
||||
if ($status === STATUS_MODULE_NO_DATA) {
|
||||
$data[2] .= html_print_image(
|
||||
'images/error.png',
|
||||
'images/alert-yellow@svg.svg',
|
||||
true,
|
||||
['title' => __('Non initialized module')]
|
||||
[
|
||||
'title' => __('Non initialized module'),
|
||||
'class' => 'main_menu_icon',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2716,13 +2716,20 @@ td.cellBig {
|
||||
|
||||
.info_box .title * {
|
||||
font-size: 14pt;
|
||||
font-family: Pandora-Bold;
|
||||
font-family: "Pandora-Bold";
|
||||
}
|
||||
|
||||
.info_box .icon {
|
||||
width: 24px;
|
||||
}
|
||||
|
||||
.info_box_container {
|
||||
width: 30%;
|
||||
position: fixed;
|
||||
top: 120px;
|
||||
right: 10px;
|
||||
z-index: 100;
|
||||
}
|
||||
/* Standard styles for status colos (groups, events, backgrounds...) */
|
||||
.opacity_cell {
|
||||
filter: alpha(opacity=80);
|
||||
|
@ -183,7 +183,7 @@
|
||||
padding: 0.1em;
|
||||
font-weight: normal;
|
||||
color: #000;
|
||||
margin-left: 0.5em;
|
||||
/*margin-left: 0.5em;*/
|
||||
}
|
||||
|
||||
.info_table > tbody > tr {
|
||||
|
@ -223,36 +223,15 @@ if ($pure) {
|
||||
$url .= '&pure='.$pure;
|
||||
}
|
||||
|
||||
if ($free_search != '') {
|
||||
if (empty($free_search) === false) {
|
||||
$url .= '&free_search='.$free_search;
|
||||
}
|
||||
|
||||
$columns = ['standby'];
|
||||
$column_names = [
|
||||
[
|
||||
'title' => 'Standby',
|
||||
'text' => 'S.',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
if (enterprise_installed() === true) {
|
||||
array_unshift(
|
||||
$column_names,
|
||||
[
|
||||
'title' => 'Policy',
|
||||
'text' => 'P.',
|
||||
]
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
['policy'],
|
||||
$columns
|
||||
);
|
||||
}
|
||||
$columns = [];
|
||||
$column_names = [];
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
if ((bool) check_acl($config['id_user'], $id_group, 'LW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) {
|
||||
array_unshift(
|
||||
$column_names,
|
||||
[
|
||||
@ -262,6 +241,11 @@ if (is_metaconsole() === false) {
|
||||
],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
['standby'],
|
||||
$columns
|
||||
);
|
||||
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
array_unshift(
|
||||
$column_names,
|
||||
@ -291,7 +275,7 @@ if (is_metaconsole() === false) {
|
||||
}
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
if ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) {
|
||||
array_push(
|
||||
$column_names,
|
||||
[
|
||||
@ -339,24 +323,6 @@ if ($print_agent === true) {
|
||||
);
|
||||
}
|
||||
|
||||
array_push(
|
||||
$column_names,
|
||||
['text' => 'Module'],
|
||||
['text' => 'Template'],
|
||||
['text' => 'Action'],
|
||||
['text' => 'Last fired'],
|
||||
['text' => 'Status']
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['agent_module_name'],
|
||||
['template_name'],
|
||||
['action'],
|
||||
['last_fired'],
|
||||
['status']
|
||||
);
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
if ((bool) check_acl($config['id_user'], $id_group, 'LW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) {
|
||||
array_unshift(
|
||||
|
Loading…
x
Reference in New Issue
Block a user