mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
fixed macros reports
This commit is contained in:
parent
a752cbd2fe
commit
ed0688f853
@ -1341,6 +1341,16 @@ switch ($action) {
|
|||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'update':
|
case 'update':
|
||||||
$values = [];
|
$values = [];
|
||||||
|
$server_name = get_parameter('server_id');
|
||||||
|
if (is_metaconsole() && $server_name != '') {
|
||||||
|
$id_meta = metaconsole_get_id_server($server_name);
|
||||||
|
$connection = metaconsole_get_connection_by_id(
|
||||||
|
$id_meta
|
||||||
|
);
|
||||||
|
metaconsole_connect($connection);
|
||||||
|
$values['server_name'] = $connection['server_name'];
|
||||||
|
}
|
||||||
|
|
||||||
$values['id_report'] = $idReport;
|
$values['id_report'] = $idReport;
|
||||||
$values['description'] = get_parameter('description');
|
$values['description'] = get_parameter('description');
|
||||||
$values['type'] = get_parameter('type', null);
|
$values['type'] = get_parameter('type', null);
|
||||||
@ -1349,14 +1359,36 @@ switch ($action) {
|
|||||||
|
|
||||||
$label = get_parameter('label', '');
|
$label = get_parameter('label', '');
|
||||||
|
|
||||||
|
$id_agent = get_parameter('id_agent');
|
||||||
|
$id_agent_module = get_parameter('id_agent_module');
|
||||||
|
|
||||||
// Add macros name.
|
// Add macros name.
|
||||||
$items_label = [];
|
|
||||||
$items_label['type'] = get_parameter('type');
|
|
||||||
$items_label['id_agent'] = get_parameter('id_agent');
|
|
||||||
$items_label['id_agent_module'] = get_parameter(
|
|
||||||
'id_agent_module'
|
|
||||||
);
|
|
||||||
$name_it = (string) get_parameter('name');
|
$name_it = (string) get_parameter('name');
|
||||||
|
|
||||||
|
$agent_description = agents_get_description($id_agent);
|
||||||
|
$agent_group = agents_get_agent_group($id_agent);
|
||||||
|
$agent_address = agents_get_address($id_agent);
|
||||||
|
$agent_alias = agents_get_alias($id_agent);
|
||||||
|
$module_name = modules_get_agentmodule_name(
|
||||||
|
$id_agent_module
|
||||||
|
);
|
||||||
|
|
||||||
|
$module_description = modules_get_agentmodule_descripcion(
|
||||||
|
$id_agent_module
|
||||||
|
);
|
||||||
|
|
||||||
|
$items_label = [
|
||||||
|
'type' => get_parameter('type'),
|
||||||
|
'id_agent' => $id_agent,
|
||||||
|
'id_agent_module' => $id_agent_module,
|
||||||
|
'agent_description' => $agent_description,
|
||||||
|
'agent_group' => $agent_group,
|
||||||
|
'agent_address' => $agent_address,
|
||||||
|
'agent_alias' => $agent_alias,
|
||||||
|
'module_name' => $module_name,
|
||||||
|
'module_description' => $module_description,
|
||||||
|
];
|
||||||
|
|
||||||
$values['name'] = reporting_label_macro(
|
$values['name'] = reporting_label_macro(
|
||||||
$items_label,
|
$items_label,
|
||||||
$name_it
|
$name_it
|
||||||
@ -1712,13 +1744,6 @@ switch ($action) {
|
|||||||
);
|
);
|
||||||
$values['id_group'] = get_parameter('combo_group');
|
$values['id_group'] = get_parameter('combo_group');
|
||||||
$values['server_name'] = get_parameter('server_name');
|
$values['server_name'] = get_parameter('server_name');
|
||||||
$server_id = (int) get_parameter('server_id');
|
|
||||||
if ($server_id != 0) {
|
|
||||||
$connection = metaconsole_get_connection_by_id(
|
|
||||||
$server_id
|
|
||||||
);
|
|
||||||
$values['server_name'] = $connection['server_name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($values['server_name'] == '') {
|
if ($values['server_name'] == '') {
|
||||||
$values['server_name'] = get_parameter(
|
$values['server_name'] = get_parameter(
|
||||||
@ -1975,22 +2000,11 @@ switch ($action) {
|
|||||||
|
|
||||||
$values['style'] = io_safe_input(json_encode($style));
|
$values['style'] = io_safe_input(json_encode($style));
|
||||||
|
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
|
||||||
if ($good_format) {
|
if ($good_format) {
|
||||||
switch ($config['dbtype']) {
|
|
||||||
case 'oracle':
|
|
||||||
if (isset($values['type'])) {
|
|
||||||
$values[db_escape_key_identifier(
|
|
||||||
'type'
|
|
||||||
)] = $values['type'];
|
|
||||||
unset($values['type']);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Default.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$resultOperationDB = db_process_sql_update(
|
$resultOperationDB = db_process_sql_update(
|
||||||
'treport_content',
|
'treport_content',
|
||||||
$values,
|
$values,
|
||||||
@ -2003,21 +2017,62 @@ switch ($action) {
|
|||||||
|
|
||||||
case 'save':
|
case 'save':
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
|
$values['server_name'] = get_parameter('server_name');
|
||||||
|
$server_id = (int) get_parameter('server_id');
|
||||||
|
if ($server_id != 0) {
|
||||||
|
$connection = metaconsole_get_connection_by_id(
|
||||||
|
$server_id
|
||||||
|
);
|
||||||
|
metaconsole_connect($connection);
|
||||||
|
$values['server_name'] = $connection['server_name'];
|
||||||
|
}
|
||||||
|
|
||||||
$values['id_report'] = $idReport;
|
$values['id_report'] = $idReport;
|
||||||
$values['type'] = get_parameter('type', null);
|
$values['type'] = get_parameter('type', null);
|
||||||
$values['description'] = get_parameter('description');
|
$values['description'] = get_parameter('description');
|
||||||
$label = get_parameter('label', '');
|
$label = get_parameter('label', '');
|
||||||
|
|
||||||
// Add macros name.
|
|
||||||
$items_label = [];
|
|
||||||
$items_label['type'] = get_parameter('type');
|
|
||||||
$items_label['id_agent'] = get_parameter('id_agent');
|
|
||||||
$items_label['id_agent_module'] = get_parameter(
|
|
||||||
'id_agent_module'
|
|
||||||
);
|
|
||||||
$name_it = (string) get_parameter('name');
|
|
||||||
$values['recursion'] = get_parameter('recursion', null);
|
$values['recursion'] = get_parameter('recursion', null);
|
||||||
$values['show_extended_events'] = get_parameter('include_extended_events', null);
|
$values['show_extended_events'] = get_parameter(
|
||||||
|
'include_extended_events',
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
$id_agent = get_parameter('id_agent');
|
||||||
|
$id_agent_module = get_parameter('id_agent_module');
|
||||||
|
|
||||||
|
// Add macros name.
|
||||||
|
$name_it = (string) get_parameter('name');
|
||||||
|
|
||||||
|
$agent_description = agents_get_description($id_agent);
|
||||||
|
$agent_group = agents_get_agent_group($id_agent);
|
||||||
|
$agent_address = agents_get_address($id_agent);
|
||||||
|
$agent_alias = agents_get_alias($id_agent);
|
||||||
|
$module_name = modules_get_agentmodule_name(
|
||||||
|
$id_agent_module
|
||||||
|
);
|
||||||
|
|
||||||
|
$module_description = modules_get_agentmodule_descripcion(
|
||||||
|
$id_agent_module
|
||||||
|
);
|
||||||
|
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
metaconsole_restore_db();
|
||||||
|
}
|
||||||
|
|
||||||
|
$items_label = [
|
||||||
|
'type' => get_parameter('type'),
|
||||||
|
'id_agent' => $id_agent,
|
||||||
|
'id_agent_module' => $id_agent_module,
|
||||||
|
'agent_description' => $agent_description,
|
||||||
|
'agent_group' => $agent_group,
|
||||||
|
'agent_address' => $agent_address,
|
||||||
|
'agent_alias' => $agent_alias,
|
||||||
|
'module_name' => $module_name,
|
||||||
|
'module_description' => $module_description,
|
||||||
|
];
|
||||||
|
|
||||||
$values['name'] = reporting_label_macro(
|
$values['name'] = reporting_label_macro(
|
||||||
$items_label,
|
$items_label,
|
||||||
$name_it
|
$name_it
|
||||||
@ -2222,18 +2277,6 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$values['server_name'] = get_parameter('server_name');
|
|
||||||
$server_id = (int) get_parameter('server_id');
|
|
||||||
if ($server_id != 0) {
|
|
||||||
$connection = metaconsole_get_connection_by_id(
|
|
||||||
$server_id
|
|
||||||
);
|
|
||||||
|
|
||||||
$values['server_name'] = $connection['server_name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($values['server_name'] == '') {
|
if ($values['server_name'] == '') {
|
||||||
$values['server_name'] = get_parameter(
|
$values['server_name'] = get_parameter(
|
||||||
'combo_server'
|
'combo_server'
|
||||||
|
@ -1513,29 +1513,30 @@ function agents_get_name($id_agent, $case='none')
|
|||||||
* Get alias of an agent (cached function).
|
* Get alias of an agent (cached function).
|
||||||
*
|
*
|
||||||
* @param integer $id_agent Agent id.
|
* @param integer $id_agent Agent id.
|
||||||
* @param string $case Case (upper, lower, none)
|
* @param string $case Case (upper, lower, none).
|
||||||
*
|
*
|
||||||
* @return string Alias of the given agent.
|
* @return string Alias of the given agent.
|
||||||
*/
|
*/
|
||||||
function agents_get_alias($id_agent, $case='none')
|
function agents_get_alias($id_agent, $case='none')
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
// Prepare cache
|
// Prepare cache.
|
||||||
static $cache = [];
|
static $cache = [];
|
||||||
if (empty($case)) {
|
if (empty($case)) {
|
||||||
$case = 'none';
|
$case = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check cache
|
// Check cache.
|
||||||
if (isset($cache[$case][$id_agent])) {
|
if (isset($cache[$case][$id_agent])) {
|
||||||
return $cache[$case][$id_agent];
|
return $cache[$case][$id_agent];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_metaconsole()) {
|
$alias = (string) db_get_value(
|
||||||
$alias = (string) db_get_value('alias', 'tmetaconsole_agent', 'id_tagente', (int) $id_agent);
|
'alias',
|
||||||
} else {
|
'tagente',
|
||||||
$alias = (string) db_get_value('alias', 'tagente', 'id_agente', (int) $id_agent);
|
'id_agente',
|
||||||
}
|
(int) $id_agent
|
||||||
|
);
|
||||||
|
|
||||||
switch ($case) {
|
switch ($case) {
|
||||||
case 'upper':
|
case 'upper':
|
||||||
@ -1545,6 +1546,10 @@ function agents_get_alias($id_agent, $case='none')
|
|||||||
case 'lower':
|
case 'lower':
|
||||||
$alias = mb_strtolower($alias, 'UTF-8');
|
$alias = mb_strtolower($alias, 'UTF-8');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Not posible.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache[$case][$id_agent] = $alias;
|
$cache[$case][$id_agent] = $alias;
|
||||||
|
@ -1277,12 +1277,34 @@ function graphic_combined_module(
|
|||||||
array_push($modules, $source['id_agent_module']);
|
array_push($modules, $source['id_agent_module']);
|
||||||
array_push($weights, $source['weight']);
|
array_push($weights, $source['weight']);
|
||||||
if ($source['label'] != '' || $params_combined['labels']) {
|
if ($source['label'] != '' || $params_combined['labels']) {
|
||||||
$item['type'] = 'custom_graph';
|
$id_agent = agents_get_module_id(
|
||||||
$item['id_agent'] = agents_get_module_id(
|
|
||||||
$source['id_agent_module']
|
$source['id_agent_module']
|
||||||
);
|
);
|
||||||
$item['id_agent_module'] = $source['id_agent_module'];
|
$agent_description = agents_get_description($id_agent);
|
||||||
$labels[$source['id_agent_module']] = ($source['label'] != '') ? reporting_label_macro($item, $source['label']) : reporting_label_macro($item, $params_combined['labels']);
|
$agent_group = agents_get_agent_group($id_agent);
|
||||||
|
$agent_address = agents_get_address($id_agent);
|
||||||
|
$agent_alias = agents_get_alias($id_agent);
|
||||||
|
$module_name = modules_get_agentmodule_name(
|
||||||
|
$source['id_agent_module']
|
||||||
|
);
|
||||||
|
|
||||||
|
$module_description = modules_get_agentmodule_descripcion(
|
||||||
|
$source['id_agent_module']
|
||||||
|
);
|
||||||
|
|
||||||
|
$items_label = [
|
||||||
|
'type' => 'custom_graph',
|
||||||
|
'id_agent' => $id_agent,
|
||||||
|
'id_agent_module' => $source['id_agent_module'],
|
||||||
|
'agent_description' => $agent_description,
|
||||||
|
'agent_group' => $agent_group,
|
||||||
|
'agent_address' => $agent_address,
|
||||||
|
'agent_alias' => $agent_alias,
|
||||||
|
'module_name' => $module_name,
|
||||||
|
'module_description' => $module_description,
|
||||||
|
];
|
||||||
|
|
||||||
|
$labels[$source['id_agent_module']] = ($source['label'] != '') ? reporting_label_macro($items_label, $source['label']) : reporting_label_macro($item, $params_combined['labels']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -141,6 +141,15 @@ function html_do_report_info($report)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print html report.
|
||||||
|
*
|
||||||
|
* @param array $report Info.
|
||||||
|
* @param boolean $mini Type.
|
||||||
|
* @param integer $report_info Show info.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function reporting_html_print_report($report, $mini=false, $report_info=1)
|
function reporting_html_print_report($report, $mini=false, $report_info=1)
|
||||||
{
|
{
|
||||||
if ($report_info == 1) {
|
if ($report_info == 1) {
|
||||||
@ -161,7 +170,38 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
|
|||||||
$table->rowstyle = [];
|
$table->rowstyle = [];
|
||||||
|
|
||||||
if (isset($item['label']) && $item['label'] != '') {
|
if (isset($item['label']) && $item['label'] != '') {
|
||||||
$label = reporting_label_macro($item, $item['label']);
|
$id_agent = $item['id_agent'];
|
||||||
|
$id_agent_module = $item['id_agent_module'];
|
||||||
|
|
||||||
|
// Add macros name.
|
||||||
|
$agent_description = agents_get_description($id_agent);
|
||||||
|
$agent_group = agents_get_agent_group($id_agent);
|
||||||
|
$agent_address = agents_get_address($id_agent);
|
||||||
|
$agent_alias = agents_get_alias($id_agent);
|
||||||
|
$module_name = modules_get_agentmodule_name(
|
||||||
|
$id_agent_module
|
||||||
|
);
|
||||||
|
|
||||||
|
$module_description = modules_get_agentmodule_descripcion(
|
||||||
|
$id_agent_module
|
||||||
|
);
|
||||||
|
|
||||||
|
$items_label = [
|
||||||
|
'type' => $item['type'],
|
||||||
|
'id_agent' => $id_agent,
|
||||||
|
'id_agent_module' => $id_agent_module,
|
||||||
|
'agent_description' => $agent_description,
|
||||||
|
'agent_group' => $agent_group,
|
||||||
|
'agent_address' => $agent_address,
|
||||||
|
'agent_alias' => $agent_alias,
|
||||||
|
'module_name' => $module_name,
|
||||||
|
'module_description' => $module_description,
|
||||||
|
];
|
||||||
|
|
||||||
|
$label = reporting_label_macro(
|
||||||
|
$items_label,
|
||||||
|
$item['label']
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$label = '';
|
$label = '';
|
||||||
}
|
}
|
||||||
@ -180,7 +220,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
|
|||||||
|
|
||||||
$table->data['description_row']['description'] = $item['description'];
|
$table->data['description_row']['description'] = $item['description'];
|
||||||
|
|
||||||
if ($item['type'] == 'event_report_agent' || $item['type'] == 'event_report_group' || $item['type'] == 'event_report_module') {
|
if ($item['type'] == 'event_report_agent'
|
||||||
|
|| $item['type'] == 'event_report_group'
|
||||||
|
|| $item['type'] == 'event_report_module'
|
||||||
|
) {
|
||||||
$table->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
$table->data['count_row']['count'] = 'Total events: '.$item['total_events'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user