id = $system->getRequest('id', 0);
global $config;
echo "';
if (!$system->getConfig('metaconsole')) {
$this->agent = agents_get_agents(
[
'disabled' => 0,
'id_agente' => $this->id,
],
['*']
);
} else {
$this->agent = agents_get_meta_agents(
[
'disabled' => 0,
'id_agente' => $this->id,
],
['*']
);
}
if (!empty($this->agent)) {
$this->agent = $this->agent[0];
if ($system->checkACL('AR', $this->agent['id_grupo'])) {
$this->correct_acl = true;
} else {
$this->correct_acl = false;
}
} else {
$this->agent = null;
$this->correct_acl = true;
}
}
public function show()
{
if (!$this->correct_acl) {
$this->show_fail_acl();
} else {
$this->show_agent();
}
}
private function show_fail_acl()
{
$error['type'] = 'onStart';
$error['title_text'] = __('You don\'t have access to this page');
$error['content_text'] = System::getDefaultACLFailText();
if (class_exists('HomeEnterprise')) {
$home = new HomeEnterprise();
} else {
$home = new Home();
}
$home->show($error);
}
private function show_agent()
{
$ui = Ui::getInstance();
$system = System::getInstance();
$ui->createPage();
if ($this->id != 0) {
$agent_alias = (string) $this->agent['alias'];
$agents_filter = (string) $system->getRequest('agents_filter');
$agents_filter_q_param = empty($agents_filter) ? '' : '&agents_filter='.$agents_filter;
$ui->createDefaultHeader(
sprintf('%s', $agent_alias),
$ui->createHeaderButton(
[
'icon' => 'back',
'pos' => 'left',
'text' => __('Back'),
'href' => 'index.php?page=agents'.$agents_filter_q_param,
]
)
);
} else {
$ui->createDefaultHeader(__('Agents'));
}
$ui->showFooter(false);
$ui->beginContent();
if (empty($this->agent)) {
$ui->contentAddHtml(
''.__('No agent found').''
);
} else {
$ui->contentBeginGrid();
if ($this->agent['disabled']) {
$agent_alias = ''.$agent_alias.''.ui_print_help_tip(__('Disabled'), true);
} else if ($this->agent['quiet']) {
$agent_alias = ''.$agent_alias.' '.html_print_image(
'images/dot_blue.png',
true,
[
'border' => '0',
'title' => __('Quiet'),
'alt' => '',
]
).'';
}
if ($system->getConfig('metaconsole')) {
metaconsole_connect(null, $this->agent['id_tmetaconsole_setup']);
// ~ $addresses = agents_get_addresses($this->agent['id_tagente']);
} else {
$addresses = agents_get_addresses($this->id);
}
if ($system->getConfig('metaconsole')) {
metaconsole_restore_db();
}
$address = $this->agent['direccion'];
$ip .= (empty($address) === true) ? ''.__('N/A').'' : $address;
$last_contact = ''.__('Last contact').': ';
$last_contact .= ui_print_timestamp(
$this->agent['ultimo_contacto'],
true
);
if (empty($agent['comentarios']) === true) {
$description .= ''.__('N/A').'';
} else {
$description .= $this->agent['comentarios'];
}
$html = '
';
$html .= ''.$agent_alias.'';
$html .= '
';
$html .= ''.ui_print_os_icon(
$this->agent['id_os'],
false,
true,
true,
false,
false,
false,
false,
true
).'
';
$html .= '';
$html .= $ip.' - '.groups_get_name($this->agent['id_grupo'], true);
$html .= '
';
$html .= $last_contact;
$html .= '
';
$html .= $description;
$html .= '
';
$ui->contentGridAddCell($html, 'agent_details');
ob_start();
// Fixed width non interactive charts.
$status_chart_width = 160;
$graph_width = 160;
$html = '';
$html .= '
'.__('Modules by status').'';
$html .= '
';
$html .= graph_agent_status(
$this->id,
$graph_width,
160,
true,
false,
false,
true
);
$html .= '
';
$graph_js = ob_get_clean();
$html = $graph_js.$html;
unset($this->agent['fired_count']);
if ($system->getConfig('metaconsole')) {
metaconsole_connect(
null,
$this->agent['id_tmetaconsole_setup']
);
}
if ($this->agent['total_count'] > 0) {
$html .= '
'.reporting_tiny_stats($this->agent, true, 'agent', ' ').'
';
}
$html .= '
';
$html .= '';
$html .= '
'.__('Events (24h)').'';
$html .= '
';
$html .= graph_graphic_agentevents(
$this->id,
95,
45,
SECONDS_1DAY,
'',
true,
false,
true,
1,
''
);
$html .= '
';
$html .= '
';
$ui->contentGridAddCell($html, 'agent_graphs');
$ui->contentEndGrid();
if ($system->getConfig('metaconsole')) {
metaconsole_restore_db();
}
$modules = new Modules();
if ($system->getConfig('metaconsole')) {
$filters = [
'id_agent' => $this->agent['id_tagente'],
'all_modules' => true,
'status' => -1,
];
} else {
$filters = [
'id_agent' => $this->id,
'all_modules' => true,
'status' => -1,
];
}
$modules->setFilters($filters);
$modules->disabledColumns(['agent']);
$ui->contentBeginCollapsible(__('Modules'));
$ui->contentCollapsibleAddItem($modules->listModulesHtml(0, true));
$ui->contentEndCollapsible();
if ($system->getConfig('metaconsole')) {
metaconsole_connect(
null,
$this->agent['id_tmetaconsole_setup']
);
}
$alerts = new Alerts();
if ($system->getConfig('metaconsole')) {
$filters = [
'id_agent' => $this->agent['id_tagente'],
'all_alerts' => true,
];
} else {
$filters = [
'id_agent' => $this->id,
'all_alerts' => true,
];
}
$alerts->setFilters($filters);
$alerts->disabledColumns(['agent']);
$ui->contentBeginCollapsible(__('Alerts'));
$ui->contentCollapsibleAddItem($alerts->listAlertsHtml(true));
$ui->contentEndCollapsible();
if ($system->getConfig('metaconsole')) {
metaconsole_restore_db();
}
$events = new Events();
$events->addJavascriptDialog();
$options = $events->get_event_dialog_options();
$ui->addDialog($options);
$options = $events->get_event_dialog_error_options($options);
$ui->addDialog($options);
$ui->contentAddHtml("detail_event_hook");
$ui->contentAddHtml("detail_event_dialog_error_hook");
$ui->contentBeginCollapsible(sprintf(__('Last %s Events'), $system->getPageSize()));
$tabledata = $events->listEventsHtml(0, true, 'last_agent_events');
$ui->contentCollapsibleAddItem($tabledata['table']);
$ui->contentCollapsibleAddItem($events->putEventsTableJS($this->id));
$ui->contentEndCollapsible();
}
$ui->contentAddLinkListener('last_agent_events');
$ui->contentAddLinkListener('list_events');
$ui->contentAddLinkListener('list_agent_Modules');
$ui->contentAddHtml(
""
);
$ui->endContent();
$ui->showPage();
}
}