';
$output .= "
";
if (!$return) {
echo $output;
}
return $output;
}
}
//
// AREA GRAPHS ////////
//
function flot_area_graph(
$agent_module_id,
$array_data,
$legend,
$series_type,
$color,
$date_array,
$data_module_graph,
$params,
$water_mark,
$array_events_alerts
) {
global $config;
// include_javascript_dependencies_flot_graph();
// Get a unique identifier to graph
$graph_id = uniqid('graph_');
$background_style = '';
switch ($params['backgroundColor']) {
case 'white':
$background_style = ' background: #fff; ';
$params['grid_color'] = '#C1C1C1';
break;
case 'black':
$background_style = ' background: #000; ';
$params['grid_color'] = '#BDBDBD';
break;
case 'transparent':
$background_style = '';
$params['grid_color'] = '#A4A4A4';
break;
default:
$background_style = 'background-color: '.$params['backgroundColor'];
$params['grid_color'] = '#C1C1C1';
break;
}
$padding_vconsole = $params['dashboard'] ? 'padding: 1px 0px 10px 10px;' : '';
// Parent layer
$return = "
";
// Set some containers to legend, graph, timestamp tooltip, etc.
if ($params['show_legend']) {
$return .= "
";
}
if (isset($params['graph_combined']) && $params['graph_combined']
&& (!isset($params['from_interface']) || !$params['from_interface'])
) {
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;
}
} else if (!isset($params['combined']) || !$params['combined']) {
$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);
}
} else if (isset($params['from_interface']) && $params['from_interface']) {
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;
}
} else {
$yellow_up = 0;
$red_up = 0;
$yellow_inverse = false;
$red_inverse = false;
}
if ($params['menu']) {
$return .= menu_graph(
$yellow_threshold,
$red_threshold,
$yellow_up,
$red_up,
$yellow_inverse,
$red_inverse,
$graph_id,
$params
);
}
$return .= html_print_input_hidden('line_width_graph', $config['custom_graph_width'], true);
$return .= "
";
$return .= "
";
if ($params['menu']) {
$params['height'] = 100;
} else {
$params['height'] = 1;
}
if (!$vconsole) {
$return .= "
";
}
if ($water_mark != '') {
$return .= "
";
$watermark = 'true';
} else {
$watermark = 'false';
}
foreach ($series_type as $k => $v) {
$series_type_unique['data_'.$graph_id.'_'.$k] = $v;
}
// Store data series in javascript format
$extra_width = (int) ($params['width'] / 3);
$return .= "";
// 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);
$color = json_encode($color);
$date_array = json_encode($date_array);
$data_module_graph = json_encode($data_module_graph);
$params = json_encode($params);
$array_events_alerts = json_encode($array_events_alerts);
// Javascript code
if ($font_size == '') {
$font_size = '\'\'';
}
$return .= "';
// Parent layer
$return .= '
';
return $return;
}
function menu_graph(
$yellow_threshold,
$red_threshold,
$yellow_up,
$red_up,
$yellow_inverse,
$red_inverse,
$graph_id,
$params
) {
$return = '';
$threshold = false;
if ($yellow_threshold != $yellow_up || $red_threshold != $red_up) {
$threshold = true;
}
if ($params['dashboard'] == false and $params['vconsole'] == false) {
$return .= "';
}
if ($params['dashboard']) {
$return .= "';
}
return $return;
}
//
//
//
// Prints a FLOT pie chart
function flot_pie_chart(
$values,
$labels,
$width,
$height,
$water_mark,
$font='',
$font_size=8,
$legend_position='',
$colors='',
$hide_labels=false
) {
// include_javascript_dependencies_flot_graph();
$series = sizeof($values);
if (($series != sizeof($labels)) || ($series == 0)) {
return;
}
$graph_id = uniqid('graph_');
switch ($legend_position) {
case 'bottom':
$height = ($height + (count($values) * 24));
break;
case 'right':
default:
// TODO FOR TOP OR LEFT OR RIGHT
break;
}
$return = "