diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 926b5fc198..ccd0eb3136 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,27 @@ +2007-08-06 Sancho Lerena + + * include/functions_db.php: Fixed unsorted render (E.Ross). + + * index.php: Several fixes from E.Ross and me (HTTP port, REFR bug + #1756143). + + * status_monitor.php: Small fixes for SQL sentences (E.Ross). + + * estado_grupo.php: Small fixes for SQL sentnces (E.Ross). + + * estado_ultimopaquete.php: Fix to use boolean graph from E.Ross. + + * fgraph.php: Use simplified version of sparse to make a more + quick and simplified version of graph, useful for Boolean types + (E.Ross). + + * stat_win.php: Fixed problem with resizing (E.Ross). + + * godmode/groups/configure_group.php: Fixed code for Non-dependant + groups (E.Ross). + + * login_page.php: Fixes for non 80 HTTP port (E.Ross). + 2007-08-06 Sancho Lerena * CSS Fixes (min height). diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index c439e45d08..99f9fdba9b 100644 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -17,6 +17,18 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +$addr = ""; +if (isset($_GET['sec'])){ + $addr = 'http://' . $_SERVER['SERVER_NAME']; // TODO: check https + + if ($_SERVER['SERVER_PORT'] != 80) + $addr .= ":" . $_SERVER['SERVER_PORT']; + + $addr .= $_SERVER['REQUEST_URI']; + + $addr = urlencode($addr); +} + ?>

@@ -30,7 +42,7 @@ Login
- + Password
@@ -40,8 +52,16 @@ + + 0) { ?> + +
'.$REMOTE_ADDR.''; ?>
- \ No newline at end of file + + + diff --git a/pandora_console/godmode/groups/configure_group.php b/pandora_console/godmode/groups/configure_group.php index 2353c2018b..aa77e7a187 100644 --- a/pandora_console/godmode/groups/configure_group.php +++ b/pandora_console/godmode/groups/configure_group.php @@ -119,6 +119,7 @@ sec2=godmode/groups/group_list"> $id_grupo2 = $row["id_grupo"]; echo ""; $sql='SELECT DISTINCT nombre FROM tagente_modulo - WHERE (id_tipo_modulo = 2) - OR (id_tipo_modulo = 9) - OR (id_tipo_modulo = 12) - OR (id_tipo_modulo = 18) - OR (id_tipo_modulo = 6) '; + WHERE id_tipo_modulo in (2, 9, 12, 18, 6, 100)'; $result=mysql_query($sql); while ($row=mysql_fetch_array($result)){ echo ""; @@ -100,8 +96,7 @@ if (comprueba_login() == 0) { // Show only selected names & groups if ($ag_group > 1) - $sql='SELECT * FROM tagente WHERE id_grupo='.$ag_group.' - ORDER BY nombre'; + $sql='SELECT * FROM tagente WHERE id_grupo='.$ag_group.' ORDER BY nombre'; else $sql='SELECT * FROM tagente ORDER BY id_grupo, nombre'; @@ -112,27 +107,19 @@ if (comprueba_login() == 0) { if (mysql_num_rows($result)){ while ($row=mysql_fetch_array($result)){ //while there are agents if ($row["disabled"] == 0) { - if ((isset($ag_modulename)) && ($ag_modulename != "ALL")) + if ((isset($ag_modulename)) && ($ag_modulename != $lang_label["all"])) $query_gen='SELECT * FROM tagente_modulo WHERE id_agente = '.$row["id_agente"].' AND nombre = "'.entrada_limpia($_POST["ag_modulename"]).'" - AND ( - (id_tipo_modulo = 2) - OR (id_tipo_modulo = 9) - OR (id_tipo_modulo = 12) - OR (id_tipo_modulo = 18) - OR (id_tipo_modulo = 6) - )'; + AND + id_tipo_modulo in (2, 9, 12, 18, 6)'; + // generic_proc, remote_tcp_proc, ??, remote_snmp_proc, remote_icmp_proc else $query_gen='SELECT * FROM tagente_modulo WHERE id_agente = '.$row["id_agente"].' - AND ( - (id_tipo_modulo = 2) - OR (id_tipo_modulo = 9) - OR (id_tipo_modulo = 12) - OR (id_tipo_modulo = 18) - OR (id_tipo_modulo = 6) - )'; + AND + id_tipo_modulo in (2, 9, 12, 18, 6) '; + $result_gen=mysql_query($query_gen); if (mysql_num_rows ($result_gen)) { while ($data=mysql_fetch_array($result_gen)){ diff --git a/pandora_console/reporting/fgraph.php b/pandora_console/reporting/fgraph.php index 7a59e56e0c..8e2cbdbeb5 100644 --- a/pandora_console/reporting/fgraph.php +++ b/pandora_console/reporting/fgraph.php @@ -1592,6 +1592,310 @@ function odo_tactic ($value1, $value2, $value3){ $Graph->done(); } +function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event, + $width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0 ) { + + include ("../include/config.php"); + require ("../include/languages/language_".$language_code.".php"); + require_once 'Image/Graph.php'; + + $resolution = $config_graph_res * 50; // Number of "slices" we want in graph + + //$unix_timestamp = strtotime($mysql_timestamp) // Convert MYSQL format tio utime + $fechatope = time() - $periodo; // limit date + $horasint = $periodo / $resolution; // Each intervalo is $horasint seconds length + $nombre_agente = dame_nombre_agente_agentemodulo($id_agente_modulo); + $id_agente = dame_agente_id($nombre_agente); + $nombre_modulo = dame_nombre_modulo_agentemodulo($id_agente_modulo); + + if ($show_event == 1) + $real_event = array(); + + if ($show_alert == 1){ + $alert_high = 0; + $alert_low = 10000000; + // If we want to show alerts limits + $sql1="SELECT * FROM talerta_agente_modulo where id_agente_modulo = ".$id_agente_modulo; + $result=mysql_query($sql1); + while ($row=mysql_fetch_array($result)){ + if ($row["dis_max"] > $alert_high) + $alert_high = $row["dis_max"]; + if ($row["dis_min"] < $alert_low) + $alert_low = $row["dis_min"]; + } + // if no valid alert defined to render limits, disable it + if (($alert_low == 10000000) && ($alert_high == 0)){ + $show_alert = 0; + } + } + + // intervalo - This is the number of "rows" we are divided the time + // to fill data. more interval, more resolution, and slower. + // periodo - Gap of time, in seconds. This is now to (now-periodo) secs + + // Init tables + for ($x = 0; $x <= $resolution; $x++) { + $valores[$x][0] = 0; // SUM of all values for this interval + $valores[$x][1] = 0; // counter + $valores[$x][2] = $fechatope + ($horasint * $x); // [2] Top limit for this range + $valores[$x][3] = $fechatope + ($horasint*($x+1)); // [3] Botom limit + $valores[$x][4] = -1; // MIN + $valores[$x][5] = -1; // MAX + $valores[$x][6] = -1; // Event + } + // Init other general variables + if ($show_event == 1){ + // If we want to show events in graphs + $sql1="SELECT utimestamp FROM tevento WHERE id_agente = $id_agente AND utimestamp > $fechatope"; + $result=mysql_query($sql1); + while ($row = mysql_fetch_array($result)){ + $utimestamp = $row[0]; + for ($i=0; $i <= $resolution; $i++) { + if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){ + $real_event[$i]=1; + } + } + } + } + // Init other general variables + $max_value = 0; + $min_value = 0; + + // DEBUG ONLY (to get number of items for this graph) + /* + // Make "THE" query. Very HUGE. + $sql1="SELECT COUNT(datos) FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp > fechatope"; + $result=mysql_query($sql1); + $row=mysql_fetch_array($result); + $title=$title." [C] ".$row[0]; + */ + $previous=0; + // Get the first data outsite (to the left---more old) of the interval given + $sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp < $fechatope ORDER BY utimestamp DESC LIMIT 1"; + $result=mysql_query($sql1); + if ($row=mysql_fetch_array($result)) + $previous=$row[0]; + + $sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope"; + //echo "$sql1
"; + $result=mysql_query($sql1); + while ($row=mysql_fetch_array($result)){ + $datos = $row[0]; + $utimestamp = $row[1]; + + $i = round(($utimestamp - $fechatope) / $horasint); + + //echo "$datos $utimestamp at $i
"; + + $valores[$i][0] += $datos; + $valores[$i][1]++; + + if ($valores[$i][6] == -1) + $valores[$i][6]=$datos; + + // Init min value + if ($valores[$i][4] == -1) + $valores[$i][4] = $datos; + else { + // Check min value + if ($datos < $valores[$i][4]) + $valores[$i][4] = $datos; + } + // Check max value + if ($valores[$i][5] == -1) + $valores[$i][5] = $datos; + else + if ($datos > $valores[$i][5]) + $valores[$i][5] = $datos; + } + + + $last = $previous; + // Calculate Average value for $valores[][0] + for ($x =0; $x <= $resolution; $x++) { + //echo $valores[$x][6] . ", (" . $valores[$x][4] . ", " . $valores[$x][5] . ") : "; + + if ($valores[$x][6] == -1) + $valores[$x][6] = $last; + else + $valores[$x][6] = $valores[$x][4]; // min + + $last = $valores[$x][5] != -1 ? $valores[$x][5] : $valores[$x][6]; // max + + if ($valores[$x][1] > 0) + $valores[$x][0] = $valores[$x][0]/$valores[$x][1]; + else { + $valores[$x][0] = $previous; + $valores[$x][4] = $previous; + $valores[$x][5] = $previous; + } + // Get max value for all graph + if ($valores[$x][5] > $max_value) + $max_value = $valores[$x][5]; + // Take prev. value + // TODO: CHeck if there are more than 24hours between + // data, if there are > 24h, module down. + $previous = $valores[$x][0]; + + //echo $valores[$x][6]; + //echo "
"; + } +//exit; + // Create graph + // ************* + $Graph =& Image_Graph::factory('graph', array($width, $height)); + // add a TrueType font + $Font =& $Graph->addNew('font', $config_fontpath); + $Font->setSize(6); + $Graph->setFont($Font); + + if ($periodo == 86400) + $title_period = "Last day"; + elseif ($periodo == 604800) + $title_period = "Last week"; + elseif ($periodo == 3600) + $title_period = "Last hour"; + elseif ($periodo == 2419200) + $title_period = "Last month"; + else + $title_period = "Last ".format_numeric(($periodo / (3600*24)),2)." days"; + if ($pure == 0){ + $Graph->add( + 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 + ), + Image_Graph::horizontal( + $Plotarea = Image_Graph::factory('plotarea'), + $Legend = Image_Graph::factory('legend'), + 85 + ), + 15) + ); + $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')); + } + // Create the dataset + // Merge data into a dataset object (sancho) + // $Dataset =& Image_Graph::factory('dataset'); + /* + if ($avg_only == 1) { + $dataset[0] = Image_Graph::factory('dataset'); + $dataset[0]->setName("Avg."); + } else { + $dataset[0] = Image_Graph::factory('dataset'); + $dataset[0]->setName("Max."); + $dataset[1] = Image_Graph::factory('dataset'); + $dataset[1]->setName("Avg."); + $dataset[2] = Image_Graph::factory('dataset'); + $dataset[2]->setName("Min."); + } + */ + $dataset[0] = Image_Graph::factory('dataset'); + $dataset[0]->setName("Value"); + + // Event dataset creation + if ($show_event == 1){ + $dataset_event = Image_Graph::factory('dataset'); + $dataset_event -> setName("Event Fired"); + } + // ... and populated with data ... + for ($cc=0; $cc <= $resolution; $cc++) { + $tdate = date('d/m', $valores[$cc][2])."\n".date('H:i', $valores[$cc][2]); + /* + if ($avg_only == 0) { + $dataset[1]->addPoint($tdate, $valores[$cc][0]); + $dataset[0]->addPoint($tdate, $valores[$cc][5]); + $dataset[2]->addPoint($tdate, $valores[$cc][4]); + } else { + $dataset[0]->addPoint($tdate, $valores[$cc][6]); // 0:average 4:min 5:max 6:event + } + */ + $dataset[0]->addPoint($tdate, $valores[$cc][6]); + + if (($show_event == 1) AND (isset($real_event[$cc]))) { + $dataset_event->addPoint($tdate, $valores[$cc][5]); + } + } + + if ($max_value > 0){ + // Show alert limits + if ($show_alert == 1){ + $Plot =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', IMAGE_GRAPH_AXIS_Y); + $Plot->setFillColor( 'blue@0.1' ); + $Plot->setLowerBound( $alert_low); + $Plot->setUpperBound( $alert_high ); + } + + // create the 1st plot as smoothed area chart using the 1st dataset + $Plot =& $Plotarea->addNew('area', array(&$dataset)); + if ($avg_only == 1){ + $Plot->setLineColor('black@0.1'); + } else { + $Plot->setLineColor('yellow@0.2'); + } + + $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); + // $AxisX->Hide(); + + $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); + $AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'format_for_graph')); + $AxisY->setLabelOption("showtext",true); + $yinterval = $height / 30; + $AxisY->setLabelInterval(ceil($max_value / $yinterval)); + $AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO); + if ($unit_name != "") + $AxisY->setTitle($unit_name, 'vertical'); + if ($periodo < 10000) + $xinterval = 8; + else + $xinterval = $resolution / 7 ; + $AxisX->setLabelInterval($xinterval) ; + //$AxisY->forceMinimum($minvalue); + $AxisY->forceMaximum($max_value+($max_value/12)) ; + $GridY2 =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY); + $GridY2->setLineColor('gray'); + $GridY2->setFillColor('lightgray@0.05'); + // set line colors + $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array'); + + $Plot->setFillStyle($FillArray); + /* + if ($avg_only == 1){ + $FillArray->addColor('green@0.6'); + } else { + $FillArray->addColor('yellow@0.5'); + $FillArray->addColor('orange@0.6'); + $FillArray->addColor('#e37907@0.7'); + $FillArray->addColor('red@0.7'); + $FillArray->addColor('blue@0.7'); + $FillArray->addColor('green@0.7'); + $FillArray->addColor('black@0.7'); + } + */ + $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 ); + } + + $Graph->done(); + } else + graphic_error (); +} // ************************************************************************** // ************************************************************************** @@ -1715,6 +2019,8 @@ if (isset($_GET["tipo"])){ if ($_GET["tipo"] == "sparse"){ grafico_modulo_sparse ($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, $avg_only, $pure); } + elseif ($_GET["tipo"] =="boolean") + grafico_modulo_boolean ($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, 1, $pure); elseif ($_GET["tipo"] =="estado_incidente") grafico_incidente_estados(); elseif ($_GET["tipo"] =="prioridad_incidente") diff --git a/pandora_console/reporting/stat_win.php b/pandora_console/reporting/stat_win.php index 965856df14..0c870e89d6 100644 --- a/pandora_console/reporting/stat_win.php +++ b/pandora_console/reporting/stat_win.php @@ -136,16 +136,31 @@ if (isset($_GET["zoom"])){ else $zoom = "1"; -echo ""; -echo ""; - echo ""; -echo "
"; - echo $lang_label["max_value"]." : ". format_for_graph(return_moduledata_max_value ($id, $period)); - echo ""; - echo $lang_label["avg_value"]." : ". format_for_graph(return_moduledata_avg_value ($id, $period)); - echo ""; - echo $lang_label["min_value"]." : ". format_for_graph(return_moduledata_min_value ($id, $period)); - echo "
"; +if ($zoom > 1) { + echo " + + "; +} + +$graph_type = "sparse"; +if (isset($_GET["type"])) + $graph_type = entrada_limpia($_GET["type"]); + + +echo ""; + + echo ""; + echo ""; + echo "
"; + echo $lang_label["max_value"]." : ". format_for_graph(return_moduledata_max_value ($id, $period)); + echo ""; + echo $lang_label["avg_value"]." : ". format_for_graph(return_moduledata_avg_value ($id, $period)); + echo ""; + echo $lang_label["min_value"]." : ". format_for_graph(return_moduledata_min_value ($id, $period)); + echo "
"; + ?> @@ -204,6 +219,8 @@ echo ""; "; echo ""; + if (isset($_GET["type"])) + echo ""; ?>