fix visual windows charts

This commit is contained in:
daniel 2020-10-01 15:29:54 +02:00 committed by Daniel Rodriguez
parent 43b02efa4e
commit 0db539c444
13 changed files with 633 additions and 475 deletions

View File

@ -801,7 +801,7 @@ function mainAgentsModules()
echo "<td style='text-align: center;'>";
$win_handle = dechex(crc32($module_id.$module['name']));
$graph_type = return_graphtype(modules_get_agentmodule_type($module_id));
$link = "winopeng('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module_id.'&'.'refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."')";
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module_id.'&'.'refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)";
echo '<a href="javascript:'.$link.'">';

View File

@ -1084,7 +1084,7 @@ if (check_login()) {
$draw_events = 0;
}
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&amp;".'period='.SECONDS_1DAY.'&amp;id='.$module['id_agente_modulo'].'&amp;refresh='.SECONDS_10MINUTES.'&amp;'."draw_events=$draw_events', 'day_".$win_handle."', 1000, 700)";
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&amp;".'period='.SECONDS_1DAY.'&amp;id='.$module['id_agente_modulo'].'&amp;refresh='.SECONDS_10MINUTES.'&amp;'."draw_events=$draw_events', 'day_".$win_handle."', 800, 480)";
if (!is_snapshot_data($module['datos'])) {
$data[8] .= '<a href="javascript:'.$link.'">'.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).'</a> &nbsp;&nbsp;';
}

View File

@ -4228,7 +4228,7 @@ function events_page_details($event, $server='')
$graph_params_str = http_build_query($graph_params);
$link = "winopeng('".$url.'?'.$graph_params_str."','".$win_handle."')";
$link = "winopeng_var('".$url.'?'.$graph_params_str."','".$win_handle."', 800, 480)";
$data[1] = '<a href="javascript:'.$link.'">';
$data[1] .= html_print_image('images/chart_curve.png', true);

View File

@ -267,13 +267,13 @@ function grafico_modulo_sparse_data(
|| $data_module_graph['id_module_type'] == 31
|| $data_module_graph['id_module_type'] == 100
) {
$array_data = grafico_modulo_sparse_data_chart(
$agent_module_id,
$date_array,
$data_module_graph,
$params,
$series_suffix
);
$array_data = grafico_modulo_sparse_data_chart(
$agent_module_id,
$date_array,
$data_module_graph,
$params,
$series_suffix
);
} else {
$data_slice = ($date_array['period'] / (250 * $params['zoom']) + 100);
$array_data = fullscale_data(
@ -289,6 +289,10 @@ function grafico_modulo_sparse_data(
}
}
if (empty($array_data) === true) {
return [];
}
if ($array_data === false && (!$params['graph_combined']
&& !isset($array_data['sum1']['data'][0][1]) && !$params['baseline'])
) {
@ -1005,7 +1009,7 @@ function grafico_modulo_sparse($params, $server_name='')
$return .= graph_nodata_image($params['width'], $params['height']);
}
} else {
if (!empty($array_data)) {
if (empty($array_data) === false) {
$return = area_graph(
$agent_module_id,
$array_data,
@ -4168,6 +4172,10 @@ function fullscale_data(
$data_slice
);
if ($data_uncompress === false) {
return [];
}
$data = [];
$previous_data = 0;
// Normal.
@ -4413,10 +4421,6 @@ function fullscale_data(
$data['sum'.$series_suffix]['avg'] = ($sum_data_avg / $count_data_total);
}
} else {
if ($data_uncompress === false) {
$data_uncompress = [];
}
foreach ($data_uncompress as $k) {
foreach ($k['data'] as $v) {
if (isset($v['type']) && $v['type'] == 1) {
@ -4991,7 +4995,14 @@ function graph_nodata_image(
if ($percent === true) {
$div = $image_div;
} else {
$style = 'width:'.$width.'px; height:'.$height.'px; background-color: white; margin: 0 auto;';
if (strpos($width, '%') === false) {
$width = 'width: '.$width.'px;';
} else {
$width = 'width: '.$width.';';
}
$style = $width.' height:'.$height.'px;';
$style .= ' background-color: white; margin: 0 auto;';
$div = '<div style="'.$style.'">'.$image_div.'</div>';
}

View File

@ -3456,7 +3456,7 @@ function get_module_realtime_link_graph($module)
$win_handle = 'realtime_'.dechex(crc32($module['id_agente_modulo'].$module['nombre']));
$link_button = '<a href="javascript:winopeng_var(\''.$link.'\',\''.$win_handle.'\', 850, 480)">'.html_print_image(
$link_button = '<a href="javascript:winopeng_var(\''.$link.'\',\''.$win_handle.'\', 900, 480)">'.html_print_image(
'images/realtime_shortcut.png',
true,
[

View File

@ -857,7 +857,13 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$graph_url = "$url?params=$params_encoded";
$win_handle = dechex(crc32($interface['status_module_id'].$interface_name));
$graph_link = "<a href=\"javascript:winopeng('$graph_url','$win_handle')\">".html_print_image('images/chart_curve.png', true, ['title' => __('Interface traffic')]).'</a>';
$graph_link = "<a href=\"javascript:winopeng_var('".$graph_url."','".$win_handle."', 800, 480)\">";
$graph_link .= html_print_image(
'images/chart_curve.png',
true,
['title' => __('Interface traffic')]
);
$graph_link .= '</a>';
} else {
$graph_link = '';
}

View File

@ -3030,7 +3030,7 @@ function number_format(number, force_integer, unit, short_data, divisor) {
var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
var pos = 0;
while (number >= divisor) {
while (Math.abs(number) >= divisor) {
// As long as the number can be divided by 1000 or 1024.
pos++;
number = number / divisor;

View File

@ -758,8 +758,8 @@ var TreeController = {
winopeng_var(
element.moduleGraph.url,
element.moduleGraph.handle,
1000,
650
800,
480
);
} catch (error) {
// console.log(error);

View File

@ -3077,6 +3077,18 @@ div.nodata_container {
display: table;
}
div#stat-win-module-graph div.nodata_container {
width: 30%;
height: 100%;
background-repeat: no-repeat;
background-position: center;
margin: auto auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#snmp_data {
width: 40%;
position: absolute;
@ -5478,12 +5490,7 @@ table.info_table.policy_sub_table {
* ---------------------------------------------------------------------
*/
.module_graph_menu_dropdown {
padding-top: 20px;
padding-bottom: 20px;
position: absolute;
top: 10px;
width: 100%;
z-index: 1001;
}
.module_graph_menu_content,
@ -5501,7 +5508,7 @@ table.info_table.policy_sub_table {
padding: 6px 10px;
cursor: pointer;
display: flex;
justify-content: space-between;
justify-content: flex-start;
align-items: center;
}
@ -5511,12 +5518,20 @@ table.info_table.policy_sub_table {
}
.module_graph_menu_content {
position: absolute;
left: 2.5%;
top: 41px;
z-index: 1001;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
padding: 15px;
border-top: none;
}
#stat-win-module-graph .flot-y-axis.flot-y1-axis.yAxis.y1Axis {
left: -10px !important;
}
/*
* ---------------------------------------------------------------------
* - AGENT VIEW

View File

@ -647,7 +647,7 @@ if (!empty($network_interfaces)) {
$win_handle = dechex(crc32($interface['status_module_id'].$interface_name));
$graph_link = "<a href=\"javascript:winopeng_var('operation/agentes/interface_traffic_graph_win.php?params=";
$graph_link .= $params_encoded."','";
$graph_link .= $win_handle."', 1000, 650)\">";
$graph_link .= $win_handle."', 800, 480)\">";
$graph_link .= html_print_image(
'images/chart_curve.png',
true,

View File

@ -1,18 +1,31 @@
<?php
/**
* View interfaces charts.
*
* @category View interfaces charts
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Don't start a session before this import.
// The session is configured and started inside the config process.
require_once '../../include/config.php';
require_once $config['homedir'].'/include/auth/mysql.php';
require_once $config['homedir'].'/include/functions.php';
@ -30,16 +43,18 @@ check_login();
$params_json = base64_decode((string) get_parameter('params'));
$params = json_decode($params_json, true);
// Metaconsole connection to the node
// Metaconsole connection to the node.
$server_id = (int) (isset($params['server']) ? $params['server'] : 0);
if ($config['metaconsole'] && !empty($server_id)) {
if ($config['metaconsole'] && empty($server_id) === false) {
$server = metaconsole_get_connection_by_id($server_id);
// Error connecting
// Error connecting.
if (metaconsole_connect($server) !== NOERR) {
echo '<html>';
echo '<body>';
ui_print_error_message(__('There was a problem connecting with the node'));
ui_print_error_message(
__('There was a problem connecting with the node')
);
echo '</body>';
echo '</html>';
exit;
@ -48,7 +63,9 @@ if ($config['metaconsole'] && !empty($server_id)) {
$user_language = get_user_language($config['id_user']);
if (file_exists('../../include/languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader(new CachedFileReader('../../include/languages/'.$user_language.'.mo'));
$l10n = new gettext_reader(
new CachedFileReader('../../include/languages/'.$user_language.'.mo')
);
$l10n->load_tables();
}
@ -65,59 +82,59 @@ $interface_traffic_modules = [
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
// Parsing the refresh before sending any header
$refresh = (int) get_parameter('refresh', SECONDS_5MINUTES);
// Parsing the refresh before sending any header.
$refresh = (int) get_parameter('refresh', SECONDS_5MINUTES);
if ($refresh > 0) {
$query = ui_get_url_refresh(false);
echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />';
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo __('%s Interface Graph', get_product_name()).' ('.agents_get_alias($agent_id).' - '.$interface_name; ?>)</title>
<link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" />
<link rel="stylesheet" href="../../include/styles/js/jquery-ui.min.css" type="text/css" />
<script type='text/javascript' src='../../include/javascript/pandora.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery-3.3.1.min.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery.pandora.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery-ui.min.js'></script>
<?php
require_once $config['homedir'].'/include/graphs/functions_flot.php';
echo include_javascript_dependencies_flot_graph(true, '../');
?>
<script type='text/javascript'>
<!--
window.onload = function() {
// Hack to repeat the init process to period select
var periodSelectId = $('[name="period"]').attr('class');
period_select_init(periodSelectId);
};
-->
</script>
</head>
<body style='background:#ffffff;'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo __('%s Interface Graph', get_product_name()).' ('.agents_get_alias($agent_id).' - '.$interface_name; ?>)</title>
<link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" />
<link rel="stylesheet" href="../../include/styles/js/jquery-ui.min.css" type="text/css" />
<script type='text/javascript' src='../../include/javascript/pandora.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery-3.3.1.min.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery.pandora.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery-ui.min.js'></script>
<?php
// ACL
$all_groups = agents_get_all_groups_agent($agent_id);
require_once $config['homedir'].'/include/graphs/functions_flot.php';
echo include_javascript_dependencies_flot_graph(true, '../');
?>
<script type='text/javascript'>
<!--
window.onload = function() {
// Hack to repeat the init process to period select
var periodSelectId = $('[name="period"]').attr('class');
period_select_init(periodSelectId);
};
-->
</script>
</head>
<body style='background:#ffffff;'>
<?php
// ACL.
$all_groups = agents_get_all_groups_agent($agent_id);
if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AR')) {
include $config['homedir'].'/general/noaccess.php';
exit;
}
// Get input parameters
$period = get_parameter('period', SECONDS_1DAY);
$width = (int) get_parameter('width', 555);
$height = (int) get_parameter('height', 245);
$start_date = (string) get_parameter('start_date', date('Y-m-d'));
$start_time = get_parameter('start_time', date('H:i:s'));
$zoom = (int) get_parameter('zoom', $config['zoom_graph']);
$baseline = get_parameter('baseline', 0);
$show_percentil = get_parameter('show_percentil', 0);
$fullscale = get_parameter('fullscale');
// Get input parameters.
$period = get_parameter('period', SECONDS_1DAY);
$width = (int) get_parameter('width', 555);
$height = (int) get_parameter('height', 245);
$start_date = (string) get_parameter('start_date', date('Y-m-d'));
$start_time = get_parameter('start_time', date('H:i:s'));
$zoom = (int) get_parameter('zoom', $config['zoom_graph']);
$baseline = get_parameter('baseline', 0);
$show_percentil = get_parameter('show_percentil', 0);
$fullscale = get_parameter('fullscale');
if (!isset($_GET['fullscale_sent'])) {
if (!isset($config['full_scale_option'])
if (isset($_GET['fullscale_sent']) === false) {
if (isset($config['full_scale_option']) === false
|| $config['full_scale_option'] == 0
|| $config['full_scale_option'] == 2
) {
@ -127,164 +144,222 @@ if (!isset($_GET['fullscale_sent'])) {
}
}
$date = strtotime("$start_date $start_time");
$now = time();
$date = strtotime("$start_date $start_time");
$now = time();
if ($date > $now) {
$date = $now;
}
$urlImage = ui_get_full_url(false);
$urlImage = ui_get_full_url(false);
// Graph.
echo '<div style="padding-top:80px;">';
// FORM TABLE.
$table = html_get_predefined_table('transparent', 2);
$table->width = '100%';
$table->id = 'stat_win_form_div';
$table->style[0] = 'text-align:left;';
$table->style[1] = 'text-align:left;';
$table->styleTable = 'margin-bottom: 20px;';
$table->class = 'table_modal_alternate';
$height = 400;
$width = '90%';
$data = [];
$data[0] = __('Refresh time');
$data[1] = html_print_extended_select_for_time(
'refresh',
$refresh,
'',
'',
0,
7,
true
);
$table->data[] = $data;
$table->rowclass[] = '';
$params = [
'period' => $period,
'width' => $width,
'height' => $height,
'unit_name' => array_fill(0, count($interface_traffic_modules), $config['interface_unit']),
'date' => $date,
'homeurl' => $config['homeurl'],
'percentil' => (($show_percentil) ? $config['percentil'] : null),
'fullscale' => $fullscale,
'zoom' => $zoom,
];
$data = [];
$data[0] = __('Begin date');
$data[1] = html_print_input_text(
'start_date',
substr($start_date, 0, 10),
'',
15,
255,
true
);
$data[1] .= html_print_image(
'/images/calendar_view_day.png',
true,
[
'onclick' => "scwShow(scwID('text-start_date'),this);",
'style' => 'vertical-align: bottom;',
],
false,
false,
false,
true
);
$table->data[] = $data;
$table->rowclass[] = '';
if (is_metaconsole()) {
$params['id_server'] = $server_id;
}
$data = [];
$data[0] = __('Begin time');
$data[1] = html_print_input_text('start_time', $start_time, '', 10, 10, true);
$table->data[] = $data;
$table->rowclass[] = '';
if ($config['type_interface_charts'] == 'line') {
$stacked = CUSTOM_GRAPH_LINE;
} else {
$stacked = CUSTOM_GRAPH_AREA;
}
$data = [];
$data[0] = __('Time range');
$data[1] = html_print_extended_select_for_time(
'period',
$period,
'',
'',
0,
7,
true
);
$table->data[] = $data;
$table->rowclass[] = '';
$params_combined = [
'weight_list' => [],
'projection' => false,
'labels' => array_keys($interface_traffic_modules),
'from_interface' => true,
'modules_series' => array_values($interface_traffic_modules),
'return' => 0,
'stacked' => $stacked,
];
$data = [];
$data[0] = __('Show percentil');
$data[1] = html_print_checkbox_switch(
'show_percentil',
1,
(bool) $show_percentil,
true
);
$table->data[] = $data;
$table->rowclass[] = '';
graphic_combined_module(
array_values($interface_traffic_modules),
$params,
$params_combined
);
$data = [];
$data[0] = __('Show full scale graph (TIP)').ui_print_help_tip(
__('This option may cause performance issues'),
true,
'images/tip.png',
true
);
$data[1] = html_print_checkbox_switch('fullscale', 1, (bool) $fullscale, true);
$table->data[] = $data;
$table->rowclass[] = '';
echo '</div>';
$data = [];
$data[0] = __('Zoom factor');
$options = [];
$options[$zoom] = 'x'.$zoom;
$options[1] = 'x1';
$options[2] = 'x2';
$options[3] = 'x3';
$options[4] = 'x4';
$options[5] = __('Full');
$data[1] = html_print_select(
$options,
'zoom',
$zoom,
'',
'',
0,
true,
false,
false
);
$table->data[] = $data;
$table->rowclass[] = '';
// FORM TABLE
$table = html_get_predefined_table('transparent', 2);
$table->width = '100%';
$table->id = 'stat_win_form_div';
$table->style[0] = 'text-align:left;';
$table->style[1] = 'text-align:left;';
$table->styleTable = 'margin-bottom: 20px;';
$table->class = 'table_modal_alternate';
$data = [];
$data[0] = __('Refresh time');
$data[1] = html_print_extended_select_for_time('refresh', $refresh, '', '', 0, 7, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Begin date');
$data[1] = html_print_input_text('start_date', substr($start_date, 0, 10), '', 15, 255, true);
$data[1] .= html_print_image('/images/calendar_view_day.png', true, ['onclick' => "scwShow(scwID('text-start_date'),this);", 'style' => 'vertical-align: bottom;'], false, false, false, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Begin time');
$data[1] = html_print_input_text('start_time', $start_time, '', 10, 10, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Time range');
$data[1] = html_print_extended_select_for_time('period', $period, '', '', 0, 7, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Show percentil');
$data[1] = html_print_checkbox_switch('show_percentil', 1, (bool) $show_percentil, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Show full scale graph (TIP)').ui_print_help_tip(
__('This option may cause performance issues'),
true,
'images/tip.png',
true
);
$data[1] = html_print_checkbox_switch('fullscale', 1, (bool) $fullscale, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Zoom factor');
$options = [];
$options[$zoom] = 'x'.$zoom;
$options[1] = 'x1';
$options[2] = 'x2';
$options[3] = 'x3';
$options[4] = 'x4';
$options[5] = __('Full');
$data[1] = html_print_select($options, 'zoom', $zoom, '', '', 0, true, false, false);
$table->data[] = $data;
$table->rowclass[] = '';
$form_table = html_print_table($table, true);
$form_table .= '<div style="width:100%; text-align:right;">'.html_print_submit_button(
__('Reload'),
'submit',
false,
'class="sub upd"',
true
).'</div>';
$form_table = html_print_table($table, true);
$form_table .= '<div style="width:100%; text-align:right;">'.html_print_submit_button(
__('Reload'),
'submit',
false,
'class="sub upd"',
true
).'</div>';
// Menu.
$menu_form = "<form method='get' action='interface_traffic_graph_win.php'>".html_print_input_hidden('params', base64_encode($params_json), true);
// Menu.
$menu_form = "<form method='get' action='interface_traffic_graph_win.php' style='margin-top: 10px;'>".html_print_input_hidden('params', base64_encode($params_json), true);
if (!empty($server_id)) {
$menu_form .= html_print_input_hidden('server', $server_id, true);
}
if (empty($server_id) === false) {
$menu_form .= html_print_input_hidden('server', $server_id, true);
}
echo $menu_form;
echo '<div class="module_graph_menu_dropdown">
<div id="module_graph_menu_header" class="module_graph_menu_header">
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).'
<span>'.__('Graph configuration menu').'</span>
'.html_print_image('images/config.png', true, ['float' => 'right'], false, false, true).'
</div>
<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">'.$form_table.'</div>
</div>';
echo '</form>';
echo $menu_form;
echo '<div class="module_graph_menu_dropdown">
<div id="module_graph_menu_header" class="module_graph_menu_header">
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).'
<span style="flex: 2;">'.__('Graph configuration menu').'</span></div>
<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">'.$form_table.'</div>
</div>';
echo '</form>';
// Hidden div to forced title
html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', 'hidden' => true]);
?>
// Hidden div to forced title.
html_print_div(
[
'id' => 'forced_title_layer',
'class' => 'forced_title_layer',
'hidden' => true,
]
);
// Graph.
echo '<div>';
$height = 280;
$width = '90%';
$params = [
'period' => $period,
'width' => $width,
'height' => $height,
'unit_name' => array_fill(0, count($interface_traffic_modules), $config['interface_unit']),
'date' => $date,
'homeurl' => $config['homeurl'],
'percentil' => (($show_percentil) ? $config['percentil'] : null),
'fullscale' => $fullscale,
'zoom' => $zoom,
];
if (is_metaconsole()) {
$params['id_server'] = $server_id;
}
if ($config['type_interface_charts'] == 'line') {
$stacked = CUSTOM_GRAPH_LINE;
} else {
$stacked = CUSTOM_GRAPH_AREA;
}
$params_combined = [
'weight_list' => [],
'projection' => false,
'labels' => array_keys($interface_traffic_modules),
'from_interface' => true,
'modules_series' => array_values($interface_traffic_modules),
'return' => 0,
'stacked' => $stacked,
];
graphic_combined_module(
array_values($interface_traffic_modules),
$params,
$params_combined
);
echo '</div>';
?>
</body>
</html>
<?php
// Echo the script tags of the datepicker and the timepicker
// Modify the user language cause the ui.datepicker language files use - instead _
// Modify the user language cause the ui.datepicker
// language files use - instead.
$custom_user_language = str_replace('_', '-', $user_language);
ui_require_jquery_file('ui.datepicker-'.$custom_user_language, 'include/javascript/i18n/', true);
ui_require_jquery_file(
'ui.datepicker-'.$custom_user_language,
'include/javascript/i18n/',
true
);
ui_include_time_picker(true);
?>
<script>
@ -322,7 +397,9 @@ ui_include_time_picker(true);
closeText: '<?php echo __('Close'); ?>'
});
$.datepicker.setDefaults($.datepicker.regional["<?php echo $custom_user_language; ?>"]);
$.datepicker.setDefaults(
$.datepicker.regional["<?php echo $custom_user_language; ?>"]
);
forced_title_callback();
@ -333,12 +410,14 @@ ui_include_time_picker(true);
var arrow_down = 'arrow_down_green';
if( $('.module_graph_menu_content').hasClass('module_graph_menu_content_closed')){
$('.module_graph_menu_content').show();
$('.module_graph_menu_content').removeClass('module_graph_menu_content_closed');
$('.module_graph_menu_content')
.removeClass('module_graph_menu_content_closed');
arrow.attr('src',arrow.attr('src').replace(arrow_down, arrow_up));
}
else{
$('.module_graph_menu_content').hide();
$('.module_graph_menu_content').addClass('module_graph_menu_content_closed');
$('.module_graph_menu_content')
.addClass('module_graph_menu_content_closed');
arrow.attr('src',arrow.attr('src').replace(arrow_up, arrow_down));
}
});

View File

@ -1,18 +1,31 @@
<?php
/**
* View charts.
*
* @category View charts
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Don't start a session before this import.
// The session is configured and started inside the config process.
require_once '../../include/config.php';
require_once $config['homedir'].'/include/auth/mysql.php';
require_once $config['homedir'].'/include/functions.php';
@ -22,20 +35,21 @@ require_once $config['homedir'].'/include/functions_graph.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_tags.php';
require_once $config['homedir'].'/include/php_to_js_values.php';
enterprise_include_once('include/functions_agents.php');
check_login();
// Metaconsole connection to the node
// Metaconsole connection to the node.
$server_id = (int) get_parameter('server');
if (is_metaconsole() && !empty($server_id)) {
if (is_metaconsole() === true && empty($server_id) === false) {
$server = metaconsole_get_connection_by_id($server_id);
// Error connecting
// Error connecting.
if (metaconsole_connect($server) !== NOERR) {
echo '<html>';
echo '<body>';
ui_print_error_message(__('There was a problem connecting with the node'));
ui_print_error_message(
__('There was a problem connecting with the node')
);
echo '</body>';
echo '</html>';
exit;
@ -44,30 +58,34 @@ if (is_metaconsole() && !empty($server_id)) {
$user_language = get_user_language($config['id_user']);
if (file_exists('../../include/languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader(new CachedFileReader('../../include/languages/'.$user_language.'.mo'));
$l10n = new gettext_reader(
new CachedFileReader('../../include/languages/'.$user_language.'.mo')
);
$l10n->load_tables();
}
echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css"/>';
$id = get_parameter('id');
$id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $id);
$alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent);
$label = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id);
// $agent = agents_get_agent_with_ip ("192.168.50.31");
// $label = rawurldecode(urldecode(base64_decode(get_parameter('label', ''))));
ui_require_css_file('register', 'include/styles/', true);
// Connection lost alert.
$conn_title = __('Connection with server has been lost');
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
$id = get_parameter('id');
$id_agent = db_get_value(
'id_agente',
'tagente_modulo',
'id_agente_modulo',
$id
);
$alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent);
$label = db_get_value(
'nombre',
'tagente_modulo',
'id_agente_modulo',
$id
);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
// Parsing the refresh before sending any header
// Parsing the refresh before sending any header.
$refresh = (int) get_parameter('refresh', -1);
if ($refresh > 0) {
$query = ui_get_url_refresh(false);
@ -98,22 +116,20 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.
</script>
</head>
<body style='background:#ffffff;'>
<?php
echo "<div id='dialog' title='".__('CSV Export Information')."' style='visibility:hidden;'>";
echo '<p>'.__('The CSV export has been successful.').'</p>';
echo '</div>';
// Module id
// Module id.
$id = (int) get_parameter('id', 0);
// Agent id
// Agent id.
$agent_id = (int) modules_get_agentmodule_agent($id);
if (empty($id) || empty($agent_id)) {
ui_print_error_message(__('There was a problem locating the source of the graph'));
if (empty($id) === true || empty($agent_id) === true) {
ui_print_error_message(
__('There was a problem locating the source of the graph')
);
exit;
}
// ACL
// ACL.
$all_groups = agents_get_all_groups_agent($agent_id);
if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AR')) {
include $config['homedir'].'/general/noaccess.php';
@ -138,7 +154,9 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.
$fullscale_sent = get_parameter('fullscale_sent', 0);
if (!$fullscale_sent) {
if (!isset($config['full_scale_option']) || $config['full_scale_option'] == 0) {
if (isset($config['full_scale_option']) === false
|| $config['full_scale_option'] == 0
) {
$fullscale = 0;
} else if ($config['full_scale_option'] == 1) {
$fullscale = 1;
@ -153,9 +171,6 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.
$fullscale = get_parameter('fullscale', 0);
}
// To avoid the horizontal overflow
$width -= 20;
$time_compare = false;
if ($time_compare_separated) {
@ -169,8 +184,8 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.
$width = ($width * ($zoom / 1.4));
}
// Build date
$date = strtotime("$start_date $start_time");
// Build date.
$date = strtotime($start_date.' '.$start_time);
$now = time();
if ($date > $now) {
@ -179,14 +194,222 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.
$urlImage = ui_get_full_url(false, false, false, false);
$unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $id);
$unit = db_get_value(
'unit',
'tagente_modulo',
'id_agente_modulo',
$id
);
// FORM TABLE.
$table = html_get_predefined_table('transparent', 2);
$table->width = '100%';
$table->id = 'stat_win_form_div';
$table->style[0] = 'text-align:left;';
$table->style[1] = 'text-align:left;';
$table->style[2] = 'text-align:left;font-weight: bold;';
$table->style[3] = 'text-align:left;';
$table->class = 'table_modal_alternate';
$table->data = [];
$table->data[0][0] = __('Refresh time');
$table->data[0][1] = html_print_extended_select_for_time(
'refresh',
$refresh,
'',
'',
0,
7,
true
);
$table->data[0][2] = __('Show events');
$disabled = false;
if (isset($config['event_replication']) === true) {
if ($config['event_replication']
&& !$config['show_events_in_local']
) {
$disabled = true;
}
}
$table->data[0][3] = html_print_checkbox_switch(
'draw_events',
1,
(bool) $draw_events,
true,
$disabled
);
if ($disabled) {
$table->data[1] .= ui_print_help_tip(
__("'Show events' is disabled because this %s node is set to event replication.", get_product_name()),
true
);
}
$table->data[1][0] = __('Begin date');
$table->data[1][1] = html_print_input_text(
'start_date',
$start_date,
'',
10,
20,
true
);
$table->data[1][2] = __('Show alerts');
$table->data[1][3] = html_print_checkbox_switch(
'draw_alerts',
1,
(bool) $draw_alerts,
true
);
$table->data[2][0] = __('Begin time');
$table->data[2][1] = html_print_input_text(
'start_time',
$start_time,
'',
10,
10,
true
);
$table->data[2][2] = __('Show unknown graph');
$table->data[2][3] = html_print_checkbox_switch(
'unknown_graph',
1,
(bool) $unknown_graph,
true
);
$table->data[3][0] = __('Time range');
$table->data[3][1] = html_print_extended_select_for_time(
'period',
$period,
'',
'',
0,
7,
true
);
$table->data[3][2] = __('Show full scale graph (TIP)');
$table->data[3][3] = html_print_checkbox_switch(
'fullscale',
1,
(bool) $fullscale,
true,
false
);
if (!modules_is_boolean($id)) {
$table->data[4][0] = __('Zoom');
$options = [];
$options[$zoom] = 'x'.$zoom;
$options[1] = 'x1';
$options[2] = 'x2';
$options[3] = 'x3';
$options[4] = 'x4';
$options[5] = 'x5';
$table->data[4][1] = html_print_select(
$options,
'zoom',
$zoom,
'',
'',
0,
true,
false,
false
);
$table->data[4][2] = __('Show percentil');
$table->data[4][3] = html_print_checkbox_switch(
'show_percentil',
1,
(bool) $show_percentil,
true
);
}
$table->data[5][0] = __('Time compare (Overlapped)');
$table->data[5][1] = html_print_checkbox_switch(
'time_compare_overlapped',
1,
(bool) $time_compare_overlapped,
true
);
$table->data[5][2] = __('Time compare (Separated)');
$table->data[5][3] = html_print_checkbox_switch(
'time_compare_separated',
1,
(bool) $time_compare_separated,
true
);
$form_table = html_print_table($table, true);
$form_table .= '<div style="width:100%; text-align:right; margin-top: 15px;">';
$form_table .= html_print_submit_button(
__('Reload'),
'submit',
false,
'class="sub upd"',
true
);
$form_table .= '</div>';
// Menu.
$menu_form = "<form method='get' action='stat_win.php' style='margin-top: 10px;'>";
$menu_form .= html_print_input_hidden('id', $id, true);
$menu_form .= html_print_input_hidden('label', $label, true);
if (empty($server_id) === false) {
$menu_form .= html_print_input_hidden('server', $server_id, true);
}
if (isset($_GET['type']) === true) {
$type = get_parameter_get('type');
$menu_form .= html_print_input_hidden('type', $type, true);
}
$menu_form .= '<div class="module_graph_menu_dropdown">';
$menu_form .= '<div id="module_graph_menu_header" class="module_graph_menu_header">';
$menu_form .= html_print_image(
'images/arrow_down_green.png',
true,
[
'class' => 'module_graph_menu_arrow',
'float' => 'left',
],
false,
false,
true
);
$menu_form .= '<span style="flex: 2;">';
$menu_form .= __('Graph configuration menu');
$menu_form .= '</span>';
$menu_form .= '</div>';
$menu_form .= '<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">';
$menu_form .= $form_table;
$menu_form .= '</div>';
$menu_form .= '</div>';
$menu_form .= '</form>';
echo $menu_form;
// Hidden div to forced title.
html_print_div(
[
'id' => 'forced_title_layer',
'class' => 'forced_title_layer',
'hidden' => true,
]
);
// Graph.
echo '<div style="padding-top: 60px; padding-right: 30px;">';
$width = '90%';
$height = '450';
$output = '<div id="stat-win-module-graph">';
switch ($graph_type) {
case 'boolean':
case 'sparse':
@ -209,12 +432,14 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.
'type_graph' => $config['type_module_charts'],
'fullscale' => $fullscale,
'zoom' => $zoom,
'height' => 300,
];
echo grafico_modulo_sparse($params);
echo '<br>';
$output .= grafico_modulo_sparse($params);
$output .= '<br>';
if ($show_events_graph) {
$width = '500';
echo graphic_module_events(
$height = '450';
$output .= graphic_module_events(
$id,
$width,
$height,
@ -229,200 +454,12 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.
break;
default:
echo fs_error_image('../images');
$output .= fs_error_image('../images');
break;
}
echo '</div>';
// FORM TABLE.
$table = html_get_predefined_table('transparent', 2);
$table->width = '100%';
$table->id = 'stat_win_form_div';
$table->style[0] = 'text-align:left;';
$table->style[1] = 'text-align:left;';
$table->styleTable = 'margin-bottom: 20px;';
$table->class = 'table_modal_alternate';
$data = [];
$data[0] = __('Refresh time');
$data[1] = html_print_extended_select_for_time(
'refresh',
$refresh,
'',
'',
0,
7,
true
);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Begin date');
$data[1] = html_print_input_text('start_date', $start_date, '', 10, 20, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Begin time');
$data[1] = html_print_input_text('start_time', $start_time, '', 10, 10, true);
$table->data[] = $data;
$table->rowclass[] = '';
if (!modules_is_boolean($id)) {
$data = [];
$data[0] = __('Zoom');
$options = [];
$options[$zoom] = 'x'.$zoom;
$options[1] = 'x1';
$options[2] = 'x2';
$options[3] = 'x3';
$options[4] = 'x4';
$options[5] = 'x5';
$data[1] = html_print_select($options, 'zoom', $zoom, '', '', 0, true, false, false);
$table->data[] = $data;
$table->rowclass[] = '';
}
$data = [];
$data[0] = __('Time range');
$data[1] = html_print_extended_select_for_time(
'period',
$period,
'',
'',
0,
7,
true
);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Show events');
$disabled = false;
if (isset($config['event_replication'])) {
if ($config['event_replication'] && !$config['show_events_in_local']) {
$disabled = true;
}
}
$data[1] = html_print_checkbox_switch(
'draw_events',
1,
(bool) $draw_events,
true,
$disabled
);
if ($disabled) {
$data[1] .= ui_print_help_tip(
__("'Show events' is disabled because this %s node is set to event replication.", get_product_name()),
true
);
}
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Show alerts');
$data[1] = html_print_checkbox_switch('draw_alerts', 1, (bool) $draw_alerts, true);
$table->data[] = $data;
$table->rowclass[] = '';
/*
$data = array();
$data[0] = __('Show event graph');
$data[1] = html_print_checkbox_switch ("show_events_graph", 1, (bool) $show_events_graph, true);
$table->data[] = $data;
$table->rowclass[] = '';
*/
switch ($graph_type) {
case 'boolean':
case 'sparse':
$data = [];
$data[0] = __('Show percentil');
$data[1] = html_print_checkbox_switch('show_percentil', 1, (bool) $show_percentil, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Time compare (Overlapped)');
$data[1] = html_print_checkbox_switch('time_compare_overlapped', 1, (bool) $time_compare_overlapped, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Time compare (Separated)');
$data[1] = html_print_checkbox_switch('time_compare_separated', 1, (bool) $time_compare_separated, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$data[0] = __('Show unknown graph');
$data[1] = html_print_checkbox_switch('unknown_graph', 1, (bool) $unknown_graph, true);
$table->data[] = $data;
$table->rowclass[] = '';
break;
}
$data = [];
$data[0] = __('Show full scale graph (TIP)');
$data[1] = html_print_checkbox_switch(
'fullscale',
1,
(bool) $fullscale,
true,
false
);
$table->data[] = $data;
$table->rowclass[] = '';
$form_table = html_print_table($table, true);
$form_table .= '<div style="width:100%; text-align:right;">'.html_print_submit_button(
__('Reload'),
'submit',
false,
'class="sub upd"',
true
).'</div>';
// Menu.
$menu_form = "<form method='get' action='stat_win.php'>".html_print_input_hidden('id', $id, true).html_print_input_hidden('label', $label, true);
if (!empty($server_id)) {
$menu_form .= html_print_input_hidden('server', $server_id, true);
}
if (isset($_GET['type'])) {
$type = get_parameter_get('type');
$menu_form .= html_print_input_hidden('type', $type, true);
}
echo $menu_form;
echo '<div class="module_graph_menu_dropdown">
<div id="module_graph_menu_header" class="module_graph_menu_header">
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).'
<span>'.__('Graph configuration menu').'</span>
'.html_print_image('images/config.png', true, ['float' => 'right'], false, false, true).'
</div>
<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">'.$form_table.'</div>
</div>';
echo '</form>';
// Hidden div to forced title
html_print_div(
[
'id' => 'forced_title_layer',
'class' => 'forced_title_layer',
'hidden' => true,
]
);
$output .= '</div>';
echo $output;
?>
</body>
@ -430,9 +467,14 @@ ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.
<?php
// Echo the script tags of the datepicker and the timepicker
// Modify the user language cause the ui.datepicker language files use - instead _
// Modify the user language cause
// the ui.datepicker language files use - instead.
$custom_user_language = str_replace('_', '-', $user_language);
ui_require_jquery_file('ui.datepicker-'.$custom_user_language, 'include/javascript/i18n/', true);
ui_require_jquery_file(
'ui.datepicker-'.$custom_user_language,
'include/javascript/i18n/',
true
);
ui_include_time_picker(true);
?>
@ -460,21 +502,26 @@ ui_include_time_picker(true);
closeText: '<?php echo __('Close'); ?>'
});
$.datepicker.setDefaults($.datepicker.regional["<?php echo $custom_user_language; ?>"]);
$.datepicker.setDefaults(
$.datepicker.regional["<?php echo $custom_user_language; ?>"]
);
// Menu.
$('#module_graph_menu_header').on('click', function(){
var arrow = $('#module_graph_menu_header .module_graph_menu_arrow');
var arrow_up = 'arrow_up_green';
var arrow_down = 'arrow_down_green';
if( $('.module_graph_menu_content').hasClass('module_graph_menu_content_closed')){
if( $('.module_graph_menu_content').hasClass(
'module_graph_menu_content_closed')){
$('.module_graph_menu_content').show();
$('.module_graph_menu_content').removeClass('module_graph_menu_content_closed');
$('.module_graph_menu_content').removeClass(
'module_graph_menu_content_closed');
arrow.attr('src',arrow.attr('src').replace(arrow_down, arrow_up));
}
else{
$('.module_graph_menu_content').hide();
$('.module_graph_menu_content').addClass('module_graph_menu_content_closed');
$('.module_graph_menu_content').addClass(
'module_graph_menu_content_closed');
arrow.attr('src',arrow.attr('src').replace(arrow_up, arrow_down));
}
});

View File

@ -1545,7 +1545,7 @@ if (!empty($result)) {
$graph_params_str = http_build_query($graph_params);
$link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 1000, 700)';
$link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)';
$data[8] = get_module_realtime_link_graph($row);