';
} else {
$data[9] = '';
}
$data[9] .= ui_print_timestamp($module['utimestamp'], true, ['style' => 'font-size: 7pt']);
$data[9] .= '';
array_push($table->data, $data);
$rowIndex++;
}
ui_require_javascript_file('pandora.js');
?>
data)) {
if ($filter_monitors) {
ui_print_info_message([ 'no_close' => true, 'message' => __('Any monitors aren\'t with this filter.') ]);
} else {
ui_print_info_message([ 'no_close' => true, 'message' => __('This agent doesn\'t have any active monitors.') ]);
}
} else {
$url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.'&status_text_monitor='.$status_text_monitor.'&status_module_group='.$status_module_group;
if ($paginate_module) {
ui_pagination(
$count_modules,
false,
0,
0,
false,
'offset',
true,
'',
'pagination_list_modules(offset_param)',
[
'count' => '',
'offset' => 'offset_param',
]
);
}
html_print_table($table);
if ($paginate_module) {
ui_pagination(
$count_modules,
false,
0,
0,
false,
'offset',
true,
'pagination-bottom',
'pagination_list_modules(offset_param)',
[
'count' => '',
'offset' => 'offset_param',
]
);
}
}
unset($table);
unset($table_data);
}
if ($get_type) {
$id_module = (int) get_parameter('id_module');
$module = modules_get_agentmodule($id_module);
$graph_type = return_graphtype($module['id_tipo_modulo']);
echo $graph_type;
return;
}
if ($get_graph_module === true) {
global $config;
$output = '';
$graph_data = get_parameter('graph_data', '');
$params = json_decode(base64_decode($graph_data), true);
$server_id = (int) get_parameter('server_id', 0);
include_once $config['homedir'].'/include/functions_graph.php';
// Metaconsole connection to the node.
if (is_metaconsole() === true && empty($server_id) === false) {
$server = metaconsole_get_connection_by_id($server_id);
metaconsole_connect($server);
}
if ($params['histogram'] === true) {
$params['id_agent_module'] = $params['agent_module_id'];
$params['dinamic_proc'] = 1;
$output .= '';
if ($params['compare'] === 'separated') {
$graph = \reporting_module_histogram_graph(
['datetime' => ($params['begin_date'] - $params['period'])],
$params
);
$output .= $graph['chart'];
}
$graph = \reporting_module_histogram_graph(
['datetime' => $params['begin_date']],
$params
);
$output .= $graph['chart'];
$output .= '
';
} else {
$output .= grafico_modulo_sparse($params);
}
if (is_metaconsole() === true && empty($server_id) === false) {
metaconsole_restore_db();
}
echo $output;
return;
}
if ($get_graph_module_interfaces === true) {
global $config;
include_once $config['homedir'].'/include/functions_graph.php';
$output = '';
$graph_data = get_parameter('graph_data', '');
$params = json_decode(base64_decode($graph_data), true);
$modules = get_parameter('modules', '');
$modules = json_decode(base64_decode($modules), true);
$graph_data_combined = get_parameter('graph_data_combined', '');
$params_combined = json_decode(
base64_decode($graph_data_combined),
true
);
$output .= graphic_combined_module(
$modules,
$params,
$params_combined
);
echo $output;
return;
}
if ($get_data_dataMatrix === true) {
global $config;
$table_id = get_parameter('table_id', '');
$modules = json_decode(
io_safe_output(
get_parameter('modules', '')
),
true
);
$period = get_parameter('period', 0);
$slice = get_parameter('slice', 0);
// Datatables offset, limit.
$start = get_parameter('start', 0);
$length = get_parameter(
'length',
$config['block_size']
);
$order = get_datatable_order(true);
$time_all_box = ($length * $slice);
$total_box = ceil($period / $slice);
if ($start > 0) {
$start = ($start / $length);
}
// Uncompress.
try {
ob_start();
$date = (get_system_time() - ($time_all_box * $start));
$datelimit = ($date - $time_all_box);
foreach ($modules as $key => $value) {
$module_data = db_uncompress_module_data(
$value['id'],
$datelimit,
$date,
$slice,
true
);
$uncompressData[] = array_reduce(
$module_data,
function ($carry, $item) use ($value) {
if (is_array($item['data']) === true) {
foreach ($item['data'] as $i => $v) {
$carry[] = [
'utimestamp' => $v['utimestamp'],
'Column-'.$value['id'] => $v['datos'],
];
}
}
return $carry;
},
[]
);
}
if (empty($uncompressData) === false) {
$data = array_reduce(
$uncompressData,
function ($carry, $item) {
foreach ($item as $data_module) {
foreach ($data_module as $key => $value) {
if ($key === 'utimestamp') {
$carry[$data_module['utimestamp']]['date'] = date('Y-m-d H:i', (int) $value);
} else {
$carry[$data_module['utimestamp']][$key] = $value;
}
}
}
// TODO: TO BE CONTINUED.
/*
if (is_numeric($tmp->data) === true) {
$tmp->data = format_numeric(
$tmp->data,
$config['graph_precision']
);
} else {
$tmp->data = ui_print_truncate_text($tmp->data, 10);
}
$carry[] = $tmp;
*/
return $carry;
}
);
}
if (empty($data) === false) {
$data = array_reverse(array_values($data));
} else {
$data = [];
}
// RecordsTotal && recordsfiltered resultados totales.
echo json_encode(
[
'data' => $data,
'recordsTotal' => $total_box,
'recordsFiltered' => $total_box,
]
);
$response = ob_get_clean();
// Clean output buffer.
while (ob_get_level() !== 0) {
ob_end_clean();
}
} catch (Exception $e) {
echo json_encode(
['error' => $e->getMessage()]
);
}
// If not valid it will throw an exception.
json_decode($response);
if (json_last_error() == JSON_ERROR_NONE) {
// If valid dump.
echo $response;
} else {
echo json_encode(
['error' => $response]
);
}
return;
}
}