2012-03-01 17:41:02 +01:00
|
|
|
<?PHP
|
|
|
|
|
|
|
|
// Copyright (c) 2007-2008 Sancho Lerena, slerena@gmail.com
|
|
|
|
// Copyright (c) 2008 Esteban Sanchez, estebans@artica.es
|
|
|
|
// Copyright (c) 2007-2011 Artica, info@artica.es
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public License
|
|
|
|
// (LGPL) as published by the Free Software Foundation; 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 Lesser General Public License for more details.
|
|
|
|
|
|
|
|
//JQuery 1.6.1 library addition
|
|
|
|
|
|
|
|
global $config;
|
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
|
|
|
|
function include_javascript_dependencies_flot_graph($return = false) {
|
|
|
|
global $config;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
static $is_include_javascript = false;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
if (!$is_include_javascript) {
|
|
|
|
$is_include_javascript = true;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-09-28 16:06:20 +02:00
|
|
|
$metaconsole_hack = '';
|
|
|
|
if (defined('METACONSOLE')) {
|
|
|
|
$metaconsole_hack = '../../';
|
|
|
|
}
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
// NOTE: jquery.flot.threshold is not te original file. Is patched to allow multiple thresholds and filled area
|
|
|
|
$output = '
|
2013-04-11 18:35:07 +02:00
|
|
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="' . ui_get_full_url($metaconsole_hack . '/include/graphs/flot/excanvas.js') . '"></script><![endif]-->
|
2018-02-16 13:41:31 +01:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.js') .'"></script>
|
2012-09-28 16:06:20 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
2018-01-25 13:14:21 +01:00
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.time.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
2013-02-19 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php, include/functions_agents.php,
include/functions_config.php, include/ajax/reporting.ajax.php,
include/functions_snmp_browser.php,
operation/agentes/status_monitor.php: improved code style.
* include/functions_graph.php, include/graphs/fgraph.php,
include/graphs/flot/jquery.flot.pie.js,
include/graphs/flot/jquery.flot.pie.min.js,
include/graphs/flot/pandora.flot.js,
include/graphs/functions_flot.php: fixed the pie graphs, added the
expanded version of flot pie js file with some changes for the
last version of jQuery.
Fixes: #3604555
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7675 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-02-19 11:35:04 +01:00
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.pie.js') .'"></script>
|
2012-09-28 16:06:20 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.crosshair.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.stack.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.selection.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.resize.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.threshold.js') .'"></script>
|
2018-05-10 08:43:09 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.threshold.multiple.js') .'"></script>
|
2012-09-28 16:06:20 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.symbol.min.js') .'"></script>
|
2016-09-07 13:21:27 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.exportdata.pandora.js') .'"></script>
|
2012-09-28 16:06:20 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
2016-09-12 16:22:58 +02:00
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.axislabels.js') .'"></script>
|
2018-04-27 13:51:13 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
2013-03-15 15:35:52 +01:00
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/pandora.flot.js') .'"></script>';
|
2012-03-05 20:25:02 +01:00
|
|
|
$output .= "
|
2013-03-15 15:35:52 +01:00
|
|
|
<script type='text/javascript'>
|
2016-10-18 17:02:13 +02:00
|
|
|
var precision_graph = " . $config['graph_precision'] . ";
|
2018-04-27 13:51:13 +02:00
|
|
|
function pieHover(event, pos, obj)
|
2013-03-15 15:35:52 +01:00
|
|
|
{
|
|
|
|
if (!obj)
|
|
|
|
return;
|
|
|
|
percent = parseFloat(obj.series.percent).toFixed(2);
|
|
|
|
$('#hover').html('<span style=\'font-weight: bold; color: '+obj.series.color+'\'>'+obj.series.label+' ('+percent+'%)</span>');
|
|
|
|
$('.legendLabel').each(function() {
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($(this).html() == obj.series.label) {
|
2013-03-15 15:35:52 +01:00
|
|
|
$(this).css('font-weight','bold');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$(this).css('font-weight','');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-04-27 13:51:13 +02:00
|
|
|
|
|
|
|
function pieClick(event, pos, obj)
|
2013-03-15 15:35:52 +01:00
|
|
|
{
|
|
|
|
if (!obj)
|
|
|
|
return;
|
|
|
|
percent = parseFloat(obj.series.percent).toFixed(2);
|
2013-04-10 09:57:54 +02:00
|
|
|
alert(''+obj.series.label+': '+obj.series.data[0][1]+' ('+percent+'%)');
|
2013-03-15 15:35:52 +01:00
|
|
|
}
|
|
|
|
</script>";
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
if (!$return)
|
|
|
|
echo $output;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
////////// AREA GRAPHS ////////
|
|
|
|
///////////////////////////////
|
2018-02-27 16:28:00 +01:00
|
|
|
function flot_area_graph (
|
2018-05-21 17:25:09 +02:00
|
|
|
$agent_module_id, $array_data,
|
2018-06-08 14:30:15 +02:00
|
|
|
$legend, $series_type, $color, $date_array,
|
2018-06-06 11:18:39 +02:00
|
|
|
$data_module_graph, $params, $water_mark,
|
2018-02-28 08:46:51 +01:00
|
|
|
$array_events_alerts ) {
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
global $config;
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// Get a unique identifier to graph
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
|
|
|
|
$background_style = '';
|
2018-06-06 11:18:39 +02:00
|
|
|
switch ($params['backgroundColor']) {
|
2018-02-16 13:41:31 +01:00
|
|
|
case 'white':
|
|
|
|
$background_style = ' background: #fff; ';
|
2018-06-12 12:08:04 +02:00
|
|
|
$params['grid_color'] = '#C1C1C1';
|
2018-02-16 13:41:31 +01:00
|
|
|
break;
|
|
|
|
case 'black':
|
|
|
|
$background_style = ' background: #000; ';
|
2018-06-12 12:08:04 +02:00
|
|
|
$params['grid_color'] = '#BDBDBD';
|
2018-02-16 13:41:31 +01:00
|
|
|
break;
|
|
|
|
case 'transparent':
|
|
|
|
$background_style = '';
|
2018-06-12 12:08:04 +02:00
|
|
|
$params['grid_color'] = '#A4A4A4';
|
2018-02-16 13:41:31 +01:00
|
|
|
break;
|
2018-06-06 11:18:39 +02:00
|
|
|
default:
|
|
|
|
$background_style = 'background-color: ' . $params['backgroundColor'];
|
2018-06-12 12:08:04 +02:00
|
|
|
$params['grid_color'] = '#C1C1C1';
|
2018-06-06 11:18:39 +02:00
|
|
|
break;
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
2018-09-11 11:37:11 +02:00
|
|
|
$padding_vconsole = $params['dashboard'] ? 'padding: 1px 0px 10px 10px;' : '';
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// Parent layer
|
2018-09-11 11:37:11 +02:00
|
|
|
$return = "<div class='parent_graph' style='width: " . ($params['width']) . ";" . $background_style . $padding_vconsole . "'>";
|
2018-02-16 13:41:31 +01:00
|
|
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
2018-06-06 11:18:39 +02:00
|
|
|
if($params['show_legend']){
|
2018-08-20 13:52:01 +02:00
|
|
|
$return .= "<p id='legend_$graph_id' style='text-align:left;'></p>";
|
2018-06-06 11:18:39 +02:00
|
|
|
}
|
2018-06-06 17:23:32 +02:00
|
|
|
if(isset($params['graph_combined']) && $params['graph_combined'] &&
|
|
|
|
(!isset($params['from_interface']) || !$params['from_interface']) ){
|
2018-08-09 16:33:29 +02:00
|
|
|
if( isset($params['threshold_data']) && is_array($params['threshold_data'])){
|
|
|
|
$yellow_threshold = $params['threshold_data']['yellow_threshold'];
|
|
|
|
$red_threshold = $params['threshold_data']['red_threshold'];
|
|
|
|
$yellow_up = $params['threshold_data']['yellow_up'];
|
|
|
|
$red_up = $params['threshold_data']['red_up'];
|
|
|
|
$yellow_inverse = $params['threshold_data']['yellow_inverse'];
|
|
|
|
$red_inverse = $params['threshold_data']['red_inverse'];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$yellow_up = 0;
|
|
|
|
$red_up = 0;
|
|
|
|
$yellow_inverse = false;
|
|
|
|
$red_inverse = false;
|
|
|
|
}
|
|
|
|
|
2018-06-06 17:23:32 +02:00
|
|
|
}
|
|
|
|
elseif(!isset($params['combined']) || !$params['combined']){
|
2018-05-21 17:25:09 +02:00
|
|
|
$yellow_threshold = $data_module_graph['w_min'];
|
|
|
|
$red_threshold = $data_module_graph['c_min'];
|
|
|
|
// Get other required module datas to draw warning and critical
|
|
|
|
if ($agent_module_id == 0) {
|
|
|
|
$yellow_up = 0;
|
|
|
|
$red_up = 0;
|
|
|
|
$yellow_inverse = false;
|
|
|
|
$red_inverse = false;
|
|
|
|
} else {
|
|
|
|
$yellow_up = $data_module_graph['w_max'];
|
|
|
|
$red_up = $data_module_graph['c_max'];
|
|
|
|
$yellow_inverse = !($data_module_graph['w_inv'] == 0);
|
|
|
|
$red_inverse = !($data_module_graph['c_inv'] == 0);
|
|
|
|
}
|
|
|
|
}
|
2018-05-28 17:47:40 +02:00
|
|
|
elseif(isset($params['from_interface']) && $params['from_interface']){
|
|
|
|
if( isset($params['threshold_data']) && is_array($params['threshold_data'])){
|
2018-08-09 16:33:29 +02:00
|
|
|
$yellow_threshold = $params['threshold_data']['yellow_threshold'];
|
|
|
|
$red_threshold = $params['threshold_data']['red_threshold'];
|
|
|
|
$yellow_up = $params['threshold_data']['yellow_up'];
|
|
|
|
$red_up = $params['threshold_data']['red_up'];
|
|
|
|
$yellow_inverse = $params['threshold_data']['yellow_inverse'];
|
|
|
|
$red_inverse = $params['threshold_data']['red_inverse'];
|
2018-05-21 17:25:09 +02:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
$yellow_up = 0;
|
|
|
|
$red_up = 0;
|
|
|
|
$yellow_inverse = false;
|
|
|
|
$red_inverse = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$yellow_up = 0;
|
|
|
|
$red_up = 0;
|
2018-02-27 16:28:00 +01:00
|
|
|
$yellow_inverse = false;
|
2018-05-21 17:25:09 +02:00
|
|
|
$red_inverse = false;
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-05-28 17:47:40 +02:00
|
|
|
if ($params['menu']) {
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= menu_graph(
|
2018-06-06 11:18:39 +02:00
|
|
|
$yellow_threshold,
|
|
|
|
$red_threshold,
|
|
|
|
$yellow_up,
|
|
|
|
$red_up,
|
|
|
|
$yellow_inverse,
|
|
|
|
$red_inverse,
|
|
|
|
$graph_id,
|
|
|
|
$params
|
2018-02-16 13:41:31 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$return .= html_print_input_hidden('line_width_graph', $config['custom_graph_width'], true);
|
2018-02-27 16:28:00 +01:00
|
|
|
$return .= "<div id='timestamp_$graph_id'
|
|
|
|
class='timestamp_graph'
|
2018-05-28 17:47:40 +02:00
|
|
|
style=' font-size:".$params['font_size']."pt;
|
2018-02-27 16:28:00 +01:00
|
|
|
display:none; position:absolute;
|
|
|
|
background:#fff; border: solid 1px #aaa;
|
2018-02-16 13:41:31 +01:00
|
|
|
padding: 2px; z-index:1000;'></div>";
|
|
|
|
$return .= "<div id='$graph_id' class='";
|
|
|
|
|
2018-05-28 17:47:40 +02:00
|
|
|
if($params['type'] == 'area_simple'){
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "noresizevc ";
|
|
|
|
}
|
2018-06-08 08:58:18 +02:00
|
|
|
|
2018-05-28 17:47:40 +02:00
|
|
|
$return .= "graph" .$params['adapt_key'] ."'
|
|
|
|
style=' width: ".$params['width']."px;
|
|
|
|
height: ".$params['height']."px;'></div>";
|
2018-02-16 13:41:31 +01:00
|
|
|
|
2018-05-28 17:47:40 +02:00
|
|
|
if ($params['menu']) {
|
|
|
|
$params['height'] = 100;
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-05-28 17:47:40 +02:00
|
|
|
$params['height'] = 1;
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
2018-02-23 14:31:00 +01:00
|
|
|
|
|
|
|
if (!$vconsole){
|
2018-04-27 10:03:05 +02:00
|
|
|
$return .= "<div id='overview_$graph_id' class='overview_graph'
|
2018-06-14 10:02:26 +02:00
|
|
|
style='margin:0px; margin-top:30px; margin-bottom:50px; width: ".$params['width']."; height: 200px;'></div>";
|
2018-02-23 14:31:00 +01:00
|
|
|
}
|
2018-04-24 13:19:24 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if ($water_mark != '') {
|
2018-06-07 09:15:45 +02:00
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='" . $water_mark['url'] . "'></div>";
|
2018-02-16 13:41:31 +01:00
|
|
|
$watermark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$watermark = 'false';
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($series_type as $k => $v){
|
2018-02-27 16:28:00 +01:00
|
|
|
$series_type_unique["data_" . $graph_id . "_" . $k] = $v;
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// Store data series in javascript format
|
2018-05-28 17:47:40 +02:00
|
|
|
$extra_width = (int)($params['width'] / 3);
|
2018-02-27 16:28:00 +01:00
|
|
|
$return .= "<div id='extra_$graph_id'
|
2018-05-28 17:47:40 +02:00
|
|
|
style='font-size: " . $params['font_size'] . "pt;
|
2018-02-27 16:28:00 +01:00
|
|
|
display:none; position:absolute; overflow: auto;
|
2018-05-28 17:47:40 +02:00
|
|
|
max-height: ".($params['height']+50)."px;
|
2018-02-27 16:28:00 +01:00
|
|
|
width: ".$extra_width."px;
|
|
|
|
background:#fff; padding: 2px 2px 2px 2px;
|
2018-02-16 13:41:31 +01:00
|
|
|
border: solid #000 1px;'></div>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// Trick to get translated string from javascript
|
|
|
|
$return .= html_print_input_hidden('unknown_text', __('Unknown'), true);
|
|
|
|
|
|
|
|
$values = json_encode($array_data);
|
|
|
|
$legend = json_encode($legend);
|
|
|
|
$series_type = json_encode($series_type);
|
2018-06-08 14:30:15 +02:00
|
|
|
$color = json_encode($color);
|
2018-02-16 13:41:31 +01:00
|
|
|
$date_array = json_encode($date_array);
|
2018-02-27 16:28:00 +01:00
|
|
|
$data_module_graph = json_encode($data_module_graph);
|
2018-05-28 17:47:40 +02:00
|
|
|
$params = json_encode($params);
|
2018-02-28 08:46:51 +01:00
|
|
|
$array_events_alerts = json_encode($array_events_alerts);
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// Javascript code
|
2018-05-03 13:02:17 +02:00
|
|
|
if ($font_size == '') $font_size = '\'\'';
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "<script type='text/javascript'>";
|
|
|
|
$return .= "$(document).ready( function () {";
|
2018-02-27 16:28:00 +01:00
|
|
|
$return .= "pandoraFlotArea(" .
|
2018-02-16 13:41:31 +01:00
|
|
|
"'$graph_id', \n" .
|
|
|
|
"JSON.parse('$values'), \n" .
|
|
|
|
"JSON.parse('$legend'), \n" .
|
|
|
|
"JSON.parse('$series_type'), \n" .
|
2018-06-08 14:30:15 +02:00
|
|
|
"JSON.parse('$color'), \n" .
|
2018-02-16 13:41:31 +01:00
|
|
|
"'$watermark', \n" .
|
|
|
|
"JSON.parse('$date_array'), \n" .
|
|
|
|
"JSON.parse('$data_module_graph'), \n" .
|
2018-05-28 17:47:40 +02:00
|
|
|
"JSON.parse('$params'), \n" .
|
2018-02-28 08:46:51 +01:00
|
|
|
"JSON.parse('$array_events_alerts')".
|
|
|
|
");";
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "});";
|
|
|
|
$return .= "</script>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// Parent layer
|
|
|
|
$return .= "</div>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
function menu_graph(
|
2018-02-27 16:28:00 +01:00
|
|
|
$yellow_threshold, $red_threshold,
|
|
|
|
$yellow_up, $red_up, $yellow_inverse,
|
2018-06-06 11:18:39 +02:00
|
|
|
$red_inverse, $graph_id, $params
|
2018-02-16 13:41:31 +01:00
|
|
|
){
|
|
|
|
$return = '';
|
|
|
|
$threshold = false;
|
|
|
|
if ($yellow_threshold != $yellow_up || $red_threshold != $red_up) {
|
|
|
|
$threshold = true;
|
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
if ( $params['dashboard'] == false AND $params['vconsole'] == false) {
|
|
|
|
$return .= "<div id='general_menu_$graph_id' class='menu_graph' style='
|
|
|
|
width: 20px;
|
|
|
|
height: 150px;
|
2018-05-10 08:43:09 +02:00
|
|
|
left:100%;
|
2018-02-16 13:41:31 +01:00
|
|
|
position: absolute;
|
|
|
|
top: 0px;
|
2018-06-06 11:18:39 +02:00
|
|
|
background-color: tranparent;'>";
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "<div id='menu_$graph_id' " .
|
|
|
|
"style='display: none; " .
|
|
|
|
"text-align: center;" .
|
|
|
|
"position: relative;".
|
|
|
|
"border-bottom: 0px;'>
|
2018-06-06 11:18:39 +02:00
|
|
|
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$params['homeurl']."images/zoom_cross_grey.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
|
2018-02-16 13:41:31 +01:00
|
|
|
if ($threshold) {
|
2018-06-06 11:18:39 +02:00
|
|
|
$return .= " <a href='javascript:'><img id='menu_threshold_$graph_id' src='".$params['homeurl']."images/chart_curve_threshold.png' alt='".__('Warning and Critical thresholds')."' title='".__('Warning and Critical thresholds')."'></a>";
|
|
|
|
}
|
|
|
|
if($params['show_overview']){
|
|
|
|
$return .= " <a href='javascript:'>
|
|
|
|
<img id='menu_overview_$graph_id' class='menu_overview' src='" . $params['homeurl'] . "images/chart_curve_overview.png' alt='" . __('Overview graph') . "' title='".__('Overview graph')."'></a>";
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
// Export buttons
|
2018-06-06 11:18:39 +02:00
|
|
|
if($params['show_export_csv']){
|
|
|
|
$return .= " <a href='javascript:'><img id='menu_export_csv_$graph_id' src='".$params['homeurl']."images/csv_grey.png' alt='".__('Export to CSV')."' title='".__('Export to CSV')."'></a>";
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
// Button disabled. This feature works, but seems that is not useful enough to the final users.
|
|
|
|
//$return .= " <a href='javascript:'><img id='menu_export_json_$graph_id' src='".$homeurl."images/json.png' alt='".__('Export to JSON')."' title='".__('Export to JSON')."'></a>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "</div>";
|
|
|
|
$return .= "</div>";
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
if ($params['dashboard']) {
|
|
|
|
$return .= "<div id='general_menu_$graph_id' class='menu_graph' style='
|
2018-02-16 13:41:31 +01:00
|
|
|
width: 30px;
|
|
|
|
height: 250px;
|
2018-06-06 11:18:39 +02:00
|
|
|
left: " . $params['width'] . "px;
|
2018-02-16 13:41:31 +01:00
|
|
|
position: absolute;
|
|
|
|
top: 0px;
|
|
|
|
background-color: white;'>";
|
|
|
|
|
|
|
|
$return .= "<div id='menu_$graph_id' " .
|
|
|
|
"style='display: none; " .
|
|
|
|
"text-align: center;" .
|
|
|
|
"position: relative;".
|
|
|
|
"border-bottom: 0px;'>
|
2018-06-06 11:18:39 +02:00
|
|
|
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$params['homeurl']."images/zoom_cross_grey.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "</div>";
|
|
|
|
$return .= "</div>";
|
|
|
|
}
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
///////////////////////////////
|
|
|
|
///////////////////////////////
|
|
|
|
///////////////////////////////
|
|
|
|
|
|
|
|
// Prints a FLOT pie chart
|
2013-01-30 17:29:49 +01:00
|
|
|
function flot_pie_chart ($values, $labels, $width, $height, $water_mark,
|
2016-05-26 13:47:45 +02:00
|
|
|
$font = '', $font_size = 8, $legend_position = '', $colors = '',
|
|
|
|
$hide_labels = false) {
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$series = sizeof($values);
|
2012-03-05 20:25:02 +01:00
|
|
|
if (($series != sizeof ($labels)) || ($series == 0) ) {
|
2012-03-01 17:41:02 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$graph_id = uniqid('graph_');
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2013-01-30 17:29:49 +01:00
|
|
|
switch ($legend_position) {
|
|
|
|
case 'bottom':
|
|
|
|
$height = $height + (count($values) * 24);
|
|
|
|
break;
|
|
|
|
case 'right':
|
|
|
|
default:
|
|
|
|
//TODO FOR TOP OR LEFT OR RIGHT
|
|
|
|
break;
|
|
|
|
}
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2012-03-07 12:03:22 +01:00
|
|
|
$return = "<div id='$graph_id' class='graph' style='width: ".$width."px; height: ".$height."px;'></div>";
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($water_mark != '') {
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
|
|
|
$water_mark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$water_mark = 'false';
|
|
|
|
}
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$separator = ';;::;;';
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2013-02-19 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php, include/functions_agents.php,
include/functions_config.php, include/ajax/reporting.ajax.php,
include/functions_snmp_browser.php,
operation/agentes/status_monitor.php: improved code style.
* include/functions_graph.php, include/graphs/fgraph.php,
include/graphs/flot/jquery.flot.pie.js,
include/graphs/flot/jquery.flot.pie.min.js,
include/graphs/flot/pandora.flot.js,
include/graphs/functions_flot.php: fixed the pie graphs, added the
expanded version of flot pie js file with some changes for the
last version of jQuery.
Fixes: #3604555
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7675 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-02-19 11:35:04 +01:00
|
|
|
$labels = implode($separator, $labels);
|
|
|
|
$values = implode($separator, $values);
|
2013-07-17 13:12:37 +02:00
|
|
|
if (!empty($colors)) {
|
2013-02-20 18:15:38 +01:00
|
|
|
$colors = implode($separator, $colors);
|
|
|
|
}
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2018-11-29 16:08:41 +01:00
|
|
|
include_javascript_dependencies_flot_graph();
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<script type='text/javascript'>";
|
2018-12-27 10:35:31 +01:00
|
|
|
$return .= "$(document).ready( function () {";
|
2013-01-30 17:29:49 +01:00
|
|
|
$return .= "pandoraFlotPie('$graph_id', '$values', '$labels',
|
2016-05-26 13:47:45 +02:00
|
|
|
'$series', '$width', $font_size, $water_mark, '$separator',
|
|
|
|
'$legend_position', '$height', '$colors', " . json_encode($hide_labels) . ")";
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "});";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "</script>";
|
2018-10-11 12:57:48 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2015-11-04 17:42:45 +01:00
|
|
|
// Prints a FLOT pie chart
|
2018-10-16 15:32:31 +02:00
|
|
|
function flot_custom_pie_chart ($graph_values,
|
2015-11-04 17:42:45 +01:00
|
|
|
$width, $height, $colors, $module_name_list, $long_index,
|
|
|
|
$no_data,$xaxisname, $yaxisname, $water_mark, $fontpath, $font_size,
|
|
|
|
$unit, $ttl, $homeurl, $background_color, $legend_position) {
|
|
|
|
|
2016-10-18 10:32:10 +02:00
|
|
|
global $config;
|
2015-11-04 17:42:45 +01:00
|
|
|
///TODO
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2015-11-04 17:42:45 +01:00
|
|
|
|
|
|
|
$total_modules = $graph_values['total_modules'];
|
|
|
|
unset($graph_values['total_modules']);
|
|
|
|
|
|
|
|
foreach ($graph_values as $label => $value) {
|
2015-11-27 11:50:53 +01:00
|
|
|
if ($value['value']) {
|
|
|
|
if ($value['value'] > 1000000)
|
2016-10-20 10:47:12 +02:00
|
|
|
$legendvalue = sprintf("%sM", remove_right_zeros(number_format($value['value'] / 1000000, $config['graph_precision'])));
|
2015-11-27 11:50:53 +01:00
|
|
|
else if ($value['value'] > 1000)
|
2016-10-20 10:47:12 +02:00
|
|
|
$legendvalue = sprintf("%sK", remove_right_zeros(number_format($value['value'] / 1000, $config['graph_precision'])));
|
2015-11-27 11:50:53 +01:00
|
|
|
else
|
2016-10-20 10:47:12 +02:00
|
|
|
$legendvalue = remove_right_zeros(number_format($value['value'], $config['graph_precision']));
|
2015-11-27 11:50:53 +01:00
|
|
|
}
|
2015-11-25 14:25:19 +01:00
|
|
|
else
|
2015-11-27 11:50:53 +01:00
|
|
|
$legendvalue = __('No data');
|
2015-11-04 17:42:45 +01:00
|
|
|
$values[] = $value['value'];
|
|
|
|
$legend[] = $label .": " . $legendvalue . " " .$value['unit'];
|
|
|
|
$labels[] = $label;
|
|
|
|
}
|
|
|
|
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
|
2017-03-22 10:10:56 +01:00
|
|
|
$return = "<div id='$graph_id' class='graph noresizevc' style='width: ".$width."px; height: ".$height."px;'></div>";
|
2015-11-04 17:42:45 +01:00
|
|
|
|
|
|
|
if ($water_mark != '') {
|
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='".$water_mark["url"]."'></div>";
|
|
|
|
$water_mark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$water_mark = 'false';
|
|
|
|
}
|
|
|
|
|
|
|
|
$separator = ';;::;;';
|
|
|
|
|
|
|
|
$labels = implode($separator, $labels);
|
|
|
|
$legend = implode($separator, $legend);
|
|
|
|
$values = implode($separator, $values);
|
|
|
|
if (!empty($colors)) {
|
|
|
|
foreach ($colors as $color) {
|
|
|
|
$temp_colors[] = $color['color'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$colors = implode($separator, $temp_colors);
|
|
|
|
|
|
|
|
$return .= "<script type='text/javascript'>";
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "$(document).ready( function () {";
|
2015-11-04 17:42:45 +01:00
|
|
|
$return .= "pandoraFlotPieCustom('$graph_id', '$values', '$labels',
|
2016-09-08 15:44:36 +02:00
|
|
|
'$width', $font_size, '$fontpath', $water_mark,
|
2017-10-09 12:03:19 +02:00
|
|
|
'$separator', '$legend_position', '$height', '$colors','$legend','$background_color')";
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "});";
|
2015-11-04 17:42:45 +01:00
|
|
|
$return .= "</script>";
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Returns a 3D column chart
|
2017-11-14 10:49:15 +01:00
|
|
|
function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = '', $font_size = 7, $background_color = "white", $tick_color = "white", $val_min=null, $val_max=null) {
|
2012-03-01 17:41:02 +01:00
|
|
|
global $config;
|
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2012-03-05 20:25:02 +01:00
|
|
|
|
|
|
|
$return = '';
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$stacked_str = '';
|
|
|
|
$multicolor = true;
|
|
|
|
|
|
|
|
// Get a unique identifier to graph
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
$graph_id2 = uniqid('graph_');
|
|
|
|
|
|
|
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
2015-11-04 17:42:45 +01:00
|
|
|
$return .= "<div id='$graph_id' class='graph' style='width: ".$width."px; height: ".$height."px; padding-left: 20px;'></div>";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='value_$graph_id' style='display:none; position:absolute; background:#fff; border: solid 1px #aaa; padding: 2px'></div>";
|
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
if ($water_mark != '') {
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
|
|
|
$watermark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$watermark = 'false';
|
|
|
|
}
|
|
|
|
|
2014-12-11 13:48:25 +01:00
|
|
|
// Set a weird separator to serialize and unserialize passing data
|
|
|
|
// from php to javascript
|
2012-03-01 17:41:02 +01:00
|
|
|
$separator = ';;::;;';
|
|
|
|
$separator2 = ':,:,,,:,:';
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Transform data from our format to library format
|
|
|
|
$labels = array();
|
|
|
|
$a = array();
|
|
|
|
$vars = array();
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2017-11-08 16:41:23 +01:00
|
|
|
$max = PHP_INT_MIN+1;
|
|
|
|
$min = PHP_INT_MAX-1;
|
2012-03-01 17:41:02 +01:00
|
|
|
$i = count($graph_data);
|
2014-07-24 Miguel de Dios <miguel.dedios@artica.es>
* operation/snmpconsole/snmp_view.php,
operation/events/events_list.php, operation/incidents/incident.php,
extensions/files_repo.php,
extensions/files_repo/sql/files_repo.postgreSQL.sql,
extensions/files_repo/functions_files_repo.php,
extensions/files_repo/files_repo_list.php,
godmode/agentes/modificar_agente.php,
godmode/snmpconsole/snmp_alert.php, godmode/db/db_info.php,
include/functions_graph.php, include/functions_db.php,
include/db/postgresql.php, include/db/oracle.php,
include/db/mysql.php, include/functions_update_manager.php,
include/functions_events.php, include/graphs/functions_flot.php,
include/graphs/fgraph.php: tiny fixes for the improve the support of
postgreSQL databases.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10354 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2014-07-24 18:02:06 +02:00
|
|
|
$data = array();
|
2015-10-08 16:26:27 +02:00
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
foreach ($graph_data as $label => $values) {
|
2018-03-21 13:40:15 +01:00
|
|
|
$labels[] = io_safe_output($label);
|
2012-03-01 17:41:02 +01:00
|
|
|
$i--;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
|
|
|
foreach ($values as $key => $value) {
|
2014-12-11 13:48:25 +01:00
|
|
|
$jsvar = "data_" . $graph_id . "_" . $key;
|
2012-03-01 17:41:02 +01:00
|
|
|
|
2015-10-08 16:26:27 +02:00
|
|
|
$data[$jsvar][] = $value;
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($value > $max) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = $value;
|
|
|
|
}
|
2017-11-08 16:41:23 +01:00
|
|
|
|
|
|
|
if ($value < $min) {
|
|
|
|
$min = $value;
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
}
|
|
|
|
}
|
2015-10-08 16:26:27 +02:00
|
|
|
|
2017-11-08 16:41:23 +01:00
|
|
|
if (!is_numeric($val_min)) {
|
|
|
|
$val_min = $min;
|
|
|
|
}
|
|
|
|
if (!is_numeric($val_max)) {
|
|
|
|
$val_max = $max;
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
// Store serialized data to use it from javascript
|
|
|
|
$labels = implode($separator,$labels);
|
|
|
|
|
|
|
|
// Store data series in javascript format
|
|
|
|
$jsvars = '';
|
|
|
|
$jsseries = array();
|
|
|
|
|
|
|
|
$i = 0;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2 = array();
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
|
|
|
foreach ($data as $jsvar => $values) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2[] = implode($separator,$values);
|
|
|
|
}
|
|
|
|
|
|
|
|
$values = implode($separator2, $values2);
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$jsseries = implode(',', $jsseries);
|
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Javascript code
|
|
|
|
$return .= "<script type='text/javascript'>";
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "$(document).ready( function () {";
|
2014-12-11 13:48:25 +01:00
|
|
|
$return .= "pandoraFlotHBars('$graph_id', '$values', '$labels',
|
2017-11-14 10:49:15 +01:00
|
|
|
false, $max, '$water_mark', '$separator', '$separator2', '$font', $font_size, '$background_color', '$tick_color', $val_min, $val_max)";
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "});";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "</script>";
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
return $return;
|
2012-03-01 17:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns a 3D column chart
|
2017-11-08 09:55:36 +01:00
|
|
|
function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $font, $font_size, $from_ux, $from_wux, $background_color = 'white', $tick_color = 'white') {
|
2012-03-01 17:41:02 +01:00
|
|
|
global $config;
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$stacked_str = '';
|
|
|
|
$multicolor = false;
|
|
|
|
|
|
|
|
// Get a unique identifier to graph
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
$graph_id2 = uniqid('graph_');
|
2014-06-11 13:34:27 +02:00
|
|
|
|
|
|
|
if ($width != 'auto') {
|
|
|
|
$width = $width . "px";
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
2015-11-04 17:42:45 +01:00
|
|
|
$return .= "<div id='$graph_id' class='graph $adapt_key' style='width: ".$width."; height: ".$height."px; padding-left: 20px;'></div>";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='value_$graph_id' style='display:none; position:absolute; background:#fff; border: solid 1px #aaa; padding: 2px'></div>";
|
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
if ($water_mark != '') {
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
|
|
|
$watermark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$watermark = 'false';
|
|
|
|
}
|
|
|
|
|
2016-06-08 15:48:47 +02:00
|
|
|
$colors = array_map(function ($elem) {
|
|
|
|
return $elem['color'] ? $elem['color'] : null;
|
|
|
|
}, $color);
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Set a weird separator to serialize and unserialize passing data from php to javascript
|
|
|
|
$separator = ';;::;;';
|
|
|
|
$separator2 = ':,:,,,:,:';
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Transform data from our format to library format
|
|
|
|
$labels = array();
|
|
|
|
$a = array();
|
|
|
|
$vars = array();
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = 0;
|
|
|
|
$i = count($graph_data);
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
foreach ($graph_data as $label => $values) {
|
2017-12-13 17:17:45 +01:00
|
|
|
$labels[] = $label;
|
2012-03-01 17:41:02 +01:00
|
|
|
$i--;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
|
|
|
foreach ($values as $key => $value) {
|
2015-11-04 17:42:45 +01:00
|
|
|
$jsvar = "data_" . $graph_id . "_" . $key;
|
|
|
|
|
|
|
|
$data[$jsvar][] = $value;
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
if ($value > $max) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store serialized data to use it from javascript
|
|
|
|
$labels = implode($separator,$labels);
|
2012-03-06 18:23:46 +01:00
|
|
|
$colors = implode($separator, $colors);
|
2017-01-23 17:55:27 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Store data series in javascript format
|
|
|
|
$jsvars = '';
|
|
|
|
$jsseries = array();
|
|
|
|
|
|
|
|
$i = 0;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2 = array();
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
foreach ($data as $jsvar => $values) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2[] = implode($separator,$values);
|
|
|
|
}
|
|
|
|
|
|
|
|
$values = implode($separator2, $values2);
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$jsseries = implode(',', $jsseries);
|
2012-03-07 12:03:22 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Javascript code
|
|
|
|
$return .= "<script type='text/javascript'>";
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "$(document).ready( function () {";
|
2017-01-23 17:55:27 +01:00
|
|
|
if ($from_ux) {
|
2017-08-17 18:38:12 +02:00
|
|
|
if($from_wux){
|
2017-11-08 09:55:36 +01:00
|
|
|
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true, '$background_color', '$tick_color')";
|
2017-08-17 18:38:12 +02:00
|
|
|
}
|
|
|
|
else{
|
2017-11-08 09:55:36 +01:00
|
|
|
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, false, '$background_color', '$tick_color')";
|
2017-08-17 18:38:12 +02:00
|
|
|
}
|
2017-01-23 17:55:27 +01:00
|
|
|
}
|
|
|
|
else {
|
2017-11-08 09:55:36 +01:00
|
|
|
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false, '$background_color', '$tick_color')";
|
2017-01-23 17:55:27 +01:00
|
|
|
}
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "});";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "</script>";
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
return $return;
|
2012-03-01 17:41:02 +01:00
|
|
|
}
|
|
|
|
|
2018-10-19 10:04:26 +02:00
|
|
|
function flot_slicesbar_graph (
|
|
|
|
$graph_data, $period, $width,
|
|
|
|
$height, $legend, $colors, $fontpath,
|
|
|
|
$round_corner, $homeurl, $watermark = '',
|
|
|
|
$adapt_key = '', $stat_win = false,
|
|
|
|
$id_agent = 0, $full_legend_date = array(),
|
2018-10-29 18:20:56 +01:00
|
|
|
$not_interactive = 0, $ttl = 1,
|
2018-11-29 17:00:55 +01:00
|
|
|
$widgets = false, $show = true) {
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
global $config;
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2018-10-19 10:49:13 +02:00
|
|
|
if($ttl == 2){
|
|
|
|
$params = array(
|
|
|
|
'graph_data' => $graph_data,
|
|
|
|
'period' => $period,
|
|
|
|
'width' => $width,
|
|
|
|
'height' => $height,
|
|
|
|
'legend' => $legend,
|
|
|
|
'colors' => $colors,
|
|
|
|
'fontpath' => $fontpath,
|
|
|
|
'round_corner' => $round_corner,
|
|
|
|
'homeurl' => $homeurl,
|
2018-12-04 10:19:26 +01:00
|
|
|
'watermark' => $watermark,
|
|
|
|
'adapt_key' => $adapt_key,
|
|
|
|
'stat_win' => $stat_win,
|
|
|
|
'id_agent' => $id_agent,
|
|
|
|
'full_legend_date' => $full_legend_date,
|
|
|
|
'not_interactive' => $not_interactive,
|
|
|
|
'ttl' => 1,
|
|
|
|
'widgets' => $widgets,
|
|
|
|
'show' => $show
|
2018-10-19 10:49:13 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return generator_chart_to_pdf('slicebar', $params);
|
|
|
|
}
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Get a unique identifier to graph
|
|
|
|
$graph_id = uniqid('graph_');
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
2015-12-31 12:04:23 +01:00
|
|
|
if ($stat_win) {
|
2018-05-10 08:43:09 +02:00
|
|
|
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width."%; height: ".$height."px; display: inline-block;'></div>";
|
2015-12-31 12:04:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-10-29 18:20:56 +01:00
|
|
|
if($widgets){
|
|
|
|
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width."px; height: ".$height."px;'></div>";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width."%; height: ".$height."px;'></div>";
|
|
|
|
}
|
2015-12-31 12:04:23 +01:00
|
|
|
}
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='value_$graph_id' style='display:none; position:absolute; background:#fff; border: solid 1px #aaa; padding: 2px'></div>";
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Set a weird separator to serialize and unserialize passing data from php to javascript
|
|
|
|
$separator = ';;::;;';
|
|
|
|
$separator2 = ':,:,,,:,:';
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Transform data from our format to library format
|
|
|
|
$labels = array();
|
|
|
|
$a = array();
|
|
|
|
$vars = array();
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$datacolor = array();
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = 0;
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$i = count($graph_data);
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$intervaltick = $period / $i;
|
2018-10-16 15:32:31 +02:00
|
|
|
|
|
|
|
$fontsize = $config['font_size'];
|
|
|
|
$fontpath = $config['fontpath'];
|
|
|
|
|
2012-03-08 13:32:59 +01:00
|
|
|
$extra_height = 15;
|
2015-03-30 10:17:35 +02:00
|
|
|
if (defined("METACONSOLE"))
|
|
|
|
$extra_height = 20;
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-08 13:32:59 +01:00
|
|
|
$return .= "<div id='extra_$graph_id' style='font-size: ".$fontsize."pt; display:none; position:absolute; overflow: auto; height: ".$extra_height."px; background:#fff; padding: 2px 2px 2px 2px; border: solid #000 1px;'></div>";
|
2018-10-16 15:32:31 +02:00
|
|
|
|
|
|
|
$maxticks = (int) 20;
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$i_aux = $i;
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
while(1) {
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($i_aux <= $maxticks ) {
|
2012-03-01 17:41:02 +01:00
|
|
|
break;
|
|
|
|
}
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$intervaltick*= 2;
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$i_aux /= 2;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
}
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$intervaltick = (int) $intervaltick;
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$acumulate = 0;
|
|
|
|
$c = 0;
|
|
|
|
$acumulate_data = array();
|
2013-07-17 13:12:37 +02:00
|
|
|
foreach ($graph_data as $label => $values) {
|
2017-12-13 17:17:45 +01:00
|
|
|
$labels[] = $label;
|
2012-03-01 17:41:02 +01:00
|
|
|
$i--;
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2013-07-17 13:12:37 +02:00
|
|
|
foreach ($values as $key => $value) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$jsvar = "d_".$graph_id."_".$i;
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($key == 'data') {
|
2012-03-01 17:41:02 +01:00
|
|
|
$datacolor[$jsvar] = $colors[$value];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$data[$jsvar][] = $value;
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$acumulate_data[$c] = $acumulate;
|
|
|
|
$acumulate += $value;
|
|
|
|
$c++;
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($value > $max) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-16 15:32:31 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Store serialized data to use it from javascript
|
|
|
|
$labels = implode($separator,$labels);
|
|
|
|
$datacolor = implode($separator,$datacolor);
|
2018-10-16 15:32:31 +02:00
|
|
|
if(is_array($legend)){
|
|
|
|
$legend = io_safe_output(implode($separator,$legend));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($full_legend_date) && count($full_legend_date) > 0 ) {
|
2017-07-10 16:22:41 +02:00
|
|
|
$full_legend_date = io_safe_output(implode($separator,$full_legend_date));
|
|
|
|
}
|
2017-07-24 16:34:22 +02:00
|
|
|
else {
|
|
|
|
$full_legend_date = false;
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
$acumulate_data = io_safe_output(implode($separator,$acumulate_data));
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Store data series in javascript format
|
|
|
|
$jsvars = '';
|
|
|
|
$jsseries = array();
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$date = get_system_time ();
|
|
|
|
$datelimit = ($date - $period) * 1000;
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$i = 0;
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2 = array();
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
foreach ($data as $jsvar => $values) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2[] = implode($separator,$values);
|
|
|
|
$i ++;
|
|
|
|
}
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
$values = implode($separator2, $values2);
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Javascript code
|
|
|
|
$return .= "<script type='text/javascript'>";
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
$return .= "//<![CDATA[\n";
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "$(document).ready( function () {";
|
2018-11-29 17:00:55 +01:00
|
|
|
$return .= "pandoraFlotSlicebar('$graph_id','$values','$datacolor','$labels','$legend','$acumulate_data',$intervaltick,'$fontpath',$fontsize,'$separator','$separator2',$id_agent,'$full_legend_date',$not_interactive, '$show')";
|
2018-12-17 11:24:44 +01:00
|
|
|
$return .= "});";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "\n//]]>";
|
|
|
|
$return .= "</script>";
|
2018-10-19 10:04:26 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
return $return;
|
2012-03-01 17:41:02 +01:00
|
|
|
}
|
2013-12-12 15:49:36 +01:00
|
|
|
?>
|