From 45adf9728f8b101eb37d51c0e095581b07aa590b Mon Sep 17 00:00:00 2001 From: eric_ross_c Date: Thu, 18 Mar 2010 20:01:48 +0000 Subject: [PATCH] Ported old graphics for the log4x data. * include/Image/Graph/Plot/Bubble.php: New chart type: bubble * include/Image/Graph.php: Add the new bubble chart to the available charts * include/functions.php: Refactoring way to get type of graph from module type * operation/agentes/estado_ultimopaquete.php: Added links to access log4x graphics * include/fgraph.php: Add log4x graphics rutines. * operation/agentes/stat_win.php: Add support to show log4x graphic. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2512 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/include/Image/Graph.php | 3 +- .../include/Image/Graph/Plot/Bubble.php | 317 ++++++++++++++ pandora_console/include/fgraph.php | 403 ++++++++++++++++++ pandora_console/include/functions.php | 26 +- .../agentes/estado_ultimopaquete.php | 38 +- .../operation/agentes/stat_win.php | 9 +- 6 files changed, 771 insertions(+), 25 deletions(-) create mode 100644 pandora_console/include/Image/Graph/Plot/Bubble.php diff --git a/pandora_console/include/Image/Graph.php b/pandora_console/include/Image/Graph.php index 13e3a62f48..bd558bb2e6 100644 --- a/pandora_console/include/Image/Graph.php +++ b/pandora_console/include/Image/Graph.php @@ -397,6 +397,7 @@ class Image_Graph extends Image_Graph_Element 'line' => 'Image_Graph_Plot_Line', 'area' => 'Image_Graph_Plot_Area', + 'bubble' => 'Image_Graph_Plot_Bubble', 'bar' => 'Image_Graph_Plot_Bar', 'smooth_line' => 'Image_Graph_Plot_Smoothed_Line', 'smooth_area' => 'Image_Graph_Plot_Smoothed_Area', @@ -848,4 +849,4 @@ class Image_Graph extends Image_Graph_Element } } -?> \ No newline at end of file +?> diff --git a/pandora_console/include/Image/Graph/Plot/Bubble.php b/pandora_console/include/Image/Graph/Plot/Bubble.php new file mode 100644 index 0000000000..387f741c81 --- /dev/null +++ b/pandora_console/include/Image/Graph/Plot/Bubble.php @@ -0,0 +1,317 @@ + + * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id: Area.php,v 1.13 2005/11/27 22:21:17 nosey Exp $ + * @link http://pear.php.net/package/Image_Graph + */ + +/** + * Include file Image/Graph/Plot.php + */ +require_once 'Image/Graph/Plot.php'; + +/** + * Bubble Chart plot. + * + * An area chart plots all data points similar to a {@link + * Image_Graph_Plot_Line}, but the area beneath the line is filled and the whole + * area 'the-line', 'the right edge', 'the x-axis' and 'the left edge' is + * bounded. Smoothed charts are only supported with non-stacked types + * + * @category Images + * @package Image_Graph + * @subpackage Plot + * @author Eric Ross + * @copyright Copyright (C) 2007 Eric Ross + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: 0.7.2 + * @link http://pear.php.net/package/Image_Graph + */ +class Image_Graph_Plot_Bubble extends Image_Graph_Plot +{ + var $_only_minmax = true; + + function Image_Graph_Plot_Bubble(&$dataset, $only_minmax = false) + { + $this->_only_minmax = $only_minmax; + + parent::Image_Graph_Plot($dataset); + } + + /** + * Perform the actual drawing on the legend. + * + * @param int $x0 The top-left x-coordinate + * @param int $y0 The top-left y-coordinate + * @param int $x1 The bottom-right x-coordinate + * @param int $y1 The bottom-right y-coordinate + * @access private + */ + function _drawLegendSample($x0, $y0, $x1, $y1) + { + if ($this->_only_minmax) + return; + + + $x = ($x0 + $x1) / 2; + $y = ($y0 + $y1) / 2; + + $rx = abs($x0 - $x1) / 2.0; + $ry = abs($y0 - $y1) / 2.0; + + $fill = $this->_fillStyle->_getFillStyle(-1); + $this->_canvas->ellipse(array( + 'x' => $x, + 'y' => $y, + 'rx' => $rx, + 'ry' => $ry, + 'fill' => $fill, + 'line' => 'black' + ) + ); + } + + + /** + * Output the plot + * + * @return bool Was the output 'good' (true) or 'bad' (false). + * @access private + */ +function _done() +{ + if (parent::_done() === false) { + return false; + } + + if ($this->_only_minmax) + return $this->_drawMinMax(); + + $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); + + $this->_clip(true); + + $index = 0; + + $canvas_width = $this->_canvas->getWidth(); + $graph_width = $this->_right - $this->_left; + $graph_height = $this->_bottom - $this->_top; + + $num_datasets = count($this->_dataset); + $y_step = $graph_height / ($num_datasets + 1); + + $keys = array_keys($this->_dataset); + + foreach ($keys as $key) { + $dataset =& $this->_dataset[$key]; + + $dataset->_reset(); + + $fill = $this->_fillStyle->_getFillStyle(-1); + + while ($point = $dataset->_next()) { + //$pivot = $point['X']; + $y = $point['Y']; + $size = $point['data']['size']; + $x = $point['data']['x']; + + // x is the % from the left border (0% = full left; 100% = full right) + $x = $this->_left + $x * $graph_width / 100.0; + + // y is the number of steps (the number of the dataset) zero based + $y = $this->_bottom - ($y + 1) * $y_step; + + $this->_canvas->ellipse(array( + 'x' => $x, + 'y' => $y, + 'rx' => $size, + 'ry' => $size, + 'fill' => $fill, + 'line' => 'black' + ) + ); + /* + if (isset($this->_callback)) { + call_user_func($this->_callback, array( 'event' => 'bubble', + 'x' => $x, + 'y' => $y, + 'rx' => $size, + 'ry' => $size, + 'value' => $point['data']['value'] + ) + ); + } + */ + } + $index++; + } + unset($keys); + + + $this->_drawMarker(); + $this->_clip(false); + + $this->_canvas->endGroup(); + + return true; +} + +function getTextWidth($str) +{ + return $this->_canvas->textWidth($str); +} + +function _drawMinMax() +{ + $this->_canvas->startGroup(get_class($this) . '_' . $this->_title); + + $this->_clip(true); + + $index = 0; + + $canvas_width = $this->_canvas->getWidth(); + $graph_width = $this->_right - $this->_left; + $graph_height = $this->_bottom - $this->_top; + + $num_datasets = count($this->_dataset); + $y_step = $graph_height / ($num_datasets + 1); + + $keys = array_keys($this->_dataset); + + $max_value = -1; + $max_size = -1; + $min_value = 999999; + $min_size = 100; + $avg_value = 0; + $avg_size = 1; + $count = 0; + + foreach ($keys as $key) { + $dataset =& $this->_dataset[$key]; + + $dataset->_reset(); + + while ($point = $dataset->_next()) { + //$pivot = $point['X']; + //$y = $point['Y']; + $value = $point['data']['value']; + $size = $point['data']['size']; + //$x = $point['data']['x']; + + if ($value > $max_value) { + $max_value = $value; + $max_size = $size; + } + if ($value < $min_value) { + $min_value = $value; + $min_size = $size; + } + $avg_value += $value; + $avg_size += $size; + + $count++; + } + } + + $avg_value /= $count == 0 ? 1 : $count; + $avg_size /= $count == 0 ? 1 : $count; + + unset($keys); + + $xs = array(0, 0, 0); + $y = 0; + $fills = array("gray", "gray", "gray"); + $sizes = array($min_size, $avg_size, $max_size); + $values = array($min_value, $avg_value, $max_value); + $titles = array("Min", "Prom", "Max"); + + for($i=0;$i<3;$i++) { + + $x = $this->_left + $xs[$i]; + + $this->_canvas->setFont($this->_getFont()); + + $this->_canvas->addText(array( + "x" => $x, + "y" => $this->_top + $y, + "text" => $titles[$i], + "color" => "black", + ) + ); + + $textHeight = $this->_canvas->textWidth($titles[$i]); + $x += $textHeight + $sizes[$i] + 6; + + + $ye = $y + $this->_canvas->textHeight($titles[$i]) / 2.0; + + $this->_canvas->ellipse(array( + 'x' => $x, + 'y' => $this->_top + $ye, + 'rx' => $sizes[$i], + 'ry' => $sizes[$i], + 'fill' => $fills[$i], + 'line' => 'black' + ) + ); + + $x += $sizes[$i] + 6; + + $this->_canvas->setFont($this->_getFont()); + $txt = "" . round($values[$i]); + $this->_canvas->addText(array( + "x" => $x, + "y" => $this->_top + $y, + "text" => $txt, + "color" => "black", + ) + ); + + $yOld = $y; + + $y += $textHeight / 2.0; + $y += $sizes[$i]; + $y += ($i < 2 ? $sizes[$i + 1] : 0); + $y -= ($i < 2 ? $this->_canvas->textHeight($titles[$i+1]) : 0); + + if ($y < $yOld + $textHeight) + $y = $yOld + $textHeight; + } + + $this->_drawMarker(); + $this->_clip(false); + + $this->_canvas->endGroup(); + return true; +} + + +} + + + + +?> diff --git a/pandora_console/include/fgraph.php b/pandora_console/include/fgraph.php index 63c01042db..27732d6e1d 100644 --- a/pandora_console/include/fgraph.php +++ b/pandora_console/include/fgraph.php @@ -1671,6 +1671,405 @@ function grafico_modulo_string ($id_agente_modulo, $period, $show_event, return; } +function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event, + $width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0, + $date = 0) +{ + + grafico_modulo_log4x_trace("
");
+
+        $now = time();
+        $fechatope = $now - $periodo; // limit date
+
+	$nombre_agente = get_agentmodule_agent_name ($id_agente_modulo);
+	$nombre_modulo = get_agentmodule_name ($id_agente_modulo);
+	$id_agente = get_agent_id ($nombre_agente);
+
+
+        $one_second = 1;
+        $one_minute = 60 * $one_second;
+        $one_hour = 60 * $one_minute;
+        $one_day = 24 * $one_hour;
+        $one_week = 7 * $one_day;
+
+        $adjust_time = $one_minute; // 60 secs
+
+        if ($periodo == 86400) // day
+                $adjust_time = $one_hour;
+        elseif ($periodo == 604800) // week
+                $adjust_time =$one_day;
+        elseif ($periodo == 3600) // hour
+                $adjust_time = 10 * $one_minute;
+        elseif ($periodo == 2419200) // month
+                $adjust_time = $one_week;
+        else
+                $adjust_time = $periodo / 12.0;
+
+        $num_slices = $periodo / $adjust_time;
+
+        $fechatope_index = grafico_modulo_log4x_index($fechatope, $adjust_time);
+
+        $sql1="SELECT utimestamp, SEVERITY " .
+                " FROM tagente_datos_log4x " .
+                " WHERE id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope and utimestamp < $now";
+
+        $valores = array();
+
+        $max_count = -1;
+        $min_count = 9999999;
+
+        grafico_modulo_log4x_trace("$sql1");
+
+        $rows = 0;
+        $result=mysql_query($sql1);
+        while ($row=mysql_fetch_array($result)){
+                $rows++;
+                $utimestamp = $row[0];
+                $severity = $row[1];
+                $severity_num = $row[2];
+
+                if (!isset($valores[$severity]))
+                        $valores[$severity] = array();
+
+                $dest = grafico_modulo_log4x_index($utimestamp, $adjust_time);
+
+                $index = (($dest - $fechatope_index) / $adjust_time) - 1;
+
+                if (!isset($valores[$severity][$index])) {
+                        $valores[$severity][$index] = array();
+                        $valores[$severity][$index]['pivot'] = $dest;
+                        $valores[$severity][$index]['count'] = 0;
+                        $valores[$severity][$index]['alerts'] = 0;
+                }
+
+                $valores[$severity][$index]['count']++;
+
+                $max_count = max($max_count, $valores[$severity][$index]['count']);
+                $min_count = min($min_count, $valores[$severity][$index]['count']);
+        }
+
+        grafico_modulo_log4x_trace("$rows rows");
+
+        // Create graph
+        // *************
+
+        grafico_modulo_log4x_trace(__LINE__);
+
+	//set_error_handler("myErrorHandler");
+
+        grafico_modulo_log4x_trace(__LINE__);
+	set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . "/../../include");
+
+	require_once 'Image/Graph.php';
+
+        grafico_modulo_log4x_trace(__LINE__);
+
+        $Graph =& Image_Graph::factory('graph', array($width, $height));
+ 
+        grafico_modulo_log4x_trace(__LINE__);
+
+
+
+
+
+        // add a TrueType font
+        $Font =& $Graph->addNew('font', $config['fontpath']); // C:\WINNT\Fonts\ARIAL.TTF
+        $Font->setSize(7);
+
+        $Graph->setFont($Font);
+
+        if ($periodo == 86400)
+                $title_period = $lang_label["last_day"];
+        elseif ($periodo == 604800)
+                $title_period = $lang_label["last_week"];
+        elseif ($periodo == 3600)
+                $title_period = $lang_label["last_hour"];
+        elseif ($periodo == 2419200)
+                $title_period = $lang_label["last_month"];
+        else {
+                $suffix = $lang_label["days"];
+                $graph_extension = $periodo / (3600*24); // in days
+
+                if ($graph_extension < 1) {
+                        $graph_extension = $periodo / (3600); // in hours
+                        $suffix = $lang_label["hours"];
+                }
+                //$title_period = "Last ";
+                $title_period = format_numeric($graph_extension,2)." $suffix";
+        }
+
+        $title_period = html_entity_decode($title_period);
+
+        grafico_modulo_log4x_trace(__LINE__);
+
+        if ($pure == 0){
+                $Graph->add(
+                        Image_Graph::horizontal(
+                                Image_Graph::vertical(
+                                        Image_Graph::vertical(
+                                                $Title = Image_Graph::factory('title', array('   Pandora FMS Graph - '.strtoupper($nombre_agente)." - " .$title_period, 10)),
+                                                $Subtitle = Image_Graph::factory('title', array('     '.$title, 7)),
+                                                90
+                                        ),
+                                        $Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')),
+                                        15 // If you change this, change the 0.85 below
+                                ),
+                                Image_Graph::vertical(
+                                        $Legend = Image_Graph::factory('legend'),
+                                        $PlotareaMinMax = Image_Graph::factory('plotarea'),
+                                        65
+                                ),
+                                85 // If you change this, change the 0.85 below
+                        )
+                );
+
+                $Legend->setPlotarea($Plotarea);
+                $Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
+                $Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
+        } else { // Pure, without title and legends
+                $Graph->add($Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')));
+        }
+
+        grafico_modulo_log4x_trace(__LINE__);
+
+        $dataset = array();
+
+        $severities = array("FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE");
+        $colors = array("black", "red", "orange", "yellow", "#3300ff", 'magenta');
+
+        $max_bubble_radius = $height * 0.6 / (count($severities) + 1); // this is the size for the max_count
+        $y = count($severities) - 1;
+        $i = 0;
+
+        foreach($severities as $severity) {
+                $dataset[$i] = Image_Graph::factory('dataset');
+                $dataset[$i]->setName($severity);
+
+                if (isset($valores[$severity])){
+                        $data =& $valores[$severity];
+                        while (list($index, $data2) = each($data)) {
+                                $count = $data2['count'];
+                                $pivot = $data2['pivot'];
+
+                                //$x = $scale * $index;
+                                $x = 100.0 * ($pivot - $fechatope) / ($now - $fechatope);
+                                if ($x > 100) $x = 100;
+
+                                $size = grafico_modulo_log4x_bubble_size($count, $max_count, $max_bubble_radius);
+
+                                // pivot is the value in the X axis
+                                // y is the number of steps (from the bottom of the graphics) (zero based)
+                                // x is the position of the bubble, in % from the left (0% = full left, 100% = full right)
+                                // size is the radius of the bubble
+                                // value is the value associated with the bubble (needed to calculate the leyend)
+                                //
+                                $dataset[$i]->addPoint($pivot, $y, array("x" => $x, "size" => $size, "value" => $count));
+                        }
+                } else {
+                        // There's a problem when we have no data ...
+                        // This was the first try.. didnt work
+                        //$dataset[$i]->addPoint($now, -1, array("x" => 0, "size" => 0));
+                }
+
+                $y--;
+                $i++;
+        }
+
+        grafico_modulo_log4x_trace(__LINE__);
+
+        // create the 1st plot as smoothed area chart using the 1st dataset
+        $Plot =& $Plotarea->addNew('bubble', array(&$dataset));
+        $Plot->setFont($Font);
+
+        $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
+        $AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_x_axis'));
+        $AxisX->forceMinimum($fechatope);
+        $AxisX->forceMaximum($now);
+
+        $minIntervalWidth = $Plot->getTextWidth("88/88/8888");
+        $interval_x = $adjust_time;
+
+        while (true) {
+                $intervalWidth = $width * 0.85 * $interval_x/ $periodo;
+                if ($intervalWidth >= $minIntervalWidth)
+                        break;
+
+                $interval_x *= 2;
+        }
+
+        $AxisX->setLabelInterval($interval_x);
+        $AxisX->setLabelOption("showtext",true);
+
+        //*
+        $GridY2 =& $Plotarea->addNew('line_grid');
+        $GridY2->setLineColor('gray');
+        $GridY2->setFillColor('lightgray@0.05');
+        $GridY2->_setPrimaryAxis($AxisX);
+        //$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Dotted', array("white", "gray", "gray", "gray")));
+        $GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
+        //*/
+        //grafico_modulo_log4x_trace(print_r($AxisX, true));
+
+        $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
+        $AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_y_axis'));
+        $AxisY->setLabelOption("showtext",true);
+        //$AxisY->setLabelInterval(0);
+        //$AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO);
+
+        //*
+        $GridY2 =& $Plotarea->addNew('line_grid');
+        $GridY2->setLineColor('gray');
+        $GridY2->setFillColor('lightgray@0.05');
+        $GridY2->_setPrimaryAxis($AxisY);
+        $GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
+        //*/
+
+        $AxisY->forceMinimum(0);
+        $AxisY->forceMaximum(count($severities) + 1) ;
+
+        // set line colors
+        $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
+
+        $Plot->setFillStyle($FillArray);
+        foreach($colors as $color)
+                $FillArray->addColor($color);
+
+        grafico_modulo_log4x_trace(__LINE__);
+
+        $FillArray->addColor('green@0.6');
+        //$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
+
+        // Show events !
+        if ($show_event == 1){
+                $Plot =& $Plotarea->addNew('Plot_Impulse', array($dataset_event));
+                $Plot->setLineColor( 'red' );
+                $Marker_event =& Image_Graph::factory('Image_Graph_Marker_Cross');
+                $Plot->setMarker($Marker_event);
+                $Marker_event->setFillColor( 'red' );
+                $Marker_event->setLineColor( 'red' );
+                $Marker_event->setSize ( 5 );
+        }
+
+        $Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_X);
+        $Axis->Hide();
+        $Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_Y);
+        $Axis->Hide();
+
+        $plotMinMax =& $PlotareaMinMax->addNew('bubble', array(&$dataset, true));
+
+        grafico_modulo_log4x_trace(__LINE__);
+
+        $Graph->done();
+
+        grafico_modulo_log4x_trace(__LINE__);
+
+
+	//$image = "../../include/fgraph.php?tipo=graphic_error";
+        //grafico_modulo_log4x_trace(__LINE__);
+	//print_image ($image, false, array ("border" => 0));
+        //grafico_modulo_log4x_trace(__LINE__);
+}
+
+function grafico_modulo_log4x_index($x, $interval)
+{
+        return $x + $interval - (($x - 1) % $interval) - 1;
+}
+
+function grafico_modulo_log4x_trace($str)
+{
+        //echo "$str\n";
+}
+
+function grafico_modulo_log4x_bubble_size($count, $max_count, $max_bubble_radius)
+{
+        //Superformula de ROA
+        $r0 = 1.5;
+        $r1 = $max_bubble_radius;
+        $v2 = pow($max_count,1/2.0);
+
+        return $r1*pow($count,1/2.0)/($v2)+$r0;
+
+
+         // Esta custion no sirve paaaaaaaaaaaa naaaaaaaaaaaaaaaadaaaaaaaaaaaaaa
+         //Cementerio de formulas ... QEPD
+        $a = pow(($r1 - $r0)/(pow($v2,1/4.0)-1),4);
+        $b = $r0 - pow($a,1/4.0);
+
+        return pow($a * $count, 1/4.0) + $b;
+
+        $r = pow($count / pow(3.1415, 3), 0.25);
+
+        $q = 0.9999;
+        $x = $count;
+        $x0 = $max_count;
+        $y0 = $max_size;
+
+        $y = 4 * $y0 * $x * (((1 - 2 * $q) / (2 * $x0))* $x + ((4 * $q - 1) / 4)) / $x0;
+
+        return $y;
+
+        return 3 * (0.3796434104 + pow($count * 0.2387394557, 0.333333333));
+
+        return sqrt($count / 3.1415);
+        return 5 + log($count);
+}
+
+function grafico_modulo_log4x_format_x_axis ( $number , $decimals=2, $dec_point=".", $thousands_sep=",")
+{
+        // $number is the unix time in the local timezone
+
+        //$dtZone = new DateTimeZone(date_default_timezone_get());
+        //$d = new DateTime("now", $dtZone);
+        //$offset = $dtZone->getOffset($d);
+        //$number -= $offset;
+
+        return date("d/m", $number) . "\n" . date("H:i", $number);
+}
+
+function grafico_modulo_log4x_format_y_axis ( $number , $decimals=2, $dec_point=".", $thousands_sep=",")
+{
+        $n = "";
+
+        switch($number) {
+        case 6: $n = "FATAL"; break;
+        case 5: $n = "ERROR"; break;
+        case 4: $n = "WARN"; break;
+        case 3: $n = "INFO"; break;
+        case 2: $n = "DEBUG"; break;
+        case 1: $n = "TRACE"; break;
+        }
+
+        return "$n";
+}
+
+function myErrorHandler($errno, $errstr, $errfile, $errline)
+{
+    switch ($errno) {
+    case E_USER_ERROR:
+        echo "My ERROR [$errno] $errstr
\n"; + echo " Fatal error on line $errline in file $errfile"; + echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")
\n"; + echo "Aborting...
\n"; + exit(1); + break; + + case E_USER_WARNING: + echo "My WARNING [$errno] $errstr
\n"; + break; + + case E_USER_NOTICE: + echo "My NOTICE [$errno] $errstr
\n"; + break; + + default: + echo "[$errno] $errfile:$errline $errstr
\n"; + break; + } + + /* Don't execute PHP internal error handler */ + return true; +} + // ************************************************************************** // ************************************************************************** // MAIN Code - Parse get parameters @@ -1813,6 +2212,10 @@ if ($graphic_type) { grafico_modulo_string ($id, $period, $draw_events, $width, $height, $label, $unit_name, $draw_alerts, $avg_only, $pure, $date); break; + case 'log4x': + grafico_modulo_log4x ($id, $period, $draw_events, $width, $height, $label, $unit_name, $draw_alerts, $avg_only, $pure, $date); + break; + case 'graphic_error': default: graphic_error (); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index bdec4bd877..a48499925d 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -979,21 +979,25 @@ function index_array ($array, $index = 'id', $value = 'name') { */ function return_graphtype ($id_module_type){ - - if (($id_module_type == 3) - OR ($id_module_type == 10) - OR ($id_module_type == 17) - OR ($id_module_type == 23)){ + switch($id_module_type){ + case 3: + case 10: + case 17: + case 23: return "string"; - } - elseif (($id_module_type == 2) - OR ($id_module_type == 6) - OR ($id_module_type == 21) - OR ($id_module_type == 18) - OR ($id_module_type == 9)) { + + case 2: + case 6: + case 21: + case 18: + case 9: return "boolean"; + + case 30: + return "log4x"; } + return "sparse"; } diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index 3271cc0164..8bd3cb3024 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -123,6 +123,7 @@ foreach ($modules as $module) { print_moduletype_icon ($module["id_tipo_modulo"]); echo ""; + if ($module["module_interval"] != 0){ echo $module["module_interval"]; $real_interval = $module["module_interval"]; @@ -143,25 +144,37 @@ foreach ($modules as $module) { echo ""; } - if ($module["id_tipo_modulo"] == 30) { - echo " "; + if ($module["id_tipo_modulo"] == 30112) { + echo " "; + echo " x"; } else if (($module["id_tipo_modulo"] == 100) OR ($module['history_data'] == 0)) { echo ""; echo substr(safe_output($module["datos"]),0,12); } else { - $graph_type = return_graphtype ($module["id_tipo_modulo"]); - if (is_numeric($module["datos"])){ - echo ""; - echo format_for_graph($module["datos"] ); - } - else { - if (strlen($module["datos"]) > 0 ) $colspan = 2; - else $colspan= 1; - echo ""; - echo substr(safe_output($module["datos"]),0,42); + + if ($module["id_tipo_modulo"] == 30) { // log4x + switch($module["datos"]){ + case 10: echo "TRACE"; break; + case 20: echo "DEBUG"; break; + case 30: echo "INFO"; break; + case 40: echo "WARN"; break; + case 50: echo "ERROR"; break; + case 60: echo "FATAL"; break; + } + } else { + if (is_numeric($module["datos"])){ + echo ""; + echo format_for_graph($module["datos"] ); + } + else { + if (strlen($module["datos"]) > 0 ) $colspan = 2; + else $colspan= 1; + echo ""; + echo substr(safe_output($module["datos"]),0,42); + } } @@ -181,6 +194,7 @@ foreach ($modules as $module) { $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=3600&id=".$module["id_agente_modulo"]."&label=".$graph_label."&refresh=60','hour_".$win_handle."')"; echo ''; + } diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index dd4363e98e..82ce1cdc23 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -135,7 +135,9 @@ if ($start_date != $current) else $date = $utime; -if ($config['flash_charts']) { +// log4x doesnt support flash yet +// +if ($config['flash_charts'] && $graph_type != "log4x") { switch ($graph_type) { case 'sparse': echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height, $label, $unit_name, $draw_alerts, $avg_only, $pure, $date); @@ -147,6 +149,11 @@ if ($config['flash_charts']) { case 'string': echo grafico_modulo_string ($id, $period, $draw_events, $width, $height, $label, $unit_name, $draw_alerts, 1, $pure, $date, 1); break; + + case 'log4x': echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height, + $label, $unit_name, $draw_alerts, 1, $pure, $date, 1); + break; + default: echo fs_error_image ('../images'); } }