';
echo html_print_label_input_block(
__('Refresh'),
html_print_select(
[
'30' => __('30 seconds'),
(string) SECONDS_1MINUTE => __('1 minute'),
'180' => __('3 minutes'),
(string) SECONDS_5MINUTES => __('5 minutes'),
],
'refresh',
$refresh,
'',
'',
0,
true,
false,
false,
'',
false,
'width: 100%; margin-top: 10px;'
),
[
'label_class' => 'font-title-font',
'div_class' => 'mrgn_top_10px',
]
);
echo html_print_label_input_block(
__('Search'),
html_print_input_text(
'search',
$search,
'',
30,
255,
true,
false,
false,
'',
'w100p'
),
[
'label_class' => 'font-title-font',
'div_class' => 'mrgn_top_10px',
]
);
echo html_print_label_input_block(
__('Type'),
html_print_select(
[
0 => __('Group agents'),
1 => __('Group modules by tag'),
2 => __('Group modules by module group'),
3 => __('Group modules by agents'),
],
'type',
$type,
'',
'',
0,
true,
false,
false,
'',
false,
'width: 100%; margin-top: 10px;'
),
[
'label_class' => 'font-title-font',
'div_class' => 'mrgn_top_10px',
]
);
echo html_print_label_input_block(
__('Show groups'),
'
';
switch ($type) {
case 3:
case 2:
$sql = sprintf(
'SELECT * FROM tagente_modulo ag
INNER JOIN tagente_estado ae ON ag.id_agente_modulo = ae.id_agente_modulo
WHERE ag.id_agente_modulo = %d',
$id
);
$data = db_get_row_sql($sql);
// Nombre.
$link = sprintf(
'index.php?sec=view&sec2=operation/agentes/status_monitor%s&ag_modulename=%s',
'&refr=0&ag_group=0&module_option=1&status=-1',
$data['nombre']
);
echo '
';
// Descripcion.
$description = (empty($data['descripcion']) === true) ? '-' : $data['descripcion'];
echo '
';
echo '
'.__('Description').'
';
echo '
'.$description.'
';
echo '
';
// Agent.
echo '
';
// Group.
$group = (empty($data['id_module_group']) === true)
? '-'
: modules_get_modulegroup_name($data['id_module_group']);
echo '
';
echo '
'.__('Module group').'
';
echo '
'.$group.'
';
echo '
';
$graph_type = return_graphtype($data['module_type']);
$url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false);
$handle = dechex(crc32($data['id_agente_modulo'].$data['module_name']));
$win_handle = 'day_'.$handle;
$graph_params = [
'type' => $graph_type,
'period' => SECONDS_1DAY,
'id' => $data['id_agente_modulo'],
'refresh' => SECONDS_10MINUTES,
];
$graph_params_str = http_build_query($graph_params);
$link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)';
$img_graph = html_print_anchor(
[
'href' => 'javascript:'.$link,
'content' => html_print_image('images/module-graph.svg', true, ['border' => '0', 'alt' => '', 'class' => 'invert_filter main_menu_icon']),
],
true
);
echo '
';
echo '
'.__('Data').'
';
$data_module = '';
if (is_numeric($data['datos'])) {
$data_module = remove_right_zeros(
number_format(
$data['datos'],
$config['graph_precision'],
$config['decimal_separator'],
$config['thousand_separator']
)
);
echo '
'.$data_module.' '.$data['unit'].' '.$img_graph.'
';
} else {
$data_module = $data['datos'];
echo '
'.$data['datos'].' '.$data['unit'].' '.$img_graph.'
';
}
echo '
';
echo '
';
echo '
'.__('Date of last data').'
';
echo '
'.date('Y-m-d H:i:s', $data['utimestamp']).'
';
echo '
';
$status = modules_get_agentmodule_status($id);
switch ($status) {
case AGENT_MODULE_STATUS_NORMAL:
$status = ui_print_status_image('module_ok.png', $data_module, true);
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
$status = ui_print_status_image('module_critical.png', $data_module, true);
break;
case AGENT_MODULE_STATUS_WARNING:
$status = ui_print_status_image('module_warning.png', $data_module, true);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$status = ui_print_status_image('module_alertsfired.png', $data_module, true);
break;
case AGENT_MODULE_STATUS_NO_DATA:
$status = ui_print_status_image('module_no_data.png', $data_module, true);
break;
default:
case AGENT_MODULE_STATUS_UNKNOWN:
$status = ui_print_status_image('module_unknown.png', $data_module, true);
break;
}
echo '
';
echo '
'.__('Status').'
';
echo '
'.$status.'
';
echo '
';
break;
case 1:
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
// Nombre.
$link = sprintf(
'index.php?sec=view&sec2=operation/agentes/status_monitor%s&ag_modulename=%s',
'&refr=0&ag_group=0&module_option=1&status=-1',
$data['nombre']
);
echo '
';
// Descripcion.
$description = (empty($data['descripcion']) === true) ? '-' : $data['descripcion'];
echo '
';
echo '
'.__('Description').'
';
echo '
'.$description.'
';
echo '
';
// Agent.
echo '
';
// Group.
$group = (empty($data['id_module_group']) === true)
? '-'
: modules_get_modulegroup_name($data['id_module_group']);
echo '
';
echo '
'.__('Module group').'
';
echo '
'.$group.'
';
echo '
';
// Tag.
$tags = db_get_all_rows_sql('SELECT id_tag FROM ttag_module WHERE id_agente_modulo ='.$id);
$tags_name = '';
echo '
';
echo '
'.__('Tag').'
';
foreach ($tags as $key => $tag) {
$tags_name .= tags_get_name($tag['id_tag']).', ';
}
$tags_name = trim($tags_name, ', ');
echo '
'.$tags_name.'
';
echo '
';
break;
case 0:
default:
$data = agents_get_agent($id);
// Alias.
echo '
';
// Ip.
echo '
';
echo '
'.__('IP').'
';
echo '
'.$data['direccion'].'
';
echo '
';
// OS.
echo '
';
echo '
'.__('OS').'
';
echo '
'.ui_print_os_icon($data['id_os'], true, true).'
';
echo '
';
// Description.
echo '
';
echo '
'.__('Description').'
';
echo '
'.$data['comentarios'].'
';
echo '
';
// Last contact.
$lastContactDate = ui_print_timestamp($data['ultimo_contacto'], true);
$remoteContactDate = ($data['ultimo_contacto_remoto'] === '01-01-1970 00:00:00') ? __('Never') : date_w_fixed_tz($data['ultimo_contacto_remoto']);
$lastAndRemoteContact = sprintf('%s / %s', $lastContactDate, $remoteContactDate);
echo '
';
echo '
'.__('Last contact').' / '.__('Remote').'
';
echo '
'.$lastAndRemoteContact.'
';
echo '
';
// Next contact progress.
$progress = agents_get_next_contact($id);
$tempTimeToShow = ($data['intervalo'] - (strtotime('now') - strtotime($data['ultimo_contacto'])));
$progressCaption = ($tempTimeToShow >= 0) ? sprintf('%d s', $tempTimeToShow) : __('Out of bounds');
$ajaxNextContactInterval = (empty($data['intervalo']) === true) ? 0 : (100 / $data['intervalo']);
echo '
';
echo '
'.__('Next contact').'
';
echo '
'.ui_progress(
$progress,
'80%',
'1.2',
'#ececec',
true,
$progressCaption,
[
'page' => 'operation/agentes/ver_agente',
'interval' => $ajaxNextContactInterval,
'data' => [
'id_agente' => $id,
'refresh_contact' => 1,
],
]
).'
';
echo '
';
// Group.
$secondary_groups = '';
$secondary = enterprise_hook('agents_get_secondary_groups', [$data['id_agente']]);
if (isset($secondary['for_select']) === true && empty($secondary['for_select']) === false) {
$secondary_groups = implode(', ', $secondary['for_select']);
$secondary_groups = ', '.$secondary_groups;
}
echo '
';
echo '
'.__('Group').'
';
echo '
'.groups_get_name($data['id_grupo']).$secondary_groups.'
';
echo '
';
echo '
';
echo graph_agent_status(
$id,
150,
150,
true,
false,
false,
true
);
echo '
';
echo '
';
echo reporting_tiny_stats(
$data,
true,
'agent',
// Useless.
':',
true
);
echo '
';
// Events.
$result_graph_event = enterprise_hook(
'graph_graphic_agentevents',
[
$id,
100,
40,
SECONDS_1DAY,
'',
true,
false,
false,
1,
]
);
if ($result_graph_event !== -1) {
echo '
';
echo $result_graph_event;
echo '
';
}
break;
}
echo '
';
if (empty($id_server) === false) {
$nd->disconnect();
}
}
return;
}