2012-02-13 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_graph.php include/javascript/pandora.js operation/agentes/stat_win.php: Added new graph for module events in the module popup graph window. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5563 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
e0e14c9db8
commit
3a66dfb3ab
|
@ -1,3 +1,10 @@
|
|||
2012-02-13 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||
|
||||
* include/functions_graph.php
|
||||
include/javascript/pandora.js
|
||||
operation/agentes/stat_win.php: Added new graph for module events
|
||||
in the module popup graph window.
|
||||
|
||||
2012-02-13 Koichiro Kikuchi <koichiro@rworks.jp>
|
||||
|
||||
* include/javascript/pandora_alerts.js: Removed double quotes which encolse
|
||||
|
|
|
@ -1730,6 +1730,41 @@ function fs_agent_event_chart ($data, $width, $height, $step = 1) {
|
|||
return get_chart_code ($chart, $width, $height, 'include/FusionCharts/FCF_Area2D.swf');
|
||||
}
|
||||
|
||||
// Returns a Pandora FMS agent event chart
|
||||
function fs_module_event_chart ($data, $width, $height, $step = 1, $homedir = '', $rotate_names = 0) {
|
||||
global $config;
|
||||
|
||||
if (sizeof ($data) == 0) {
|
||||
return fs_error_image ();
|
||||
}
|
||||
|
||||
// Generate the XML
|
||||
$chart = new FusionCharts('Area2D', $width, 160);
|
||||
|
||||
$count = 0;
|
||||
$num_vlines = 0;
|
||||
foreach ($data as $name => $value) {
|
||||
|
||||
if (($step >= 1) && ($count++ % $step == 0)) {
|
||||
$show_name = '1';
|
||||
$num_vlines++;
|
||||
} else {
|
||||
$show_name = '0';
|
||||
}
|
||||
$chart->addChartData(1, 'name=' . $name . ';showName=' . $show_name . ';color=' . $value);
|
||||
}
|
||||
|
||||
if ($rotate_names == 0){
|
||||
$chart->setChartParams('numDivLines=0;numVDivLines=0;showNames=1;rotateNames=0;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=0;areaBorderThickness=1;canvasBgColor=9ABD18');
|
||||
}elseif ($rotate_names == 1){
|
||||
$chart->setChartParams('numDivLines=0;numVDivLines=0;showNames=1;rotateNames=1;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=0;areaBorderThickness=1;canvasBgColor=9ABD18');
|
||||
}
|
||||
|
||||
// Return the code
|
||||
return get_chart_code ($chart, $width, 105, $homedir . 'include/FusionCharts/FCF_Area2D.swf');
|
||||
}
|
||||
|
||||
|
||||
// Prints an error image
|
||||
function fs_error_image () {
|
||||
global $config;
|
||||
|
@ -2769,4 +2804,150 @@ function grafico_modulo_log4x_format_y_axis ( $number , $decimals=2, $dec_point=
|
|||
|
||||
return "$n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a graph with event data of module
|
||||
*
|
||||
* @param integer id_module Module ID
|
||||
* @param integer width graph width
|
||||
* @param integer height graph height
|
||||
* @param integer period time period
|
||||
* @param string homeurl Home url if the complete path is needed
|
||||
* @param int Zoom factor over the graph
|
||||
*/
|
||||
function graphic_module_events ($id_module, $width, $height, $period = 0, $homeurl = '', $zoom = 0) {
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
if ($config['flash_charts']) {
|
||||
include_flash_chart_script($homeurl);
|
||||
}
|
||||
|
||||
$data = array ();
|
||||
|
||||
$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
|
||||
|
||||
$interval = (int) ($period / $resolution);
|
||||
$date = get_system_time ();
|
||||
$datelimit = $date - $period;
|
||||
$periodtime = floor ($period / $interval);
|
||||
$time = array ();
|
||||
$data = array ();
|
||||
|
||||
// Set the title and time format
|
||||
if ($period <= 21600) {
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
$time_format = "M d H:i";
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
$time_format = "M d H\h";
|
||||
}
|
||||
else {
|
||||
$time_format = "M d H\h";
|
||||
}
|
||||
|
||||
$legend = array();
|
||||
for ($i = 0; $i < $interval; $i++) {
|
||||
$bottom = $datelimit + ($periodtime * $i);
|
||||
if (! $graphic_type) {
|
||||
$name = date($time_format, $bottom);
|
||||
//$name = date('H\h', $bottom);
|
||||
} else {
|
||||
$name = $bottom;
|
||||
}
|
||||
|
||||
$top = $datelimit + ($periodtime * ($i + 1));
|
||||
|
||||
if ($config['flash_charts']){
|
||||
$criticity = (int) db_get_value_filter ('criticity',
|
||||
'tevento',
|
||||
array ('id_agentmodule' => $id_module,
|
||||
'utimestamp > '.$bottom,
|
||||
'utimestamp < '.$top));
|
||||
|
||||
switch ($criticity) {
|
||||
case 3: $data[$name] = 'E5DF63';
|
||||
break;
|
||||
case 4: $data[$name] = 'FF3C4B';
|
||||
break;
|
||||
default: $data[$name] = '9ABD18';
|
||||
}
|
||||
}else{
|
||||
$event = db_get_row_filter ('tevento',
|
||||
array ('id_agentmodule' => $id_module,
|
||||
'utimestamp > '.$bottom,
|
||||
'utimestamp < '.$top), 'criticity, utimestamp');
|
||||
|
||||
if (!empty($event['utimestamp'])){
|
||||
$data[$cont]['utimestamp'] = $periodtime;
|
||||
switch ($event['criticity']) {
|
||||
case 3: $data[$cont]['data'] = 2;
|
||||
break;
|
||||
case 4: $data[$cont]['data'] = 3;
|
||||
break;
|
||||
default:$data[$cont]['data'] = 1;
|
||||
break;
|
||||
}
|
||||
$current_timestamp = $event['utimestamp'];
|
||||
}
|
||||
else{
|
||||
$data[$cont]['utimestamp'] = $periodtime;
|
||||
$data[$cont]['data'] = 1;
|
||||
$current_timestamp = $bottom;
|
||||
}
|
||||
$legend[] = date($time_format, $current_timestamp);
|
||||
$cont++;
|
||||
}
|
||||
}
|
||||
|
||||
$pixels_between_xdata = 25;
|
||||
$max_xdata_display = round($width / $pixels_between_xdata);
|
||||
$ndata = count($data);
|
||||
if($max_xdata_display > $ndata) {
|
||||
$xdata_display = $ndata;
|
||||
}
|
||||
else {
|
||||
$xdata_display = $max_xdata_display;
|
||||
}
|
||||
|
||||
$step = round($ndata/$xdata_display);
|
||||
|
||||
if ($config['flash_charts']) {
|
||||
return fs_module_event_chart ($data, $width, $height, /*$resolution / 750*/ $step, $homeurl, 1);
|
||||
} else {
|
||||
$colors = array(1 => '#38B800', 2 => '#FFFF00', 3 => '#FF0000', 4 => '#C3C3C3');
|
||||
|
||||
// Draw slicebar graph
|
||||
echo slicesbar_graph($data, $period, $width, 30, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
|
||||
|
||||
// Draw legend
|
||||
echo "<br>";
|
||||
|
||||
//echo "<div id='legend' style='overflow:hidden;'";
|
||||
$count = 0;
|
||||
foreach ($legend as $name => $value) {
|
||||
$file_name = string2image(ui_print_truncate_text($value, 15, false, true, false, '...'), 115, 13, 2, 270, '#FFFFFF', '#696969', 4, 0);
|
||||
|
||||
if (($step >= 1) && ($count++ % $step == 0)) {
|
||||
if ($zoom == 1)
|
||||
echo " ";
|
||||
elseif ($zoom == 2)
|
||||
echo " ";
|
||||
elseif ($zoom == 3)
|
||||
echo " ";
|
||||
elseif ($zoom == 4)
|
||||
echo " ";
|
||||
|
||||
echo html_print_image($file_name, true, array('title' => $value));
|
||||
}
|
||||
}
|
||||
//echo "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -10,7 +10,7 @@ function toggleDiv (divid){
|
|||
}
|
||||
|
||||
function winopeng (url, wid) {
|
||||
open (url, wid,"width=590,height=310,status=no,toolbar=no,menubar=no,scrollbar=no");
|
||||
open (url, wid,"width=590,height=410,status=no,toolbar=no,menubar=no,scrollbar=no");
|
||||
// WARNING !! Internet Explorer DOESNT SUPPORT "-" CARACTERS IN WINDOW HANDLE VARIABLE
|
||||
status =wid;
|
||||
}
|
||||
|
|
|
@ -135,12 +135,13 @@ $draw_events = get_parameter ("draw_events", 0);
|
|||
$graph_type = get_parameter ("type", "sparse");
|
||||
$zoom = get_parameter ("zoom", 1);
|
||||
$baseline = get_parameter ("baseline", 0);
|
||||
$show_events_graph = get_parameter ("show_events_graph", 0);
|
||||
|
||||
if ($zoom > 1) {
|
||||
$height = $height * ($zoom / 2.1);
|
||||
$width = $width * ($zoom / 1.4);
|
||||
|
||||
echo "<script type='text/javascript'>window.resizeTo($width + 10, $height + 80);</script>";
|
||||
echo "<script type='text/javascript'>window.resizeTo($width + 10, $height + 280);</script>";
|
||||
}
|
||||
|
||||
$utime = get_system_time ();
|
||||
|
@ -159,23 +160,36 @@ $urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/';
|
|||
|
||||
// log4x doesnt support flash yet
|
||||
//
|
||||
echo "<br>";
|
||||
switch ($graph_type) {
|
||||
case 'boolean':
|
||||
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
|
||||
$label, null, $draw_alerts, 1, false, $date, false, $urlImage);
|
||||
echo '<br><br><br>';
|
||||
if ($show_events_graph)
|
||||
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom);
|
||||
break;
|
||||
case 'sparse':
|
||||
echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height,
|
||||
$label, null, $draw_alerts, $avg_only, false, $date, '', $baseline,
|
||||
0, true, false, $urlImage);
|
||||
echo '<br><br><br>';
|
||||
if ($show_events_graph)
|
||||
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom);
|
||||
break;
|
||||
case 'string':
|
||||
echo grafico_modulo_string ($id, $period, $draw_events, $width, $height,
|
||||
$label, null, $draw_alerts, 1, false, $date, false, $urlImage);
|
||||
echo '<br><br><br>';
|
||||
if ($show_events_graph)
|
||||
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom);
|
||||
break;
|
||||
case 'log4x':
|
||||
echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height,
|
||||
$label, $unit_name, $draw_alerts, 1, $pure, $date, 1);
|
||||
echo '<br><br><br>';
|
||||
if ($show_events_graph)
|
||||
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom);
|
||||
break;
|
||||
default:
|
||||
echo fs_error_image ('../images');
|
||||
|
@ -183,7 +197,7 @@ switch ($graph_type) {
|
|||
}
|
||||
|
||||
//z-index is 1 because 2 made the calendar show under the divmenu.
|
||||
echo '<div id="divmenu" class="menu" style="z-index:1;"><b>'.__('Pandora FMS Graph configuration menu').'</b><br />'.__('Please, make your changes and apply with the <i>Reload</i> button');
|
||||
echo '<div id="divmenu" class="menu" style="z-index:1; height:280px;"><b>'.__('Pandora FMS Graph configuration menu').'</b><br />'.__('Please, make your changes and apply with the <i>Reload</i> button');
|
||||
echo '<form method="get" action="stat_win.php">';
|
||||
html_print_input_hidden ("id", $id);
|
||||
html_print_input_hidden ("label", $label);
|
||||
|
@ -254,6 +268,11 @@ if ($config['enterprise_installed'] && $graph_type == "sparse") {
|
|||
|
||||
echo '</td><td>';
|
||||
|
||||
echo '</td></tr><tr><td>'.__('Show event graph').'</td><td>';
|
||||
html_print_checkbox ("show_events_graph", 1, (bool) $show_events_graph);
|
||||
|
||||
echo '</td><td>';
|
||||
|
||||
html_print_submit_button ('GO', "submit", false, 'class="sub next"');
|
||||
|
||||
echo '</td></tr></table></form></div></body></html>';
|
||||
|
|
Loading…
Reference in New Issue