fixed errors in graphs

This commit is contained in:
daniel 2018-06-06 11:18:39 +02:00
parent 97aaad0b02
commit 89a481c452
15 changed files with 491 additions and 514 deletions

View File

@ -39,14 +39,40 @@ function pandora_realtime_graphs () {
$legend = '';
$long_index = array();
$no_data_image = '';
$canvas = '<div id="graph_container">';
$canvas .= '<div id="chartLegend"></div>';
$canvas .= area_graph($interactive_graph, $chart, 800, 300, $color, $legend, $long_index, $no_data_image, "", "", "",
"", '', '', '', 1, array(), array(), 0, 0, '', false, '', false);
$width = 800;
$height = 300;
$data_array['realtime']['data'][0][0] = time() - 10;
$data_array['realtime']['data'][0][1] = 0;
$data_array['realtime']['data'][1][0] = time();
$data_array['realtime']['data'][1][1] = 0;
$data_array['realtime']['color'] = 'green';
$params =array(
'agent_module_id' => false,
'period' => 300,
'width' => $width,
'height' => $height,
'unit' => $unit,
'only_image' => $only_image,
'homeurl' => $homeurl,
'type_graph' => 'area',
'font' => $config['fontpath'],
'font-size' => $config['font_size'],
'array_data_create' => $data_array,
'show_legend' => false,
'show_menu' => false
);
$canvas .= grafico_modulo_sparse($params);
$canvas .= '</div>';
echo $canvas;
$table->width = '100%';
$table->id = 'table-form';
$table->class = 'databox filters';
@ -62,7 +88,7 @@ function pandora_realtime_graphs () {
$table->style['snmp_oid'] = 'font-weight: bold;';
$table->style['snmp_oid'] = 'font-weight: bold;';
$table->data = array ();
$graph_fields['cpu_load'] = __('%s Server CPU', get_product_name());
$graph_fields['pending_packets'] = __('Pending packages from %s Server', get_product_name());
$graph_fields['disk_io_wait'] = __('%s Server Disk IO Wait', get_product_name());
@ -70,19 +96,19 @@ function pandora_realtime_graphs () {
$graph_fields['mysql_load'] = __('%s Server MySQL load', get_product_name());
$graph_fields['server_load'] = __('%s Server load', get_product_name());
$graph_fields['snmp_interface'] = __('SNMP Interface throughput');
$graph = get_parameter('graph', 'cpu_load');
$refresh = get_parameter('refresh', '1000');
if ($graph != 'snmp_module') {
$data['graph'] = __('Graph') . '&nbsp;&nbsp;' . html_print_select ($graph_fields, 'graph', $graph, '', '', 0, true);
}
$refresh_fields[1000] = human_time_description_raw(1, true, 'large');
$refresh_fields[5000] = human_time_description_raw(5, true, 'large');
$refresh_fields[1000] = human_time_description_raw(1, true, 'large');
$refresh_fields[5000] = human_time_description_raw(5, true, 'large');
$refresh_fields[10000] = human_time_description_raw(10, true, 'large');
$refresh_fields[30000] = human_time_description_raw(30, true, 'large');
if ($graph == 'snmp_module') {
$agent_alias = get_parameter('agent_alias', '');
$module_name = get_parameter('module_name', '');
@ -109,7 +135,7 @@ function pandora_realtime_graphs () {
$snmp_ver = get_parameter('snmp_ver', '');
$data = array();
$data['snmp_address'] = __('Target IP') . '&nbsp;&nbsp;' . html_print_input_text ('ip_target', $snmp_address, '', 50, 255, true);
$table->colspan[1]['snmp_address'] = 2;
@ -122,7 +148,7 @@ function pandora_realtime_graphs () {
$snmp_versions['1'] = '1';
$snmp_versions['2'] = '2';
$snmp_versions['2c'] = '2c';
$data = array();
$data['snmp_oid'] = __('OID') . '&nbsp;&nbsp;' . html_print_input_text ('snmp_oid', $snmp_oid, '', 100, 255, true);
$table->colspan[2]['snmp_oid'] = 2;
@ -140,7 +166,7 @@ function pandora_realtime_graphs () {
}
snmp_browser_print_container (false, '100%', '60%', 'none');
}
// Print the relative path to AJAX calls:
html_print_input_hidden('rel_path', get_parameter('rel_path', ''));
@ -148,7 +174,7 @@ function pandora_realtime_graphs () {
echo '<form id="realgraph" method="post">';
html_print_table($table);
echo '</form>';
// Define a custom action to save the OID selected in the SNMP browser to the form
html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/input_filter.disabled.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
html_print_input_hidden ('incremental_base', '0');
@ -156,7 +182,7 @@ function pandora_realtime_graphs () {
echo '<script type="text/javascript" src="'.ui_get_full_url("extensions/realtime_graphs/realtime_graphs.js").'"></script>';
echo '<script type="text/javascript" src="'.ui_get_full_url("include/javascript/pandora_snmp_browser.js").'"></script>';
echo '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url("extensions/realtime_graphs/realtime_graphs.css").'"></style>';
// Store servers timezone offset to be retrieved from js
set_js_value('timezone_offset', date('Z', time()));
}

View File

@ -68,11 +68,13 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph (<?php echo agents_get_alias($agent_id) . ' - ' . $interface_name; ?>)</title>
<link rel="stylesheet" href="styles/pandora.css" type="text/css" />
<link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" />
<link rel="stylesheet" href="styles/jquery-ui-1.10.0.custom.css" type="text/css" />
<script language="javascript" type='text/javascript' src='javascript/pandora.js'></script>
<script language="javascript" type='text/javascript' src='javascript/pandora.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery-1.9.0.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.pandora.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.jquery-ui-1.10.0.custom.js'></script>
@ -97,7 +99,8 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
$params = json_decode($_GET['data'], true);
//XXXXXX
$params['only_image'] = false;
$params['width'] = '1048';
$params['width'] = '1048';
$params['menu'] = false;
//cominadasssss
$params_combined = json_decode($_GET['data_combined'], true);
@ -122,4 +125,5 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
}
?>
</body>
</html>

View File

@ -3005,15 +3005,22 @@ function color_graph_array($series_suffix, $compare = false){
function series_type_graph_array($data, $show_elements_graph){
global $config;
if(isset($data) && is_array($data)){
foreach ($data as $key => $value) {
if($show_elements_graph['compare'] == 'overlapped'){
if($key == 'sum2'){
$str = ' (' . __('Previous') . ')';
}
}
if(strpos($key, 'summatory') !== false){
$data_return['series_type'][$key] = 'area';
$data_return['legend'][$key] = __('Summatory series') . ' ' . $series_suffix_str;
$data_return['legend'][$key] = __('Summatory series') . ' ' . $str;
}
elseif(strpos($key, 'average') !== false){
$data_return['series_type'][$key] = 'area';
$data_return['legend'][$key] = __('Average series') . ' ' . $series_suffix_str;
$data_return['legend'][$key] = __('Average series') . ' ' . $str;
}
elseif(strpos($key, 'sum') !== false || strpos($key, 'baseline') !== false){
switch ($value['id_module_type']) {
@ -3029,7 +3036,7 @@ function series_type_graph_array($data, $show_elements_graph){
if (isset($show_elements_graph['labels']) &&
is_array($show_elements_graph['labels']) &&
(count($show_elements_graph['labels']) > 0)){
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['id_module_type']] . ' ' ;
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']] . ' ' ;
}
else{
if(strpos($key, 'baseline') !== false){
@ -3061,25 +3068,25 @@ function series_type_graph_array($data, $show_elements_graph){
$value['avg'],
$config['graph_precision']
)
) . ' ' . $series_suffix_str;
) . ' ' . $str;
}
}
elseif(strpos($key, 'event') !== false){
$data_return['series_type'][$key] = 'points';
if($show_elements_graph['show_events']){
$data_return['legend'][$key] = __('Events') . ' ' . $series_suffix_str;
$data_return['legend'][$key] = __('Events') . ' ' . $str;
}
}
elseif(strpos($key, 'alert') !== false){
$data_return['series_type'][$key] = 'points';
if($show_elements_graph['show_alerts']){
$data_return['legend'][$key] = __('Alert') . ' ' . $series_suffix_str;
$data_return['legend'][$key] = __('Alert') . ' ' . $str;
}
}
elseif(strpos($key, 'unknown') !== false){
$data_return['series_type'][$key] = 'unknown';
if($show_elements_graph['show_unknown']){
$data_return['legend'][$key] = __('Unknown') . ' ' . $series_suffix_str;
$data_return['legend'][$key] = __('Unknown') . ' ' . $str;
}
}
elseif(strpos($key, 'percentil') !== false){
@ -3090,7 +3097,7 @@ function series_type_graph_array($data, $show_elements_graph){
$config['percentil'] .
'º ' . __('of module') . ' ';
if (isset($show_elements_graph['labels']) && is_array($show_elements_graph['labels'])){
$data_return['legend'][$key] .= $show_elements_graph['labels'][$value['id_module_type']] . ' ' ;
$data_return['legend'][$key] .= $show_elements_graph['labels'][$value['agent_module_id']] . ' ' ;
}
else{
$data_return['legend'][$key] .= $value['agent_name'] . ' / ' .
@ -3101,15 +3108,16 @@ function series_type_graph_array($data, $show_elements_graph){
$value['data'][0][1],
$config['graph_precision']
)
) . ' ' . $series_suffix_str;
) . ' ' . $str;
}
}
elseif(strpos($key, 'projection') !== false){
$data_return['series_type'][$key] = 'area';
$data_return['legend'][$key] = __('Projection') . ' ' . $series_suffix_str;
$data_return['legend'][$key] = __('Projection') . ' ' . $str;
}
else{
$data_return['series_type'][$key] = 'area';
$data_return['legend'][$key] = $key;
}
}
return $data_return;
@ -3138,8 +3146,9 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = fal
if($module_list){
$module_list = urlencode(json_encode($module_list));
}
html_debug_print("phantomjs " . $file_js . " " . $url . " '" . $type_graph_pdf . "' '" . $params_encode_json . "' '" . $params_combined . "' '" . $module_list . "' " . $img_path . " " . $width_img . " " . $height_img, true);
$result = exec("phantomjs " . $file_js . " " . $url . " '" . $type_graph_pdf . "' '" . $params_encode_json . "' '" . $params_combined . "' '" . $module_list . "' " . $img_path . " " . $width_img . " " . $height_img);
html_debug_print($result, true);
return '<img src="' . $img_url . '" />';
//html_debug_print('entrando en llamada a phantom.js.......', true);

View File

@ -355,12 +355,13 @@ function grafico_modulo_sparse_data_chart (
}
}
$array_data["sum" . $series_suffix]['min'] = $min_value;
$array_data["sum" . $series_suffix]['max'] = $max_value;
$array_data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
$array_data["sum" . $series_suffix]['id_module_type']= $data_module_graph['id_module_type'];
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
$array_data["sum" . $series_suffix]['min'] = $min_value;
$array_data["sum" . $series_suffix]['max'] = $max_value;
$array_data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
$array_data["sum" . $series_suffix]['agent_module_id']= $agent_module_id;
$array_data["sum" . $series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
if (!is_null($params['percentil']) &&
$params['percentil'] &&
@ -374,6 +375,7 @@ function grafico_modulo_sparse_data_chart (
$date_array['final_date'] * 1000,
$percentil_result
);
$array_data["percentil" . $series_suffix]['agent_module_id'] = $agent_module_id;
}
return $array_data;
}
@ -381,7 +383,7 @@ function grafico_modulo_sparse_data_chart (
function grafico_modulo_sparse_data(
$agent_module_id, $date_array,
$data_module_graph, $params,
$series_suffix, $str_series_suffix) {
$series_suffix) {
global $config;
global $array_events_alerts;
@ -393,9 +395,13 @@ function grafico_modulo_sparse_data(
$params['show_unknown'],
$params['percentil'],
$series_suffix,
$str_series_suffix,
$params['flag_overlapped']
);
$array_data["sum" . $series_suffix]['agent_module_id']= $agent_module_id;
$array_data["sum" . $series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
}
else{
$array_data = grafico_modulo_sparse_data_chart (
@ -672,7 +678,7 @@ function grafico_modulo_sparse_data(
'return_data' => 0,
'show_title' => true,
'only_image' => false,
'homeurl' => '',
'homeurl' => $config['homeurl'],
'ttl' => 1,
'adapt_key' => '',
'compare' => false,
@ -687,7 +693,9 @@ function grafico_modulo_sparse_data(
'id_widget_dashboard' => false,
'force_interval' => '',
'time_interval' => 300,
'array_data_create' => 0
'array_data_create' => 0,
'show_legend' => true,
'show_overview' => true
);
*/
function grafico_modulo_sparse ($params) {
@ -761,7 +769,7 @@ function grafico_modulo_sparse ($params) {
}
if(!isset($params['homeurl'])){
$params['homeurl'] = '';
$params['homeurl'] = $config['homeurl'];
}
if(!isset($params['ttl'])){
@ -784,6 +792,18 @@ function grafico_modulo_sparse ($params) {
$params['menu'] = true;
}
if(!isset($params['show_legend'])){
$params['show_legend'] = true;
}
if(!isset($params['show_overview'])){
$params['show_overview'] = true;
}
if(!isset($params['show_export_csv'])){
$params['show_export_csv'] = true;
}
if(!isset($params['backgroundColor'])){
$params['backgroundColor'] = 'white';
}
@ -848,26 +868,31 @@ function grafico_modulo_sparse ($params) {
$date_array["final_date"] = $params['date'];
$date_array["start_date"] = $params['date'] - $params['period'];
$module_data = db_get_row_sql (
'SELECT * FROM tagente_modulo
WHERE id_agente_modulo = ' .
$agent_module_id
);
if($agent_module_id){
$module_data = db_get_row_sql (
'SELECT * FROM tagente_modulo
WHERE id_agente_modulo = ' .
$agent_module_id
);
$data_module_graph = array();
$data_module_graph['history_db'] = db_search_in_history_db($date_array["start_date"]);
$data_module_graph['agent_name'] = modules_get_agentmodule_agent_name ($agent_module_id);
$data_module_graph['agent_id'] = $module_data['id_agente'];
$data_module_graph['module_name'] = $module_data['nombre'];
$data_module_graph['id_module_type'] = $module_data['id_tipo_modulo'];
$data_module_graph['module_type'] = modules_get_moduletype_name ($data_module_graph['id_module_type']);
$data_module_graph['uncompressed'] = is_module_uncompressed ($data_module_graph['module_type']);
$data_module_graph['w_min'] = $module_data['min_warning'];
$data_module_graph['w_max'] = $module_data['max_warning'];
$data_module_graph['w_inv'] = $module_data['warning_inverse'];
$data_module_graph['c_min'] = $module_data['min_critical'];
$data_module_graph['c_max'] = $module_data['max_critical'];
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
$data_module_graph = array();
$data_module_graph['history_db'] = db_search_in_history_db($date_array["start_date"]);
$data_module_graph['agent_name'] = modules_get_agentmodule_agent_name ($agent_module_id);
$data_module_graph['agent_id'] = $module_data['id_agente'];
$data_module_graph['module_name'] = $module_data['nombre'];
$data_module_graph['id_module_type'] = $module_data['id_tipo_modulo'];
$data_module_graph['module_type'] = modules_get_moduletype_name ($data_module_graph['id_module_type']);
$data_module_graph['uncompressed'] = is_module_uncompressed ($data_module_graph['module_type']);
$data_module_graph['w_min'] = $module_data['min_warning'];
$data_module_graph['w_max'] = $module_data['max_warning'];
$data_module_graph['w_inv'] = $module_data['warning_inverse'];
$data_module_graph['c_min'] = $module_data['min_critical'];
$data_module_graph['c_max'] = $module_data['max_critical'];
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
}
else{
$data_module_graph = false;
}
//format of the graph
if (empty($params['unit'])) {
@ -880,7 +905,6 @@ function grafico_modulo_sparse ($params) {
if(!$params['array_data_create']){
if ($params['compare'] !== false) {
$series_suffix = 2;
$series_suffix_str = ' (' . __('Previous') . ')';
$date_array_prev['final_date'] = $date_array['start_date'];
$date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period'];
@ -894,9 +918,11 @@ function grafico_modulo_sparse ($params) {
}
$array_data = grafico_modulo_sparse_data(
$agent_module_id, $date_array_prev,
$data_module_graph, $params,
$series_suffix, $series_suffix_str
$agent_module_id,
$date_array_prev,
$data_module_graph,
$params,
$series_suffix
);
switch ($params['compare']) {
@ -910,13 +936,14 @@ function grafico_modulo_sparse ($params) {
}
$series_suffix = 1;
$series_suffix_str = '';
$params['flag_overlapped'] = 0;
$array_data = grafico_modulo_sparse_data(
$agent_module_id, $date_array,
$data_module_graph, $params,
$series_suffix, $str_series_suffix
$agent_module_id,
$date_array,
$data_module_graph,
$params,
$series_suffix
);
if($params['compare']){
@ -971,7 +998,6 @@ function grafico_modulo_sparse ($params) {
$data_module_graph,
$params,
$water_mark,
$series_suffix_str,
$array_events_alerts
);
}
@ -998,7 +1024,6 @@ function grafico_modulo_sparse ($params) {
$data_module_graph,
$params,
$water_mark,
$series_suffix_str,
$array_events_alerts
);
}
@ -1017,20 +1042,20 @@ function grafico_modulo_sparse ($params) {
$data_module_graph,
$params,
$water_mark,
$series_suffix_str,
$array_events_alerts
);
}
else{
$return = graph_nodata_image($params['width'], $params['height']);
$return = graph_nodata_image(
$params['width'],
$params['height']
);
}
}
return $return;
}
function graph_get_formatted_date($timestamp, $format1, $format2) {
global $config;
@ -1171,6 +1196,13 @@ function graphic_combined_module (
$params_combined['id_graph'] = 0;
}
if(!isset($params['percentil'])){
$params_combined['percentil'] = null;
}
else{
$params_combined['percentil'] = $params['percentil'];
}
//XXX seteo los parametros
if(!isset($params['period'])){
@ -1247,6 +1279,18 @@ function graphic_combined_module (
$params['homeurl'] = ui_get_full_url(false, false, false, false);
}
if(!isset($params['show_legend'])){
$params['show_legend'] = true;
}
if(!isset($params['show_overview'])){
$params['show_overview'] = true;
}
if(!isset($params['show_export_csv'])){
$params['show_export_csv'] = true;
}
//XXXX
if($params['only_image']){
return generator_chart_to_pdf('combined', $params, $params_combined, $module_list);
@ -1255,16 +1299,6 @@ function graphic_combined_module (
global $config;
global $graphic_type;
//XXX colocar
/*
$name_list
$unit_list
$show_last
$show_max
$show_min
$show_avg
*/
$sources = false;
if ($params_combined['id_graph'] == 0) {
$count_modules = count($module_list);
@ -1313,6 +1347,18 @@ function graphic_combined_module (
}
}
if(isset($summatory)){
$params_combined['summatory'] = $summatory;
}
if(isset($average)){
$params_combined['average'] = $average;
}
if(isset($modules_series)){
$params_combined['modules_series'] = $modules_series;
}
if(isset($labels)){
$params_combined['labels'] = $labels;
}
@ -1349,7 +1395,7 @@ function graphic_combined_module (
$flash_charts = false;
//XXX no se que hacen
$fixed_font_size = '';
$fixed_font_size = $config['font_size'];
$water_mark = '';
$long_index = '';
$color = array();
@ -1397,12 +1443,10 @@ function graphic_combined_module (
$date_array,
$data_module_graph,
$params,
$i,
$data_module_graph['agent_name']
$i
);
$series_suffix = $i;
$series_suffix_str = '';
//convert to array graph and weight
foreach ($array_data_module as $key => $value) {
@ -1422,7 +1466,7 @@ function graphic_combined_module (
$color = color_graph_array(
$series_suffix,
$show_elements_graph['flag_overlapped']
$params['flag_overlapped']
);
foreach ($color as $k => $v) {
@ -1462,7 +1506,7 @@ function graphic_combined_module (
$series_type_array = series_type_graph_array(
$array_data,
$show_elements_graph
$params_combined
);
$series_type = $series_type_array['series_type'];
@ -1590,9 +1634,9 @@ function graphic_combined_module (
$data_module_graph,
$params,
$water_mark,
$series_suffix_str,
$array_events_alerts
);
break;
case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD:
case CUSTOM_GRAPH_BULLET_CHART:
@ -1650,10 +1694,7 @@ function graphic_combined_module (
$value = count($value);
}
else {
if ($flash_charts === false)
$value = 0;
else
$value = false;
$value = false;
}
if ( !empty($params_combined['labels']) && isset($params_combined['labels'][$module]) ){
@ -1690,8 +1731,10 @@ function graphic_combined_module (
//XXXX
$graph_values = $temp;
$width = 1024;
$height = 50;
$output = stacked_bullet_chart(
$flash_charts,
$graph_values,
$width,
$height,
@ -1709,6 +1752,7 @@ function graphic_combined_module (
$homeurl,
$background_color
);
break;
case CUSTOM_GRAPH_GAUGE:
@ -1779,24 +1823,20 @@ function graphic_combined_module (
//XXXX
$graph_values = $temp;
$width = 200;
$height = 200;
$output = stacked_gauge(
$flash_charts,
$graph_values,
$width,
$height,
$color,
$module_name_list,
$long_index,
ui_get_full_url("images/image_problem_area_small.png", false, false, false),
"",
"",
$water_mark,
$config['fontpath'],
$fixed_font_size,
"",
$ttl,
$homeurl,
$background_color
$homeurl
);
break;
@ -1852,9 +1892,13 @@ function graphic_combined_module (
//XXXX
$graph_values = $temp;
$width = 1024;
$height = 500;
$flash_charts = true;
if($params_combined['stacked'] == CUSTOM_GRAPH_HBARS){
$output = hbar_graph(
$flash_charts,
true,
$graph_values,
$width,
$height,
@ -1877,7 +1921,7 @@ function graphic_combined_module (
if($params_combined['stacked'] == CUSTOM_GRAPH_VBARS){
$output = vbar_graph(
$flash_charts,
true,
$graph_values,
$width,
$height,
@ -1963,8 +2007,11 @@ function graphic_combined_module (
//XXXX
$graph_values = $temp;
$width = 1024;
$height = 500;
$output = ring_graph(
$flash_charts,
true,
$graph_values,
$width,
$height,
@ -2114,66 +2161,70 @@ function combined_graph_summatory_average ($array_data, $average = false, $summa
* @param integer period time period
* @param bool return or echo the result flag
*/
function graphic_agentaccess ($id_agent, $width, $height, $period = 0, $return = false) {
function graphic_agentaccess ($id_agent, $width, $height, $period = 0, $return = false, $tree = false) {
global $config;
global $graphic_type;
$data = array ();
$date = get_system_time();
$datelimit = $date - $period;
$data_array = array ();
$resolution = $config["graph_res"] * ($period * 2 / $width); // Number of "slices" we want in graph
$data = db_get_all_rows_sql(
"SELECT count(*) as data, min(utimestamp) as utimestamp
FROM tagent_access
WHERE id_agent = $id_agent
AND utimestamp > $datelimit
AND utimestamp < $date
GROUP by ROUND(utimestamp / 300)"
);
$interval = (int) ($period / $resolution);
$date = get_system_time();
$datelimit = $date - $period;
$periodtime = floor ($period / $interval);
$time = array ();
$data = array ();
$empty_data = true;
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
if (! $graphic_type) {
$name = date('G:i', $bottom);
if(isset($data) && is_array($data)){
foreach ($data as $key => $value) {
$data_array['Agent access']['data'][$key][0] = $value['utimestamp'] * 1000;
$data_array['Agent access']['data'][$key][1] = $value['data'];
}
else {
$name = $bottom;
$data_array['Agent access']['color'] = 'green';
}
else{
if ($return) {
return graph_nodata_image($width, $height);
}
$top = $datelimit + ($periodtime * ($i + 1));
$data[$name]['data'] = (int) db_get_value_filter ('COUNT(*)',
'tagent_access',
array ('id_agent' => $id_agent,
'utimestamp > '.$bottom,
'utimestamp < '.$top));
if ($data[$name]['data'] != 0) {
$empty_data = false;
else{
echo graph_nodata_image($width, $height);
}
}
//XXXXX
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
if ($empty_data) {
$out = graph_nodata_image($width, $height);
}
else {
$out = area_graph(
$config['flash_charts'], $data, $width, $height, null, null, null,
ui_get_full_url("images/image_problem_area_small.png", false, false, false),
"", "", ui_get_full_url(false, false, false, false), $water_mark,
$config['fontpath'], $config['font_size'], "", 1, array(), array(), 0, 0, '', false, '', false);
}
$params =array(
'agent_module_id' => false,
'period' => $period,
'width' => $width,
'height' => $height,
'unit' => $unit,
'only_image' => $only_image,
'homeurl' => $homeurl,
'menu' => true,
'backgroundColor' => 'white',
'type_graph' => 'area',
'font' => $config['fontpath'],
'font-size' => $config['font_size'],
'array_data_create' => $data_array,
'show_overview' => false,
'show_export_csv' => false,
'vconsole' => $tree
);
if ($return) {
return $out;
return grafico_modulo_sparse($params);
}
else {
echo $out;
echo grafico_modulo_sparse($params);
}
}
@ -3746,9 +3797,9 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho
function graph_graphic_moduleevents ($id_agent, $id_module, $width, $height, $period = 0, $homeurl, $return = false) {
global $config;
global $graphic_type;
$data = array ();
$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
$interval = (int) ($period / $resolution);
$date = get_system_time ();
@ -3758,7 +3809,7 @@ function graph_graphic_moduleevents ($id_agent, $id_module, $width, $height, $pe
$data = array ();
$legend = array();
$full_legend = array();
$cont = 0;
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
@ -3773,13 +3824,13 @@ function graph_graphic_moduleevents ($id_agent, $id_module, $width, $height, $pe
else {
$name = $bottom;
}
// Show less values in legend
if ($cont == 0 or $cont % 2)
$legend[$cont] = $name;
$full_legend[$cont] = $name;
$top = $datelimit + ($periodtime * ($i + 1));
$event_filter = array ('id_agente' => $id_agent,
@ -3810,16 +3861,16 @@ function graph_graphic_moduleevents ($id_agent, $id_module, $width, $height, $pe
}
$cont++;
}
$colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN);
// Draw slicebar graph
if ($config['flash_charts']) {
$out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent);
}
else {
$out = slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
// Draw legend
$out .= "<br>";
$out .= "&nbsp;";
@ -3846,7 +3897,7 @@ function fs_error_image ($width = 300, $height = 110) {
function fullscale_data (
$agent_module_id, $date_array,
$show_unknown = 0, $show_percentil = 0,
$series_suffix, $str_series_suffix = '',
$series_suffix,
$compare = false){
global $config;
@ -3981,118 +4032,55 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $unit =
return;
}
if ($period <= SECONDS_6HOURS) {
$chart_time_format = 'H:i:s';
}
elseif ($period < SECONDS_1DAY) {
$chart_time_format = 'H:i';
}
elseif ($period < SECONDS_15DAYS) {
$chart_time_format = 'M d H:i';
}
elseif ($period < SECONDS_1MONTH) {
$chart_time_format = 'M d H\h';
}
elseif ($period < SECONDS_6MONTHS) {
$chart_time_format = "M d H\h";
}
else {
$chart_time_format = "Y M d H\h";
}
// Calculate source indexes
$i = 0;
$sources = array ();
foreach ($data['sources'] as $source => $value) {
$source_indexes[$source] = $i;
$sources[$i] = $source;
$i++;
}
// Add sources to chart
$chart = array ();
foreach ($data['data'] as $timestamp => $data) {
$chart_date = date ($chart_time_format, $timestamp);
$chart[$chart_date] = array ();
foreach ($source_indexes as $source => $index) {
$chart[$chart_date][$index] = 0;
}
foreach ($data as $source => $value) {
$chart[$chart_date][$source_indexes[$source]] = $value;
foreach ($data['sources'] as $key => $value) {
$i = 0;
foreach($data['data'] as $k => $v){
$chart['netflow_' . $key]['data'][$i][0] = $k * 1000;
$chart['netflow_' . $key]['data'][$i][1] = $v[$key];
$i++;
}
}
$flash_chart = $config['flash_charts'];
if ($only_image) {
$flash_chart = false;
}
if ($config['homeurl'] != '') {
$homeurl = $config['homeurl'];
}
else {
$homeurl = '';
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
$color = array();
$color[0] = array('border' => '#000000',
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[1] = array('border' => '#000000',
'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[2] = array('border' => '#000000',
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[3] = array('border' => '#000000',
'color' => $config['graph_color4'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[4] = array('border' => '#000000',
'color' => $config['graph_color5'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[5] = array('border' => '#000000',
'color' => $config['graph_color6'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[6] = array('border' => '#000000',
'color' => $config['graph_color7'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[7] = array('border' => '#000000',
'color' => $config['graph_color8'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[8] = array('border' => '#000000',
'color' => $config['graph_color9'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[9] = array('border' => '#000000',
'color' => $config['graph_color10'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[11] = array('border' => '#000000',
'color' => COL_GRAPH9,
'alpha' => CHART_DEFAULT_ALPHA);
$color[12] = array('border' => '#000000',
'color' => COL_GRAPH10,
'alpha' => CHART_DEFAULT_ALPHA);
$color[13] = array('border' => '#000000',
'color' => COL_GRAPH11,
'alpha' => CHART_DEFAULT_ALPHA);
$color[14] = array('border' => '#000000',
'color' => COL_GRAPH12,
'alpha' => CHART_DEFAULT_ALPHA);
$color[15] = array('border' => '#000000',
'color' => COL_GRAPH13,
'alpha' => CHART_DEFAULT_ALPHA);
return area_graph($flash_chart, $chart, $width, $height, $color,
$sources, array (), ui_get_full_url("images/image_problem_area_small.png", false, false, false),
"", $unit, $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], $unit, $ttl);
$water_mark = $config['homedir'] . "/images/logo_vertical_water.png";
}
if($ttl >= 2){
$only_image = true;
}
else{
$only_image = false;
}
$params =array(
'agent_module_id' => false,
'period' => $period,
'width' =>'90%',
'height' => 450,
'unit' => $unit,
'only_image' => $only_image,
'homeurl' => $homeurl,
'menu' => true,
'backgroundColor' => 'white',
'type_graph' => 'area',
'font' => $config['fontpath'],
'font-size' => $config['font_size'],
'array_data_create' => $chart
);
return grafico_modulo_sparse($params);
}
/**
@ -4101,80 +4089,59 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $unit =
function graph_netflow_total_area ($data, $period, $width, $height, $unit = '', $ttl = 1, $only_image = false) {
global $config;
global $graphic_type;
if (empty ($data)) {
echo fs_error_image ();
return;
}
if ($period <= SECONDS_6HOURS) {
$chart_time_format = 'H:i:s';
}
elseif ($period < SECONDS_1DAY) {
$chart_time_format = 'H:i';
}
elseif ($period < SECONDS_15DAYS) {
$chart_time_format = 'M d H:i';
}
elseif ($period < SECONDS_1MONTH) {
$chart_time_format = 'M d H\h';
}
elseif ($period < SECONDS_6MONTHS) {
$chart_time_format = "M d H\h";
}
else {
$chart_time_format = "Y M d H\h";
// Calculate source indexes
$i=0;
foreach ($data as $key => $value) {
$chart['netflow']['data'][$i][0] = $key * 1000;
$chart['netflow']['data'][$i][1] = $value['data'];
$i++;
}
// Calculate min, max and avg values
$avg = 0;
foreach ($data as $timestamp => $value) {
$max = $value['data'];
$min = $value['data'];
break;
}
// Populate chart
$count = 0;
$chart = array ();
foreach ($data as $timestamp => $value) {
$chart[date ($chart_time_format, $timestamp)] = $value;
if ($value['data'] > $max) {
$max = $value['data'];
}
if ($value['data'] < $min) {
$min = $value['data'];
}
$avg += $value['data'];
$count++;
}
if ($count > 0) {
$avg /= $count;
}
$flash_chart = $config['flash_charts'];
if ($only_image) {
$flash_chart = false;
}
if ($config['homeurl'] != '') {
$homeurl = $config['homeurl'];
}
else {
$homeurl = '';
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
$water_mark = $config['homedir'] . "/images/logo_vertical_water.png";
}
$legend = array (__('Max.') . ' ' . format_numeric($max) . ' ' . __('Min.') . ' ' . format_numeric($min) . ' ' . __('Avg.') . ' ' . format_numeric ($avg));
return area_graph($flash_chart, $chart, $width, $height, array (), $legend,
array (), ui_get_full_url("images/image_problem_area_small.png", false, false, false),
"", "", $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], $unit, $ttl);
if($ttl >= 2){
$only_image = true;
}
else{
$only_image = false;
}
$params =array(
'agent_module_id' => false,
'period' => $period,
'width' =>'90%',
'height' => 450,
'unit' => $unit,
'only_image' => $only_image,
'homeurl' => $homeurl,
'menu' => true,
'backgroundColor' => 'white',
'type_graph' => 'area',
'font' => $config['fontpath'],
'font-size' => $config['font_size'],
'array_data_create' => $chart
);
return grafico_modulo_sparse($params);
}
/**
@ -4183,11 +4150,16 @@ function graph_netflow_total_area ($data, $period, $width, $height, $unit = '',
function graph_netflow_aggregate_pie ($data, $aggregate, $ttl = 1, $only_image = false) {
global $config;
global $graphic_type;
if (empty ($data)) {
return fs_error_image ();
}
$date_array = array();
$date_array["period"] = 300;
$date_array["final_date"] = time();
$date_array["start_date"] = time() - 300;
$i = 0;
$values = array();
$agg = '';
@ -4201,18 +4173,18 @@ function graph_netflow_aggregate_pie ($data, $aggregate, $ttl = 1, $only_image =
}
$i++;
}
$flash_chart = $config['flash_charts'];
if ($only_image) {
$flash_chart = false;
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($flash_chart, $values, 370, 200,
__('Other'), $config['homeurl'], $water_mark,
$config['fontpath'], $config['font_size'], $ttl);

View File

@ -727,11 +727,10 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
//echo '<div id="id_div" style="height: 10px">&nbsp;</div>';
if ($config["agentaccess"]) {
$access_graph = '<div style="margin-left: 10px;">';
$access_graph .= graphic_agentaccess($id_agente, 290, 110,
SECONDS_1DAY, true);
$access_graph .= '</div><br>';
$access_graph = '<div>hjhhjhhj</div>';
$access_graph = '<div style="width:100%; heigth:200px;">';
$access_graph .= graphic_agentaccess($id_agente, 380, 180, SECONDS_1DAY, true, true);
$access_graph .= '</div><br><br>';
ui_toggle($access_graph, __('Agent access rate (24h)'));
}

View File

@ -1049,7 +1049,8 @@ function visual_map_print_item($mode = "read", $layoutData,
'only_image' => $only_image,
'menu' => false,
'backgroundColor' => $layoutData['image'],
'type_graph' => $type_graph
'type_graph' => $type_graph,
'vconsole' => true
);
if ($layoutData['label_position']=='left') {

View File

@ -223,7 +223,7 @@ function vbar_graph(
function area_graph(
$agent_module_id, $array_data,
$legend, $series_type, $date_array,
$data_module_graph, $params, $water_mark, $series_suffix_str,
$data_module_graph, $params, $water_mark,
$array_events_alerts
) {
global $config;
@ -239,12 +239,11 @@ function area_graph(
$data_module_graph,
$params,
$water_mark,
$series_suffix_str,
$array_events_alerts
);
}
function stacked_bullet_chart($flash_chart, $chart_data, $width, $height,
function stacked_bullet_chart($chart_data, $width, $height,
$color, $legend, $long_index, $no_data_image, $xaxisname = "",
$yaxisname = "", $water_mark = "", $font = '', $font_size = '',
$unit = '', $ttl = 1, $homeurl = '', $backgroundColor = 'white') {
@ -256,75 +255,43 @@ function stacked_bullet_chart($flash_chart, $chart_data, $width, $height,
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
}
if ($flash_chart) {
return d3_bullet_chart(
$chart_data,
$width,
$height,
$color,
$legend,
$homeurl,
$unit,
$font,
$font_size
);
}
else {
$legend = array();
$new_data = array();
foreach($chart_data as $key => $data) {
$temp[] = ($data['min'] != false) ? $data['min'] : 0;
$temp[] = ($data['value'] != false) ? $data['value'] : 0;
$temp[] = ($data['max'] != false) ? $data['max'] : 0;
$legend[] = $data['label'];
array_push($new_data, $temp);
$temp = array();
}
$graph = array();
$graph['data'] = $new_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
return d3_bullet_chart(
$chart_data,
$width,
$height,
$color,
$legend,
$homeurl,
$unit,
$font,
$font_size
);
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=bullet_chart&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
function stacked_gauge($flash_chart, $chart_data, $width, $height,
$color, $legend, $long_index, $no_data_image, $xaxisname = "",
$yaxisname = "", $water_mark = "", $font = '', $font_size = '',
$unit = '', $ttl = 1, $homeurl = '', $backgroundColor = 'white') {
function stacked_gauge($chart_data, $width, $height,
$color, $legend, $no_data_image, $font = '', $font_size = '',
$unit = '', $homeurl = '') {
include_once('functions_d3.php');
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
}
return d3_gauges(
$chart_data,
$width,
$height,
$color,
$legend,
$homeurl,
$unit,
$font,
$font_size + 2,
$no_data_image
);
$chart_data,
$width,
$height,
$color,
$legend,
$homeurl,
$unit,
$font,
$font_size + 2,
$no_data_image
);
}
function kiviat_graph($graph_type, $flash_chart, $chart_data, $width,

View File

@ -859,24 +859,25 @@ function pandoraFlotArea(
graph_id, values, legend, agent_module_id,
series_type, watermark, date_array,
data_module_graph, params,
force_integer, series_suffix_str,
force_integer,
background_color, legend_color, short_data,
events_array
) {
//diferents vars
var unit = params.unit ? params.unit : '';
var homeurl = params.homeurl;
var font_size = params.font_size;
var font = params.font;
var width = params.width;
var height = params.height;
var vconsole = params.vconsole;
var dashboard = params.dashboard;
var menu = params.menu;
var min_x = date_array['start_date'] *1000;
var max_x = date_array['final_date'] *1000;
var type = params.stacked;
var unit = params.unit ? params.unit : '';
var homeurl = params.homeurl;
var font_size = params.font_size;
var font = params.font;
var width = params.width;
var height = params.height;
var vconsole = params.vconsole;
var dashboard = params.dashboard;
var menu = params.menu;
var min_x = date_array['start_date'] *1000;
var max_x = date_array['final_date'] *1000;
var type = params.stacked;
var show_legend= params.show_legend;
if(typeof type === 'undefined' || type == ''){
type = params.type_graph;
@ -1564,7 +1565,7 @@ function pandoraFlotArea(
data_base.push({
id: 'serie_' + i,
data: value.data,
label: index + series_suffix_str,
label: index,
color: value.color,
lines: {
show: line_show,
@ -1583,15 +1584,22 @@ function pandoraFlotArea(
}
i++;
});
console.log(legend);
// The first execution, the graph data is the base data
datas = data_base;
font_size = 8;
// minTickSize
var count_data = datas[0].data.length;
var min_tick_pixels = 80;
var min_tick = datas[0].data[0][0];
var max_tick = datas[0].data[count_data - 1][0];
var number_ticks = 8;
if(vconsole){
number_ticks = 5;
}
var maxticks = date_array['period'] / 3600 / number_ticks;
var maxticks = date_array['period'] / 3600 /6;
var options = {
series: {
stack: stacked,
@ -1622,9 +1630,8 @@ console.log(legend);
xaxes: [{
axisLabelFontSizePixels: font_size,
mode: "time",
tickFormatter: xFormatter,
tickSize: [maxticks, 'hour'],
labelWidth: 70
//tickFormatter: xFormatter,
tickSize: [maxticks, 'hour']
}],
yaxes: [{
tickFormatter: yFormatter,
@ -1633,7 +1640,7 @@ console.log(legend);
labelWidth: 30,
position: 'left',
font: font,
reserveSpace: true,
reserveSpace: true
}],
legend: {
position: 'se',
@ -1641,6 +1648,7 @@ console.log(legend);
labelFormatter: lFormatter
}
};
if (vconsole) {
options.grid['hoverable'] = false;
options.grid['clickable'] = false;
@ -1664,15 +1672,16 @@ console.log(legend);
$('#'+graph_id).css('height', hDiff);
}
}
if (vconsole) {
console.log(vconsole);
/*
if (vconsole) {
var myCanvas = plot.getCanvas();
plot.setupGrid(); // redraw plot to new size
plot.draw();
var image = myCanvas.toDataURL("image/png");
return;
}
*/
// Adjust the overview plot to the width and position of the main plot
adjust_left_width_canvas(graph_id, 'overview_'+graph_id);
update_left_width_canvas(graph_id);
@ -1714,9 +1723,8 @@ console.log(legend);
xaxes: [{
axisLabelFontSizePixels: font_size,
mode: "time",
tickFormatter: xFormatter,
//tickFormatter: xFormatter,
tickSize: [maxticks, 'hour'],
labelWidth: 70
}],
yaxes: [{
tickFormatter: yFormatter,
@ -1777,7 +1785,7 @@ console.log(legend);
},
xaxes: [{
mode: "time",
tickFormatter: xFormatter,
//tickFormatter: xFormatter,
tickSize: [maxticks_zoom, 'hour']
}],
yaxis:{
@ -1812,7 +1820,7 @@ console.log(legend);
},
xaxes: [{
mode: "time",
tickFormatter: xFormatter,
//tickFormatter: xFormatter,
tickSize: [maxticks_zoom, 'hour']
}],
yaxis:{
@ -1833,9 +1841,8 @@ console.log(legend);
}
}));
}
$('#menu_cancelzoom_' + graph_id)
.attr('src', homeurl + '/images/zoom_cross_grey.png');
console.log(homeurl);
$('#menu_cancelzoom_' + graph_id).attr('src', homeurl + '/images/zoom_cross_grey.png');
// currentRanges = ranges;
// don't fire event on the overview to prevent eternal loop
@ -1939,7 +1946,7 @@ console.log(legend);
y = y / 1000;
}
var label_aux = legend[series.label] + series_suffix_str;
var label_aux = legend[series.label];
// The graphs of points type and unknown graphs will dont be updated
if (series_type[dataset[k]["label"]] != 'points' &&
@ -2070,21 +2077,26 @@ console.log(legend);
}
});
$('#'+graph_id).bind('mouseout',resetInteractivity);
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
$('#'+graph_id).bind('mouseout',resetInteractivity(vconsole));
if(!vconsole){
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
}
// Reset interactivity styles
function resetInteractivity() {
function resetInteractivity(vconsole) {
$('#timestamp_'+graph_id).hide();
dataset = plot.getData();
for (i = 0; i < dataset.length; ++i) {
var series = dataset[i];
var label_aux = legend[series.label] + ' ' + series_suffix_str;
var label_aux = legend[series.label];
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).html(label_aux);
}
plot.clearCrosshair();
overview.clearCrosshair();
if(!vconsole){
overview.clearCrosshair();
}
}
// Format functions
@ -2124,8 +2136,7 @@ console.log(legend);
}
// Get only two decimals
//XXXXXXXXXX
//formatted = round_with_decimals(formatted, 100);
formatted = round_with_decimals(formatted, 100);
return '<div class='+font+' style="font-size:'+font_size+'pt;">'+formatted+'</div>';
}
@ -2247,17 +2258,17 @@ console.log(legend);
$('#legend_'+graph_id).css('margin-bottom').split('px')[0]);
$('#legend_'+graph_id).css('margin-bottom', '10px');
parent_height = parseInt($('#menu_'+graph_id).parent().css('height').split('px')[0]);
adjust_menu(graph_id, plot, parent_height, width);
adjust_menu(graph_id, plot, parent_height, width, show_legend);
}
if (!dashboard) {
if (water_mark)
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
adjust_menu(graph_id, plot, parent_height, width);
adjust_menu(graph_id, plot, parent_height, width, show_legend);
}
}
function adjust_menu(graph_id, plot, parent_height, width) {
function adjust_menu(graph_id, plot, parent_height, width, show_legend) {
if ($('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width') != undefined) {
left_ticks_width = $('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width').split('px')[0];
}
@ -2267,7 +2278,12 @@ function adjust_menu(graph_id, plot, parent_height, width) {
var parent_height_new = 0;
var legend_height = parseInt($('#legend_'+graph_id).css('height').split('px')[0]) + parseInt($('#legend_'+graph_id).css('margin-top').split('px')[0]);
if(show_legend){
var legend_height = parseInt($('#legend_'+graph_id).css('height').split('px')[0]) + parseInt($('#legend_'+graph_id).css('margin-top').split('px')[0]);
}
else{
var legend_height = 0;
}
var menu_height = '25';

View File

@ -103,7 +103,7 @@ function include_javascript_dependencies_flot_graph($return = false) {
function flot_area_graph (
$agent_module_id, $array_data,
$legend, $series_type, $date_array,
$data_module_graph, $params, $water_mark, $series_suffix_str,
$data_module_graph, $params, $water_mark,
$array_events_alerts ) {
global $config;
@ -114,8 +114,7 @@ function flot_area_graph (
$graph_id = uniqid('graph_');
$background_style = '';
switch ($params['background']) {
default:
switch ($params['backgroundColor']) {
case 'white':
$background_style = ' background: #fff; ';
break;
@ -125,13 +124,19 @@ function flot_area_graph (
case 'transparent':
$background_style = '';
break;
default:
$background_style = 'background-color: ' . $params['backgroundColor'];
break;
}
///XXXXXXX los px caca
// Parent layer
$return = "<div class='parent_graph' style='width: " . ($params['width']) . "; " . $background_style . "'>";
$return = "<div class='parent_graph' style='width: " . ($params['width']) . "; height:" . ($params['height'] + 30) . "px; " . $background_style . "'>";
// Set some containers to legend, graph, timestamp tooltip, etc.
$return .= "<p id='legend_$graph_id' class='legend_graph' style='font-size:" . $params['font_size'] ."pt !important;'></p>";
if($params['show_legend']){
$return .= "<p id='legend_$graph_id' class='legend_graph' style='font-size:" . $params['font_size'] ."pt !important;'></p>";
}
if(!isset($params['combined']) || !$params['combined']){
$yellow_threshold = $data_module_graph['w_min'];
$red_threshold = $data_module_graph['c_min'];
@ -171,12 +176,14 @@ function flot_area_graph (
if ($params['menu']) {
$return .= menu_graph(
$yellow_threshold, $red_threshold,
$yellow_up, $red_up, $yellow_inverse,
$red_inverse, $params['dashboard'],
$params['vconsole'],
$graph_id, $params['width'],
$params['homeurl']
$yellow_threshold,
$red_threshold,
$yellow_up,
$red_up,
$yellow_inverse,
$red_inverse,
$graph_id,
$params
);
}
@ -281,7 +288,6 @@ function flot_area_graph (
"JSON.parse('$data_module_graph'), \n" .
"JSON.parse('$params'), \n" .
"$force_integer, \n" .
"'$series_suffix_str', \n" .
"'$background_color', \n" .
"'$legend_color', \n" .
"'$short_data', \n" .
@ -299,8 +305,7 @@ function flot_area_graph (
function menu_graph(
$yellow_threshold, $red_threshold,
$yellow_up, $red_up, $yellow_inverse,
$red_inverse, $dashboard, $vconsole,
$graph_id, $width, $homeurl
$red_inverse, $graph_id, $params
){
$return = '';
$threshold = false;
@ -308,34 +313,31 @@ function menu_graph(
$threshold = true;
}
$nbuttons = 3;
if ($threshold) {
$nbuttons++;
}
$menu_width = 25 * $nbuttons + 15;
if ( $dashboard == false AND $vconsole == false) {
$return .= "<div id='geneal_menu_$graph_id' class='menu_graph' style='
width: 30px;
height: 250px;
if ( $params['dashboard'] == false AND $params['vconsole'] == false) {
$return .= "<div id='general_menu_$graph_id' class='menu_graph' style='
width: 20px;
height: 150px;
left:100%;
position: absolute;
top: 0px;
background-color: white;'>";
background-color: tranparent;'>";
$return .= "<div id='menu_$graph_id' " .
"style='display: none; " .
"text-align: center;" .
"position: relative;".
"border-bottom: 0px;'>
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross_grey.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
<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>";
if ($threshold) {
$return .= " <a href='javascript:'><img id='menu_threshold_$graph_id' src='".$homeurl."images/chart_curve_threshold.png' alt='".__('Warning and Critical thresholds')."' title='".__('Warning and Critical thresholds')."'></a>";
$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>";
}
$return .= " <a href='javascript:'>
<img id='menu_overview_$graph_id' class='menu_overview' src='" . $homeurl . "images/chart_curve_overview.png' alt='" . __('Overview graph') . "' title='".__('Overview graph')."'></a>";
// Export buttons
$return .= " <a href='javascript:'><img id='menu_export_csv_$graph_id' src='".$homeurl."images/csv_grey.png' alt='".__('Export to CSV')."' title='".__('Export to CSV')."'></a>";
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>";
}
// 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>";
@ -343,11 +345,11 @@ function menu_graph(
$return .= "</div>";
}
if ($dashboard) {
$return .= "<div id='geneal_menu_$graph_id' class='menu_graph' style='
if ($params['dashboard']) {
$return .= "<div id='general_menu_$graph_id' class='menu_graph' style='
width: 30px;
height: 250px;
left: " . $width . "px;
left: " . $params['width'] . "px;
position: absolute;
top: 0px;
background-color: white;'>";
@ -357,7 +359,7 @@ function menu_graph(
"text-align: center;" .
"position: relative;".
"border-bottom: 0px;'>
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross_grey.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
<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>";
$return .= "</div>";
$return .= "</div>";

View File

@ -883,11 +883,6 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
global $config;
html_debug_print($graph_type, true);
html_debug_print($index, true);
html_debug_print($data, true);
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(20,22,25,5,12,8,30,8),"Probe 1");

View File

@ -1024,41 +1024,40 @@ function createGauge(name, etiqueta, value, min, max, min_warning,max_warning,wa
function createGauges(data, width, height, font_size, no_data_image, font) {
var nombre,label,minimun_warning,maximun_warning,minimun_critical,maximun_critical,
mininum,maxinum,valor;
for (key in data) {
nombre = data[key].gauge;
label = data[key].label;
label = label.replace(/&#x20;/g,' ');
label = label.replace(/\(/g,'\(');
label = label.replace(/\)/g,'\)');
label = label.replace(/&#40;/g,'\(');
label = label.replace(/&#41;/g,'\)');
minimun_warning = round_with_decimals(parseFloat( data[key].min_warning ));
maximun_warning = round_with_decimals(parseFloat( data[key].max_warning ));
minimun_critical = round_with_decimals(parseFloat( data[key].min_critical ));
maximun_critical = round_with_decimals(parseFloat( data[key].max_critical ));
minimun_warning = round_with_decimals(parseFloat( data[key].min_warning ));
maximun_warning = round_with_decimals(parseFloat( data[key].max_warning ));
minimun_critical = round_with_decimals(parseFloat( data[key].min_critical ));
maximun_critical = round_with_decimals(parseFloat( data[key].max_critical ));
mininum = round_with_decimals(parseFloat(data[key].min));
maxinum = round_with_decimals(parseFloat(data[key].max));
critical_inverse = parseInt(data[key].critical_inverse);
warning_inverse = parseInt(data[key].warning_inverse);
valor = round_with_decimals(data[key].value);
if (isNaN(valor))
valor = null;
createGauge(nombre, label, valor, mininum, maxinum,
createGauge(nombre, label, valor, mininum, maxinum,
minimun_warning, maximun_warning, warning_inverse, minimun_critical,
maximun_critical, critical_inverse, font_size, height, font);
}
}
@ -1265,8 +1264,10 @@ function Gauge(placeholderName, configuration, font)
this.drawBand = function(start, end, color)
{
if (start === undefined) return;
if (end === undefined) return;
if (0 >= end - start) return;
this.body.append("svg:path")
.style("fill", color)
.attr("d", d3.svg.arc()
@ -1276,13 +1277,13 @@ function Gauge(placeholderName, configuration, font)
.outerRadius(Math.round(0.85 * this.config.raduis)))
.attr("transform", function() { return "translate(" + self.config.cx + ", " + self.config.cy + ") rotate(270)" });
}
this.redraw = function(value, transitionDuration)
{
var pointerContainer = this.body.select(".pointerContainer");
pointerContainer.selectAll("text").text(round_with_decimals(value));
var pointer = pointerContainer.selectAll("path");
pointer.transition()
.duration(undefined != transitionDuration ? transitionDuration : this.config.transitionDuration)
@ -1297,7 +1298,7 @@ function Gauge(placeholderName, configuration, font)
var targetRotation = (self.valueToDegrees(pointerValue) - 90);
var currentRotation = self._currentRotation || targetRotation;
self._currentRotation = targetRotation;
return function(step)
{
var rotation = currentRotation + (targetRotation-currentRotation)*step;

View File

@ -1553,7 +1553,10 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er
}
}
function round_with_decimals (value, multiplier = 1) {
function round_with_decimals(value, multiplier) {
// Default values
if (typeof(multiplier) === "undefined") multiplier = 1;
// Return non numeric types without modification
if (typeof(value) !== "number") return value;
@ -1564,24 +1567,6 @@ function round_with_decimals (value, multiplier = 1) {
return round_with_decimals (value, multiplier * 10);
}
/*
$("body").append('<div id="event_delete_confirm_dialog"><h4>' + '<?php echo __('Are you sure?'); ?>' + '</h4></div>');
$("#event_delete_confirm_dialog").dialog({
resizable: false,
draggable: false,
modal: true,
height: 280,
width: 330,
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});
*/
/**
* Display a confirm dialog box
*
@ -1590,12 +1575,7 @@ function round_with_decimals (value, multiplier = 1) {
* @param string Cancel button text
* @param function Callback to action when ok button is pressed
*/
function display_confirm_dialog (
message = '',
ok_text = '',
cancel_text = '',
ok_function = function () {}
) {
function display_confirm_dialog (message, ok_text, cancel_text, ok_function) {
// Clean function to close the dialog
var clean_function = function () {
$("#pandora_confirm_dialog_text").hide();

View File

@ -38,10 +38,14 @@ page.viewportSize = { width: _width, height: _height };
//page.zoomFactor = 1.75;
page.open(finish_url, function start(status) {
page.includeJs('./javascript/pandora.js');
});
page.onLoadFinished = function (status) {
page.render(output_filename, {format: 'png'});
//var base64 = page.renderBase64('JPG');
//console.log(base64);
phantom.exit();
});
}

View File

@ -153,7 +153,8 @@ class ModuleGraph {
'compare' => $time_compare,
'show_unknown' => $this->unknown_graph,
'menu' => false,
'type_graph' => $config['type_module_charts']
'type_graph' => $config['type_module_charts'],
'vconsole' => true
);
$graph = grafico_modulo_sparse($params);

View File

@ -280,13 +280,15 @@ $access_agent = db_get_value_sql("SELECT COUNT(id_agent)
WHERE id_agent = " . $id_agente);
if ($config["agentaccess"] && $access_agent > 0) {
$data[2] =
'<fieldset width=90% class="databox agente" style="">
'<fieldset width=99% class="databox agente" style="">
<legend>' .
__('Agent access rate (24h)') .
'</legend>' .
graphic_agentaccess($id_agente, 300, 100, SECONDS_1DAY, true) .
graphic_agentaccess($id_agente, '90%', 150, SECONDS_1DAY, true) .
'</fieldset>';
$table_data->style[1] = 'width: 40%;';
$table_data->style[0] = 'width: 20%;';
$table_data->style[1] = 'width: 30%;';
$table_data->style[2] = 'width: 50%;';
$table_data->rowspan[0][2] = 5;
}
@ -298,8 +300,6 @@ if (!empty($addresses)) {
$data[1] = '<div style="max-height: 45px; overflow-y: scroll; height:45px;">' .
implode('<br>',$addresses) .
'</div>';
//~ $table_data->data[] = '<div style="max-height: 200px; overflow: hidden;>' .
//~ $data . '</div>';
$table_data->data[] = $data;
}