Merge branch 'ent-6366-Definir-tipo-de-grafica-en-informes-de-grafica' into 'develop'

add render graph to reports

See merge request artica/pandorafms!3483
This commit is contained in:
Daniel Rodriguez 2020-10-02 14:16:55 +02:00
commit 350018982c
19 changed files with 577 additions and 231 deletions

View File

@ -22,4 +22,7 @@ ALTER TABLE talert_actions ADD COLUMN `field18_recovery` TEXT NOT NULL DEFAULT "
ALTER TABLE talert_actions ADD COLUMN `field19_recovery` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_actions ADD COLUMN `field20_recovery` TEXT NOT NULL DEFAULT "";
ALTER TABLE `treport_content` add column `graph_render` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content_template` add column `graph_render` tinyint(1) UNSIGNED NOT NULL default 0;
COMMIT;

View File

@ -849,7 +849,8 @@ ALTER TABLE `treport_content_template` MODIFY COLUMN `historical_db` tinyint(1)
MODIFY COLUMN `visual_format` tinyint(1) unsigned NOT NULL DEFAULT '0';
ALTER TABLE `treport_content_template` ADD COLUMN `landscape` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content_template` ADD COLUMN `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content_template` add column `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content_template` ADD COLUMN `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content_template` ADD COLUMN `graph_render` tinyint(1) UNSIGNED NOT NULL default 0;
-- ----------------------------------------------------------------------
-- Table `tnews`
@ -1370,13 +1371,13 @@ ALTER TABLE `ttag` ADD COLUMN `previous_name` text NULL;
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 41);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 42);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '749');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', 750);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password';
@ -1692,7 +1693,8 @@ ALTER TABLE `treport_content` MODIFY COLUMN `historical_db` tinyint(1) unsigned
MODIFY COLUMN `failover_type` tinyint(1) NULL DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `landscape` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content` ADD COLUMN `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content` add column `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content` ADD COLUMN `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `treport_content` ADD COLUMN `graph_render` tinyint(1) UNSIGNED NOT NULL default 0;
-- ---------------------------------------------------------------------
-- Table `tmodule_relationship`

View File

@ -156,6 +156,8 @@ $agent_max_value = true;
$agent_min_value = true;
$uncompressed_module = true;
$graph_render = (empty($config['type_mode_graph']) === true) ? 0 : $config['type_mode_graph'];
switch ($action) {
case 'new':
$actionParameter = 'save';
@ -259,7 +261,8 @@ switch ($action) {
case 'simple_graph':
$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
$percentil = isset($style['percentil']) ? $config['percentil'] : 0;
$percentil = isset($style['percentil']) ? (bool) $style['percentil'] : 0;
$graph_render = $item['graph_render'];
// The break hasn't be forgotten.
case 'simple_baseline_graph':
case 'projection_graph':
@ -653,6 +656,7 @@ switch ($action) {
$period = $item['period'];
$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
$recursion = $item['recursion'];
$graph_render = $item['graph_render'];
break;
case 'top_n':
@ -2091,18 +2095,24 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_time_compare_overlapped" style="" class="datos">
<tr id="row_graph_render" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Time compare (Overlapped)');
echo __('Graph render');
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'time_compare_overlapped',
1,
$time_compare_overlapped
$list_graph_render = [
1 => __('Avg, max & min'),
2 => __('Max only'),
3 => __('Min only'),
0 => __('Avg only'),
];
html_print_select(
$list_graph_render,
'graph_render',
$graph_render
);
?>
</td>
@ -2128,9 +2138,26 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_time_compare_overlapped" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Time compare (Overlapped)');
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'time_compare_overlapped',
1,
$time_compare_overlapped
);
?>
</td>
</tr>
<tr id="row_percentil" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Percentil'); ?></td>
<td><?php html_print_checkbox('percentil', 1, $percentil); ?></td>
<td><?php html_print_checkbox_switch('percentil', 1, $percentil); ?></td>
</tr>
<tr id="row_exception_condition_value" style="" class="datos">
@ -3891,6 +3918,16 @@ $(document).ready (function () {
});
});
$("#checkbox-fullscale").change(function(e){
if(e.target.checked === true) {
$("#graph_render").prop('disabled', 'disabled');
} else {
$("#graph_render").prop('disabled', false);
}
});
$('#checkbox-fullscale').trigger('change');
$("#submit-create_item").click(function () {
var type = $('#type').val();
var name = $('#text-name').val();
@ -4906,6 +4943,7 @@ function chooseType() {
$("#row_show_graph").hide();
$("#row_max_min_avg").hide();
$("#row_fullscale").hide();
$("#row_graph_render").hide();
$("#row_time_compare_overlapped").hide();
$("#row_quantity").hide();
$("#row_exception_condition_value").hide();
@ -5010,8 +5048,14 @@ function chooseType() {
case 'simple_graph':
$("#row_time_compare_overlapped").show();
$("#row_fullscale").show();
if ($("#checkbox-percentil").prop("checked"))
$("#row_percentil").show();
$("#row_graph_render").show();
$("#row_percentil").show();
// Force type.
if('<?php echo $action; ?>' === 'new'){
$("#graph_render").val(<?php echo $graph_render; ?>);
}
// The break hasn't be forgotten, this element
// only should be shown on the simple graphs.
case 'simple_baseline_graph':
@ -5377,7 +5421,12 @@ function chooseType() {
$("#row_description").show();
$("#row_period").show();
$("#row_historical_db_check").hide();
$("#row_graph_render").show();
$("#row_fullscale").show();
// Force MAX type.
if('<?php echo $action; ?>' === 'new'){
$("#graph_render").val(2);
}
break;
case 'top_n':

View File

@ -1632,6 +1632,9 @@ switch ($action) {
break;
case 'simple_graph':
$values['graph_render'] = (int) get_parameter(
'graph_render'
);
case 'simple_baseline_graph':
// HACK it is saved in show_graph field.
$values['show_graph'] = (int) get_parameter(
@ -1641,6 +1644,14 @@ switch ($action) {
$good_format = true;
break;
case 'network_interfaces_report':
$values['graph_render'] = (int) get_parameter(
'graph_render'
);
$values['period'] = get_parameter('period');
$good_format = true;
break;
case 'min_value':
case 'max_value':
case 'avg_value':
@ -2274,6 +2285,9 @@ switch ($action) {
break;
case 'simple_graph':
$values['graph_render'] = (int) get_parameter(
'graph_render'
);
case 'simple_baseline_graph':
// HACK it is saved in show_graph field.
$values['show_graph'] = (int) get_parameter(
@ -2283,6 +2297,14 @@ switch ($action) {
$good_format = true;
break;
case 'network_interfaces_report':
$values['graph_render'] = (int) get_parameter(
'graph_render'
);
$values['period'] = get_parameter('period');
$good_format = true;
break;
case 'min_value':
case 'max_value':
case 'avg_value':

View File

@ -738,67 +738,166 @@ $row++;
$table_chars->data = [];
$table_chars->data[$row][0] = __('Graph color #1');
$table_chars->data[$row][1] = html_print_input_text('graph_color1', $config['graph_color1'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color1',
$config['graph_color1'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #2');
$table_chars->data[$row][1] = html_print_input_text('graph_color2', $config['graph_color2'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color2',
$config['graph_color2'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #3');
$table_chars->data[$row][1] = html_print_input_text('graph_color3', $config['graph_color3'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color3',
$config['graph_color3'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #4');
$table_chars->data[$row][1] = html_print_input_text('graph_color4', $config['graph_color4'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color4',
$config['graph_color4'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #5');
$table_chars->data[$row][1] = html_print_input_text('graph_color5', $config['graph_color5'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color5',
$config['graph_color5'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #6');
$table_chars->data[$row][1] = html_print_input_text('graph_color6', $config['graph_color6'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color6',
$config['graph_color6'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #7');
$table_chars->data[$row][1] = html_print_input_text('graph_color7', $config['graph_color7'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color7',
$config['graph_color7'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #8');
$table_chars->data[$row][1] = html_print_input_text('graph_color8', $config['graph_color8'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color8',
$config['graph_color8'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #9');
$table_chars->data[$row][1] = html_print_input_text('graph_color9', $config['graph_color9'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color9',
$config['graph_color9'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph color #10');
$table_chars->data[$row][1] = html_print_input_text('graph_color10', $config['graph_color10'], '', 8, 8, true);
$table_chars->data[$row][1] = html_print_input_text(
'graph_color10',
$config['graph_color10'],
'',
8,
8,
true
);
$row++;
$table_chars->data[$row][0] = __('Value to interface graphics');
$table_chars->data[$row][1] = html_print_input_text('interface_unit', $config['interface_unit'], '', 20, 20, true);
$table_chars->data[$row][1] = html_print_input_text(
'interface_unit',
$config['interface_unit'],
'',
20,
20,
true
);
$row++;
$disabled_graph_precision = false;
if (!enterprise_installed()) {
if (enterprise_installed() === false) {
$disabled_graph_precision = true;
}
$table_chars->data[$row][0] = __('Data precision');
$table_chars->data[$row][1] = html_print_input_text('graph_precision', $config['graph_precision'], '', 5, 5, true, $disabled_graph_precision, false, 'onChange="change_precision()"');
$table_chars->data[$row][1] = html_print_input_text(
'graph_precision',
$config['graph_precision'],
'',
5,
5,
true,
$disabled_graph_precision,
false,
'onChange="change_precision()"'
);
$row++;
if (!isset($config['short_module_graph_data'])) {
if (isset($config['short_module_graph_data']) === false) {
$config['short_module_graph_data'] = true;
}
$table_chars->data[$row][0] = __('Data precision in graphs');
$table_chars->data[$row][1] = html_print_input_text('short_module_graph_data', $config['short_module_graph_data'], '', 5, 5, true, $disabled_graph_precision, false, 'onChange="change_precision()"');
$table_chars->data[$row][1] = html_print_input_text(
'short_module_graph_data',
$config['short_module_graph_data'],
'',
5,
5,
true,
$disabled_graph_precision,
false,
'onChange="change_precision()"'
);
$row++;
$table_chars->data[$row][0] = __('Default line thickness for the Custom Graph.');
$table_chars->data[$row][0] = __(
'Default line thickness for the Custom Graph.'
);
$table_chars->data[$row][1] = html_print_input_text(
'custom_graph_width',
$config['custom_graph_width'],
@ -853,7 +952,14 @@ $row++;
$row++;
$table_chars->data[$row][0] = __('Percentile');
$table_chars->data[$row][1] = html_print_input_text('percentil', $config['percentil'], '', 20, 20, true);
$table_chars->data[$row][1] = html_print_input_text(
'percentil',
$config['percentil'],
'',
20,
20,
true
);
$row++;
$table_chars->data[$row][0] = __('Graph TIP view:');
@ -863,17 +969,37 @@ $row++;
$options_full_escale[1] = __('All');
$options_full_escale[2] = __('On Boolean graphs');
$table_chars->data[$row][1] = html_print_select($options_full_escale, 'full_scale_option', $config['full_scale_option'], '', '', 0, true, false, false);
$table_chars->data[$row][1] = html_print_select(
$options_full_escale,
'full_scale_option',
$config['full_scale_option'],
'',
'',
0,
true,
false,
false
);
$row++;
$table_chars->data[$row][0] = __('Show only average');
$table_chars->data[$row][0] = __('Graph mode');
$options_soft_graphs = [];
$options_soft_graphs[0] = __('Show only average by default');
$options_soft_graphs[1] = __('Show MAX/AVG/MIN by default');
$table_chars->data[$row][1] = html_print_select($options_soft_graphs, 'type_mode_graph', $config['type_mode_graph'], '', '', 0, true, false, false);
$table_chars->data[$row][1] = html_print_select(
$options_soft_graphs,
'type_mode_graph',
$config['type_mode_graph'],
'',
'',
0,
true,
false,
false
);
$row++;
$table_chars->data[$row][0] = __('Zoom graphs:');
@ -885,18 +1011,19 @@ $row++;
$options_zoom_graphs[4] = 'x4';
$options_zoom_graphs[5] = 'x5';
$table_chars->data[$row][1] = html_print_select($options_zoom_graphs, 'zoom_graph', $config['zoom_graph'], '', '', 0, true, false, false);
$table_chars->data[$row][1] = html_print_select(
$options_zoom_graphs,
'zoom_graph',
$config['zoom_graph'],
'',
'',
0,
true,
false,
false
);
$row++;
/*
$table_font->data[$row][0] = __('Font path');
$fonts = load_fonts();
$table_font->data[$row][1] = html_print_select($fonts, 'fontpath',
io_safe_output($config["fontpath"]), '', '', 0, true);
$row++;
*/
echo '<fieldset>';
echo '<legend>'.__('Charts configuration').' '.ui_print_help_icon('charts_conf_tab', true).'</legend>';
html_print_table($table_chars);

View File

@ -198,6 +198,7 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
break;
case 'sparse':
$params['pdf'] = true;
echo grafico_modulo_sparse($params);
break;

View File

@ -3771,7 +3771,11 @@ function series_type_graph_array($data, $show_elements_graph)
}
} else {
$name_legend = '';
if ((int) $config['type_mode_graph'] === 1) {
if (isset($show_elements_graph['fullscale']) === true
&& (int) $show_elements_graph['fullscale'] === 1
) {
$name_legend .= 'Tip: ';
} else {
$name_legend .= 'Avg: ';
}
@ -3839,7 +3843,8 @@ function series_type_graph_array($data, $show_elements_graph)
$data_return['series_type'][$key] = $type_graph;
$name_legend = '';
if ((int) $config['type_mode_graph'] === 1) {
if ((int) $show_elements_graph['type_mode_graph'] != 0) {
if (strpos($key, 'min') !== false) {
$name_legend .= 'Min: ';
}

View File

@ -2957,7 +2957,6 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false)
}
$ni_by_agents = [];
foreach ($agents as $agent) {
$agent_id = $agent['id_agente'];
$agent_group_id = $agent['id_grupo'];
@ -2965,27 +2964,52 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false)
$agent_interfaces = [];
$accepted_module_types = [];
$remote_snmp_proc = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'remote_snmp_proc');
$remote_snmp_proc = (int) db_get_value(
'id_tipo',
'ttipo_modulo',
'nombre',
'remote_snmp_proc'
);
if ($remote_snmp_proc) {
$accepted_module_types[] = $remote_snmp_proc;
}
$remote_icmp_proc = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'remote_icmp_proc');
$remote_icmp_proc = (int) db_get_value(
'id_tipo',
'ttipo_modulo',
'nombre',
'remote_icmp_proc'
);
if ($remote_icmp_proc) {
$accepted_module_types[] = $remote_icmp_proc;
}
$remote_tcp_proc = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'remote_tcp_proc');
$remote_tcp_proc = (int) db_get_value(
'id_tipo',
'ttipo_modulo',
'nombre',
'remote_tcp_proc'
);
if ($remote_tcp_proc) {
$accepted_module_types[] = $remote_tcp_proc;
}
$generic_proc = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'generic_proc');
$generic_proc = (int) db_get_value(
'id_tipo',
'ttipo_modulo',
'nombre',
'generic_proc'
);
if ($generic_proc) {
$accepted_module_types[] = $generic_proc;
}
$remote_snmp = (int) db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'remote_snmp');
$remote_snmp = (int) db_get_value(
'id_tipo',
'ttipo_modulo',
'nombre',
'remote_snmp'
);
if ($remote_snmp) {
$accepted_module_types[] = $remote_snmp;
}
@ -3008,8 +3032,13 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false)
}
$filter = " tagente_modulo.id_agente = $agent_id AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo IN (".implode(',', $accepted_module_types).") AND (tagente_modulo.nombre LIKE '%_ifOperStatus' OR tagente_modulo.nombre LIKE 'ifOperStatus_%')";
$modules = agents_get_modules($agent_id, $columns, $filter, true, false);
$modules = agents_get_modules(
$agent_id,
$columns,
$filter,
true,
false
);
if (!empty($modules)) {
$interfaces = [];

View File

@ -299,13 +299,17 @@ function grafico_modulo_sparse_data(
return false;
}
$array_data = series_suffix_leyend(
'sum',
$series_suffix,
$agent_module_id,
$data_module_graph,
$array_data
);
if ((int) $params['type_mode_graph'] !== 2
&& (int) $params['type_mode_graph'] !== 3
) {
$array_data = series_suffix_leyend(
'sum',
$series_suffix,
$agent_module_id,
$data_module_graph,
$array_data
);
}
if ($params['percentil']) {
$array_data = series_suffix_leyend(
@ -317,22 +321,30 @@ function grafico_modulo_sparse_data(
);
}
if ($params['type_mode_graph']) {
$array_data = series_suffix_leyend(
'min',
$series_suffix,
$agent_module_id,
$data_module_graph,
$array_data
);
if ($params['type_mode_graph'] > 0) {
if ((int) $params['type_mode_graph'] === 1
|| (int) $params['type_mode_graph'] === 3
) {
$array_data = series_suffix_leyend(
'min',
$series_suffix,
$agent_module_id,
$data_module_graph,
$array_data
);
}
$array_data = series_suffix_leyend(
'max',
$series_suffix,
$agent_module_id,
$data_module_graph,
$array_data
);
if ((int) $params['type_mode_graph'] === 1
|| (int) $params['type_mode_graph'] === 2
) {
$array_data = series_suffix_leyend(
'max',
$series_suffix,
$agent_module_id,
$data_module_graph,
$array_data
);
}
}
// This is for a specific type of report that consists in passing
@ -614,6 +626,7 @@ function grafico_modulo_sparse_data(
* 'return_img_base_64' => false,
* 'image_treshold' => false,
* 'graph_combined' => false,
* 'graph_render' => 0,
* 'zoom' => 1,
* 'server_id' => null,
* 'stacked' => 0.
@ -776,14 +789,28 @@ function grafico_modulo_sparse($params, $server_name='')
if (!isset($params['type_mode_graph'])) {
$params['type_mode_graph'] = $config['type_mode_graph'];
if (isset($params['graph_render']) === true) {
$params['type_mode_graph'] = $params['graph_render'];
}
}
if (!isset($params['projection'])) {
$params['projection'] = false;
}
if (isset($params['pdf']) === false) {
$params['pdf'] = false;
}
if (!isset($params['agent_module_id'])) {
return graph_nodata_image($params['width'], $params['height']);
return graph_nodata_image(
$params['width'],
$params['height'],
'area',
'',
false,
$params['pdf']
);
} else {
$agent_module_id = $params['agent_module_id'];
}
@ -816,12 +843,6 @@ function grafico_modulo_sparse($params, $server_name='')
$date_array['final_date'] = $params['date'];
$date_array['start_date'] = ($params['date'] - $params['period']);
if (is_metaconsole()) {
$id_meta = metaconsole_get_id_server($server_name);
$server = metaconsole_get_connection_by_id($id_meta);
metaconsole_connect($server);
}
if ($agent_module_id) {
$module_data = db_get_row_sql(
'SELECT * FROM tagente_modulo
@ -979,7 +1000,14 @@ function grafico_modulo_sparse($params, $server_name='')
$array_events_alerts
);
} else {
$return = graph_nodata_image($params['width'], $params['height']);
$return = graph_nodata_image(
$params['width'],
$params['height'],
'area',
'',
false,
$params['pdf']
);
}
$return .= '<br>';
@ -1006,7 +1034,14 @@ function grafico_modulo_sparse($params, $server_name='')
$array_events_alerts
);
} else {
$return .= graph_nodata_image($params['width'], $params['height']);
$return = graph_nodata_image(
$params['width'],
$params['height'],
'area',
'',
false,
$params['pdf']
);
}
} else {
if (empty($array_data) === false) {
@ -1027,15 +1062,13 @@ function grafico_modulo_sparse($params, $server_name='')
$params['width'],
$params['height'],
'area',
__('No data to display within the selected interval')
__('No data to display within the selected interval'),
false,
$params['pdf']
);
}
}
if (is_metaconsole()) {
metaconsole_restore_db();
}
return $return;
}
@ -1247,8 +1280,17 @@ function graphic_combined_module(
}
if (!isset($params['type_mode_graph'])) {
// $config['type_mode_graph']
$params['type_mode_graph'] = 0;
if (isset($params['graph_render']) === true) {
$params['type_mode_graph'] = $params['graph_render'];
$params_combined['type_mode_graph'] = $params['graph_render'];
}
}
if (isset($params['fullscale']) === false) {
$params_combined['fullscale'] = false;
} else {
$params_combined['fullscale'] = $params['fullscale'];
}
$params['graph_combined'] = true;
@ -1281,7 +1323,7 @@ function graphic_combined_module(
$sources = false;
if ($params_combined['id_graph'] == 0) {
if ((int) $params_combined['id_graph'] === 0) {
$count_modules = count($module_list);
if (!$params_combined['weight_list']) {
@ -1290,7 +1332,7 @@ function graphic_combined_module(
if ($count_modules > 0) {
foreach ($module_list as $key => $value) {
$sources[$key]['id_server'] = (isset($value['id_server']) === true) ? $value['id_server'] : $params['id_server'];
$sources[$key]['id_server'] = (isset($value['id_server']) === true) ? $value['id_server'] : $params['server_id'];
$sources[$key]['id_agent_module'] = $value['module'];
$sources[$key]['weight'] = $weights[$key];
$sources[$key]['label'] = $params_combined['labels'];
@ -4258,21 +4300,23 @@ function fullscale_data(
}
}
if (isset($v['datos']) && $v['datos']) {
// Max.
if ($v['datos'] >= $max_value) {
// Max.
if ($v['datos'] === false || $v['datos'] >= $max_value) {
if ($v['datos'] === false) {
$max_value = 0;
} else {
$max_value = $v['datos'];
}
// Min.
if ($v['datos'] <= $min_value) {
$min_value = $v['datos'];
}
// Avg sum.
$sum_data += $v['datos'];
}
// Min.
if ($v['datos'] <= $min_value) {
$min_value = $v['datos'];
}
// Avg sum.
$sum_data += $v['datos'];
// Avg count.
$count_data++;
@ -4291,23 +4335,30 @@ function fullscale_data(
$real_date = ($k['data'][0]['utimestamp'] * 1000);
}
$data['sum'.$series_suffix]['data'][] = [
$real_date,
($sum_data / $count_data),
];
if ($type_mode_graph <= 1) {
$data['sum'.$series_suffix]['data'][] = [
$real_date,
($sum_data / $count_data),
];
}
if ($type_mode_graph && !$params['baseline']) {
if ($min_value != PHP_INT_MAX) {
$data['min'.$series_suffix]['data'][] = [
$real_date,
$min_value,
];
if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 3) {
if ($min_value != PHP_INT_MAX) {
$data['min'.$series_suffix]['data'][] = [
$real_date,
$min_value,
];
}
}
if ($max_value != (-PHP_INT_MAX)) {
$data['max'.$series_suffix]['data'][] = [
$real_date,
$max_value,
];
if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 2) {
if ($max_value != (-PHP_INT_MAX)) {
$data['max'.$series_suffix]['data'][] = [
$real_date,
$max_value,
];
}
}
} else {
if ($min_value != PHP_INT_MAX) {
@ -4400,25 +4451,33 @@ function fullscale_data(
}
}
$data['sum'.$series_suffix]['min'] = $min_value_total;
$data['sum'.$series_suffix]['max'] = $max_value_total;
$data['sum'.$series_suffix]['avg'] = 0;
if (isset($count_data_total) === true) {
$data['sum'.$series_suffix]['avg'] = ($sum_data_total / $count_data_total);
if ($type_mode_graph <= 1) {
$data['sum'.$series_suffix]['min'] = $min_value_total;
$data['sum'.$series_suffix]['max'] = $max_value_total;
$data['sum'.$series_suffix]['avg'] = 0;
if (isset($count_data_total) === true) {
$data['sum'.$series_suffix]['avg'] = ($sum_data_total / $count_data_total);
}
}
if ($type_mode_graph && !$params['baseline']) {
$data['min'.$series_suffix]['min'] = $min_value_min;
$data['min'.$series_suffix]['max'] = $min_value_max;
$data['min'.$series_suffix]['avg'] = ($sum_data_min / $count_data_total);
if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 3) {
$data['min'.$series_suffix]['min'] = $min_value_min;
$data['min'.$series_suffix]['max'] = $min_value_max;
$data['min'.$series_suffix]['avg'] = ($sum_data_min / $count_data_total);
}
$data['max'.$series_suffix]['min'] = $max_value_min;
$data['max'.$series_suffix]['max'] = $max_value_max;
$data['max'.$series_suffix]['avg'] = ($sum_data_max / $count_data_total);
if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 2) {
$data['max'.$series_suffix]['min'] = $max_value_min;
$data['max'.$series_suffix]['max'] = $max_value_max;
$data['max'.$series_suffix]['avg'] = ($sum_data_max / $count_data_total);
}
$data['sum'.$series_suffix]['min'] = $avg_value_min;
$data['sum'.$series_suffix]['max'] = $avg_value_max;
$data['sum'.$series_suffix]['avg'] = ($sum_data_avg / $count_data_total);
if ($type_mode_graph <= 1) {
$data['sum'.$series_suffix]['min'] = $avg_value_min;
$data['sum'.$series_suffix]['max'] = $avg_value_max;
$data['sum'.$series_suffix]['avg'] = ($sum_data_avg / $count_data_total);
}
}
} else {
foreach ($data_uncompress as $k) {
@ -4543,20 +4602,28 @@ function fullscale_data(
$last_data,
];
} else {
$data['sum'.$series_suffix]['data'][] = [
($date_array['final_date'] * 1000),
$last_data,
];
if ($type_mode_graph <= 1) {
$data['sum'.$series_suffix]['data'][] = [
($date_array['final_date'] * 1000),
$last_data,
];
}
if ($data_slice) {
if ($type_mode_graph && !$params['baseline']) {
$data['min'.$series_suffix]['data'][] = [
($date_array['final_date'] * 1000),
$min_value,
];
$data['max'.$series_suffix]['data'][] = [
($date_array['final_date'] * 1000),
$max_value,
];
if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 3) {
$data['min'.$series_suffix]['data'][] = [
($date_array['final_date'] * 1000),
$min_value,
];
}
if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 2) {
$data['max'.$series_suffix]['data'][] = [
($date_array['final_date'] * 1000),
$max_value,
];
}
} else {
$data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['min'] = $min_value;
$data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = 0;
@ -4975,8 +5042,20 @@ function graph_nodata_image(
$height=110,
$type='area',
$text='',
$percent=false
$percent=false,
$base64=false
) {
if ($base64 === true) {
$dataImg = file_get_contents(
html_print_image(
'images/image_problem_area.png',
false,
['style' => 'width:150px;']
)
);
return base64_encode($dataImg);
}
$image = ui_get_full_url(
'images/image_problem_area.png',
false,

View File

@ -3684,17 +3684,24 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
$return['failed'] = null;
$return['data'] = [];
if (is_metaconsole()) {
if (is_metaconsole() === true) {
metaconsole_restore_db();
$server_names = metaconsole_get_connection_names();
if (isset($server_names) && is_array($server_names)) {
if (isset($server_names) === true
&& is_array($server_names) === true
) {
foreach ($server_names as $key => $value) {
$id_meta = metaconsole_get_id_server($value);
$connection = metaconsole_get_connection_by_id($id_meta);
if (metaconsole_connect($connection) != NOERR) {
continue;
} else {
$network_interfaces_by_agents = agents_get_network_interfaces(false, $filter);
$network_interfaces_by_agents = agents_get_network_interfaces(
false,
$filter
);
$return = agents_get_network_interfaces_array(
$network_interfaces_by_agents,
$return,
@ -3737,81 +3744,90 @@ function agents_get_network_interfaces_array(
$pdf,
$id_meta
) {
if (empty($network_interfaces_by_agents)) {
$return['failed'] = __('The group has no agents or none of the agents has any network interface');
global $config;
if (empty($network_interfaces_by_agents) === true
&& is_metaconsole() === false
) {
$return['failed'] = __(
'The group has no agents or none of the agents has any network interface'
);
$return['data'] = [];
} else {
foreach ($network_interfaces_by_agents as $agent_id => $agent) {
$row_data = [];
$row_data['agent'] = $agent['name'];
$row_data['interfaces'] = [];
foreach ($agent['interfaces'] as $interface_name => $interface) {
$row_interface = [];
$row_interface['name'] = $interface_name;
$row_interface['ip'] = $interface['ip'];
$row_interface['mac'] = $interface['mac'];
$row_interface['status'] = $interface['status_image'];
$row_interface['chart'] = null;
if (isset($network_interfaces_by_agents) === true
&& is_array($network_interfaces_by_agents) === true
) {
foreach ($network_interfaces_by_agents as $agent_id => $agent) {
$row_data = [];
$row_data['agent'] = $agent['name'];
$row_data['interfaces'] = [];
foreach ($agent['interfaces'] as $interface_name => $interface) {
$row_interface = [];
$row_interface['name'] = $interface_name;
$row_interface['ip'] = $interface['ip'];
$row_interface['mac'] = $interface['mac'];
$row_interface['status'] = $interface['status_image'];
$row_interface['chart'] = null;
$width = null;
$params = [
'period' => $content['period'],
'unit_name' => array_fill(0, count($interface['traffic']), __('bytes/s')),
'date' => $report['datetime'],
'only_image' => $pdf,
'homeurl' => $config['homeurl'],
'fullscale' => $fullscale,
'server_id' => $id_meta,
'height' => $config['graph_image_height'],
'landscape' => $content['landscape'],
'return_img_base_64' => true,
'graph_render' => $content['graph_render'],
];
$params = [
'period' => $content['period'],
'width' => $width,
'unit_name' => array_fill(0, count($interface['traffic']), __('bytes/s')),
'date' => $report['datetime'],
'only_image' => $pdf,
'homeurl' => $config['homeurl'],
'fullscale' => $fullscale,
'server_id' => $id_meta,
'height' => $config['graph_image_height'],
'landscape' => $content['landscape'],
'return_img_base_64' => true,
];
$params_combined = [
'labels' => array_keys($interface['traffic']),
'modules_series' => array_values($interface['traffic']),
'stacked' => CUSTOM_GRAPH_LINE,
];
$params_combined = [
'labels' => array_keys($interface['traffic']),
'modules_series' => array_values($interface['traffic']),
];
switch ($type) {
case 'dinamic':
case 'static':
if (!empty($interface['traffic'])) {
if ($pdf === false) {
$row_interface['chart'] = graphic_combined_module(
array_values($interface['traffic']),
$params,
$params_combined
);
} else {
$row_interface['chart'] = '<img src="data:image/jpg;base64,';
$row_interface['chart'] .= graphic_combined_module(
array_values($interface['traffic']),
$params,
$params_combined
);
$row_interface['chart'] .= '" />';
}
}
break;
switch ($type) {
case 'dinamic':
case 'static':
if (!empty($interface['traffic'])) {
if ($pdf === false) {
case 'data':
if (!empty($interface['traffic'])) {
$params['return_data'] = true;
$row_interface['chart'] = graphic_combined_module(
array_values($interface['traffic']),
$params,
$params_combined
);
} else {
$row_interface['chart'] = '<img src="data:image/jpg;base64,';
$row_interface['chart'] .= graphic_combined_module(
array_values($interface['traffic']),
$params,
$params_combined
);
$row_interface['chart'] .= '" />';
}
}
break;
break;
}
case 'data':
if (!empty($interface['traffic'])) {
$params['return_data'] = true;
$row_interface['chart'] = graphic_combined_module(
array_values($interface['traffic']),
$params,
$params_combined
);
}
break;
$row_data['interfaces'][] = $row_interface;
}
$row_data['interfaces'][] = $row_interface;
$return['data'][] = $row_data;
}
$return['data'][] = $row_data;
}
}
@ -8435,6 +8451,7 @@ function reporting_simple_graph(
'landscape' => $content['landscape'],
'backgroundColor' => 'transparent',
'return_img_base_64' => true,
'graph_render' => $content['graph_render'],
];
if ($only_image === false) {

View File

@ -2516,7 +2516,7 @@ function reporting_html_group_configuration($table, $item, $pdf=0)
function reporting_html_network_interfaces_report($table, $item, $pdf=0)
{
$return_pdf = '';
if (!empty($item['failed'])) {
if (empty($item['failed']) === false) {
if ($pdf === 0) {
$table->colspan['interfaces']['cell'] = 3;
$table->cellstyle['interfaces']['cell'] = 'text-align: left;';
@ -5120,7 +5120,7 @@ function reporting_get_last_activity()
function reporting_get_event_histogram($events, $text_header_event=false)
{
global $config;
if (!defined('METACONSOLE')) {
if (!is_metaconsole()) {
include_once $config['homedir'].'/include/graphs/functions_gd.php';
} else {
include_once '../../include/graphs/functions_gd.php';
@ -5128,7 +5128,7 @@ function reporting_get_event_histogram($events, $text_header_event=false)
$max_value = count($events);
if (defined('METACONSOLE')) {
if (is_metaconsole()) {
$max_value = SECONDS_1HOUR;
}
@ -5149,7 +5149,7 @@ function reporting_get_event_histogram($events, $text_header_event=false)
EVENT_CRIT_CRITICAL => COL_CRITICAL,
];
if (defined('METACONSOLE')) {
if (is_metaconsole()) {
$full_legend = [];
$cont = 0;
}
@ -5193,7 +5193,7 @@ function reporting_get_event_histogram($events, $text_header_event=false)
break;
}
if (defined('METACONSOLE')) {
if (is_metaconsole()) {
$full_legend[$cont] = $data['timestamp'];
$graph_data[] = [
'data' => $color,
@ -5212,17 +5212,18 @@ function reporting_get_event_histogram($events, $text_header_event=false)
$table->width = '100%';
$table->data = [];
$table->size = [];
$table->size[0] = '100%';
$table->head = [];
$table->title = '<span>'.$text_header_event.'</span>';
$table->data[0][0] = '';
if (!empty($graph_data)) {
$url_slice = defined('METACONSOLE') ? $url : $urlImage;
if (empty($graph_data) === false) {
$url_slice = is_metaconsole() ? $url : $urlImage;
$slicebar = flot_slicesbar_graph(
$graph_data,
$max_value,
100,
'450px;border:0',
25,
$full_legend,
$colors,
@ -5235,8 +5236,8 @@ function reporting_get_event_histogram($events, $text_header_event=false)
0,
[],
true,
$ttl,
true,
1,
false,
false
);
@ -5245,7 +5246,7 @@ function reporting_get_event_histogram($events, $text_header_event=false)
$table->data[0][0] = __('No events');
}
if (!defined('METACONSOLE')) {
if (!is_metaconsole()) {
if (!$text_header_event) {
$event_graph = '<fieldset class="databox tactical_set">
<legend>'.$text_header_event.'</legend>'.html_print_table($table, true).'</fieldset>';

View File

@ -2469,7 +2469,9 @@ function pandoraFlotArea(
});
label_aux =
legend[series.label].split(":")[0] + data_legend[series.label];
legend[series.label].split(": Min")[0] +
": " +
data_legend[series.label];
$("#legend_" + graph_id + " .legendLabel")
.eq(i)
.html(label_aux);

View File

@ -8,7 +8,7 @@ div#bullets_modules span {
}
table#agent_interface_info .noresizevc.graph {
width: 500px;
margin-bottom: 10px;
}
div.agent_details_agent_alias {

View File

@ -3077,6 +3077,7 @@ div.nodata_container {
display: table;
}
div#stat-win-interface-graph div.nodata_container,
div#stat-win-module-graph div.nodata_container {
width: 30%;
height: 100%;

View File

@ -215,8 +215,6 @@ class Agent
$status_chart_width = 160;
$graph_width = 160;
hd($this->agent, true);
$html = '<div class="agent_graphs">';
$html .= '<b>'.__('Modules by status').'</b>';
$html .= '<div id="status_pie" style="margin: auto; width: '.$status_chart_width.'px; margin-bottom: 10px;">';

View File

@ -32,7 +32,6 @@ global $config;
require_once 'include/functions_agents.php';
require_once $config['homedir'].'/include/functions_graph.php';
include_graphs_dependencies();
require_once $config['homedir'].'/include/functions_groups.php';
require_once $config['homedir'].'/include/functions_ui.php';
require_once $config['homedir'].'/include/functions_incidents.php';
@ -611,7 +610,7 @@ if (!empty($network_interfaces)) {
$table_interface->style = [];
$table_interface->style['interface_status'] = 'width: 30px;padding-top:0px;padding-bottom:0px;';
$table_interface->style['interface_graph'] = 'width: 20px;padding-top:0px;padding-bottom:0px;';
$table_interface->style['interface_event_graph'] = 'width: 100%;padding-top:0px;padding-bottom:0px;';
$table_interface->style['interface_event_graph'] = 'width: 35%;padding-top:0px;padding-bottom:0px;';
$table_interface->align['interface_event_graph'] = 'right';
// $table_interface->style['interface_event_graph'] = 'width: 5%;padding-top:0px;padding-bottom:0px;';
$table_interface->align['interface_event_graph_text'] = 'left';
@ -619,7 +618,7 @@ if (!empty($network_interfaces)) {
$table_interface->align['interface_name'] = 'left';
$table_interface->align['interface_ip'] = 'left';
$table_interface->align['last_contact'] = 'left';
$table_interface->style['last_contact'] = 'width: 40%;padding-top:0px;padding-bottom:0px;';
$table_interface->style['last_contact'] = 'width: 20%;padding-top:0px;padding-bottom:0px;';
$table_interface->style['interface_ip'] = 'width: 8%;padding-top:0px;padding-bottom:0px;';
$table_interface->style['interface_mac'] = 'width: 12%;padding-top:0px;padding-bottom:0px;';
@ -729,9 +728,15 @@ if (!empty($network_interfaces)) {
$text_event_header = __('Events info (24hr.)');
if (!$events) {
$no_events = ['color' => ['criticity' => 2]];
$e_graph = reporting_get_event_histogram($no_events, $text_event_header);
$e_graph = reporting_get_event_histogram(
$no_events,
$text_event_header
);
} else {
$e_graph = reporting_get_event_histogram($events, $text_event_header);
$e_graph = reporting_get_event_histogram(
$events,
$text_event_header
);
}
$data = [];
@ -865,6 +870,9 @@ echo $agent_incidents;
if (isset($table_interface)) {
ui_toggle(
html_print_table($table_interface, true),
'<b>'.__('Interface information (SNMP)').'</b>'
'<b>'.__('Interface information (SNMP)').'</b>',
'',
'interface-table-status-agent',
true
);
}

View File

@ -302,7 +302,7 @@ html_print_div(
);
// Graph.
echo '<div>';
echo '<div id="stat-win-interface-graph">';
$height = 280;
$width = '90%';

View File

@ -1544,6 +1544,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`landscape` tinyint(1) UNSIGNED NOT NULL default 0,
`pagebreak` tinyint(1) UNSIGNED NOT NULL default 0,
`compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0,
`graph_render` tinyint(1) UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE
@ -3123,6 +3124,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`landscape` tinyint(1) UNSIGNED NOT NULL default 0,
`pagebreak` tinyint(1) UNSIGNED NOT NULL default 0,
`compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0,
`graph_render` tinyint(1) UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id_rc`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;

View File

@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''),
('custom_report_front_footer', ''),
('MR', 41),
('MR', 42),
('identification_reminder', 1),
('identification_reminder_timestamp', 0),
('current_package_enterprise', '749'),
('current_package_enterprise', 750),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'),