2007-08-06 Sancho Lerena <slerena@artica.es>
* 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). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@591 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
09f0191bf0
commit
ee68300c5e
|
@ -1,3 +1,27 @@
|
|||
2007-08-06 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* 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 <slerena@artica.es>
|
||||
|
||||
* CSS Fixes (min height).
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
?>
|
||||
<div class='databox' id='login'>
|
||||
<h1 id='log'><?php echo $lang_label['welcome_title']; ?></h1>
|
||||
|
@ -30,7 +42,7 @@
|
|||
<td rowspan='3' width='5'>
|
||||
<td class='f9b'>
|
||||
Login <br>
|
||||
<input class="login" type="text" name="nick" value="">
|
||||
<input class="login" type="text" name="nick" id="nick" value="">
|
||||
</td></tr>
|
||||
<tr><td class='f9b'>
|
||||
Password <br>
|
||||
|
@ -40,8 +52,16 @@
|
|||
<input type="submit" class="sub next" value="Login">
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<?php if (strlen($addr) > 0) { ?>
|
||||
<input type="hidden" name="redirect" value="<?php echo $addr; ?>">
|
||||
<?php } ?>
|
||||
</form>
|
||||
</div>
|
||||
<div id="ip"><?php echo 'IP: <b class="f10">'.$REMOTE_ADDR.'</b>'; ?></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
document.getElementById('nick').focus();
|
||||
</script>
|
||||
|
|
|
@ -119,6 +119,7 @@ sec2=godmode/groups/group_list">
|
|||
$id_grupo2 = $row["id_grupo"];
|
||||
echo "<option value=$id_grupo2>" . $nombre;
|
||||
}
|
||||
echo "<option value=0>None";
|
||||
echo '</select>';
|
||||
|
||||
// Disabled
|
||||
|
|
|
@ -769,7 +769,7 @@ function give_agentmodule_flag($id_agent_module){
|
|||
// ----------------------------------------------------------------------
|
||||
function list_group ($id_user){
|
||||
$mis_grupos=array (); // Define array mis_grupos to put here all groups with Agent Read permission
|
||||
$sql='SELECT id_grupo FROM tgrupo';
|
||||
$sql='SELECT id_grupo FROM tgrupo order by nombre';
|
||||
$result=mysql_query($sql);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
if ($row["id_grupo"] != 0){
|
||||
|
|
|
@ -79,10 +79,20 @@ if ( (isset ($_GET["refr"])) || (isset($_POST["refr"])) ){
|
|||
$intervalo = entrada_limpia ($_POST["refr"]);
|
||||
if ($intervalo > 0){
|
||||
// Agent selection filters and refresh
|
||||
$query = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '&refr=' . $intervalo;
|
||||
$query = 'http://' . $_SERVER['SERVER_NAME']; // TODO: Check for https
|
||||
|
||||
if ($_SERVER['SERVER_PORT'] != 80)
|
||||
$query .= ":" . $_SERVER['SERVER_PORT'];
|
||||
|
||||
$query .= $_SERVER['REQUEST_URI'];
|
||||
if (isset ($_POST["refr"]))
|
||||
$query .= '&refr=' . $intervalo;
|
||||
if (isset ($_POST["ag_group"])) {
|
||||
$ag_group = $_POST["ag_group"];
|
||||
$query = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '&ag_group_refresh=' . $ag_group;
|
||||
$query = 'http://' . $_SERVER['SERVER_NAME'];
|
||||
if ($_SERVER['SERVER_PORT'] != 80)
|
||||
$query .= ":" . $_SERVER['SERVER_PORT'];
|
||||
$query .= $_SERVER['REQUEST_URI'] . '&ag_group_refresh=' . $ag_group;
|
||||
} else
|
||||
echo '<meta http-equiv="refresh" content="' . $intervalo . '; URL=' . $query . '">';
|
||||
}
|
||||
|
|
|
@ -85,7 +85,14 @@
|
|||
$existen_agentes = 1;
|
||||
|
||||
// SQL Join to get monitor status for agents belong this group
|
||||
$sql1 = "SELECT tagente.id_agente, tagente_estado.estado, tagente_estado.datos, tagente_estado.current_interval, tagente_estado.utimestamp, tagente_estado.id_agente_modulo FROM tagente, tagente_estado WHERE tagente.disabled = 0 AND tagente.id_grupo = $migrupo AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.estado != 100 AND tagente_estado.utimestamp != 0";
|
||||
$sql1 = "SELECT
|
||||
tagente.id_agente, tagente_estado.estado, tagente_estado.datos, tagente_estado.current_interval,
|
||||
tagente_estado.utimestamp, tagente_estado.id_agente_modulo
|
||||
FROM tagente, tagente_estado
|
||||
WHERE tagente.disabled = 0 AND tagente.id_grupo = $migrupo AND
|
||||
tagente.id_agente = tagente_estado.id_agente AND tagente_estado.estado != 100 AND
|
||||
tagente_estado.utimestamp != 0";
|
||||
|
||||
if ($result1 = mysql_query ($sql1)){
|
||||
while ($row1 = mysql_fetch_array ($result1)) {
|
||||
$id_agente = $row1[0];
|
||||
|
@ -94,6 +101,7 @@
|
|||
$module_interval = $row1[3];
|
||||
$seconds = $ahora_sec - $row1[4];
|
||||
$id_agente_modulo = $row1[5];
|
||||
|
||||
if ($seconds >= ($module_interval*2))
|
||||
$grupo[$array_index]["down"]++;
|
||||
elseif ($datos != 0) {
|
||||
|
|
|
@ -169,21 +169,29 @@ if (comprueba_login() == 0) {
|
|||
} else
|
||||
echo substr(salida_limpia($row3["datos"]),0,12);
|
||||
|
||||
if (($row3["id_tipo_modulo"] == 2)
|
||||
OR ($row3["id_tipo_modulo"] == 6)
|
||||
OR ($row3["id_tipo_modulo"] == 18)
|
||||
OR ($row3["id_tipo_modulo"] == 9))
|
||||
$graph_type = "boolean";
|
||||
else
|
||||
$graph_type = "sparse";
|
||||
|
||||
$handle = "stat".$nombre_tipo_modulo."_".$row3["id_agente_modulo"];
|
||||
$url = 'reporting/procesos.php?agente='.$row3["id_agente_modulo"];
|
||||
$win_handle=dechex(crc32($row3["id_agente_modulo"].$row3["nombre"]));
|
||||
echo "<td class=".$tdcolor." width='78'>";
|
||||
$graph_label = output_clean_strict ($row3["nombre"]);
|
||||
|
||||
echo "<a href='javascript:winopeng(\"reporting/stat_win.php?period=2419200&id=".$row3["id_agente_modulo"]."&label=".$graph_label."refresh=180000\", \"month_".$win_handle."\")'><img src='images/grafica_m.png' border=0></a> ";
|
||||
echo "<a href='javascript:winopeng(\"reporting/stat_win.php?type=$graph_type&period=2419200&id=".$row3["id_agente_modulo"]."&label=".$graph_label."refresh=180000\", \"month_".$win_handle."\")'><img src='images/grafica_m.png' border=0></a> ";
|
||||
|
||||
$link ="winopeng('reporting/stat_win.php?period=604800&id=".$row3["id_agente_modulo"]."&label=".$graph_label."&refresh=6000','week_".$win_handle."')";
|
||||
$link ="winopeng('reporting/stat_win.php?type=$graph_type&period=604800&id=".$row3["id_agente_modulo"]."&label=".$graph_label."&refresh=6000','week_".$win_handle."')";
|
||||
echo '<a href="javascript:'.$link.'"><img src="images/grafica_w.png" border=0></a> ';
|
||||
|
||||
$link ="winopeng('reporting/stat_win.php?period=86400&id=".$row3["id_agente_modulo"]."&label=".$graph_label."&refresh=600','day_".$win_handle."')";
|
||||
$link ="winopeng('reporting/stat_win.php?type=$graph_type&period=86400&id=".$row3["id_agente_modulo"]."&label=".$graph_label."&refresh=600','day_".$win_handle."')";
|
||||
echo '<a href="javascript:'.$link.'"><img src="images/grafica_d.png" border=0></a> ';
|
||||
|
||||
$link ="winopeng('reporting/stat_win.php?period=3600&id=".$row3["id_agente_modulo"]."&label=".$graph_label."&refresh=60','hour_".$win_handle."')";
|
||||
$link ="winopeng('reporting/stat_win.php?type=$graph_type&period=3600&id=".$row3["id_agente_modulo"]."&label=".$graph_label."&refresh=60','hour_".$win_handle."')";
|
||||
echo '<a href="javascript:'.$link.'"><img src="images/grafica_h.png" border=0></a>';
|
||||
}
|
||||
// STRING DATA
|
||||
|
|
|
@ -82,11 +82,7 @@ if (comprueba_login() == 0) {
|
|||
echo "<option>".$lang_label["all"]."</option>";
|
||||
$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 "<option>".$row['0']."</option>";
|
||||
|
@ -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)){
|
||||
|
|
|
@ -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<br>";
|
||||
$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<br>";
|
||||
|
||||
$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 "<br>";
|
||||
}
|
||||
//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")
|
||||
|
|
|
@ -136,16 +136,31 @@ if (isset($_GET["zoom"])){
|
|||
else
|
||||
$zoom = "1";
|
||||
|
||||
echo "<img src='fgraph.php?tipo=sparse&draw_alerts=$draw_alerts&draw_events=$draw_events&id=$id&zoom=$zoom&label=$label&height=$height&width=$width&period=$period&avg_only=$avg_only' border=0 alt=''>";
|
||||
echo "<table width=450 cellspacing=1 cellpadding=1 class='databox' style='margin-left: 20px'>";
|
||||
echo "<tr><td><b>";
|
||||
echo $lang_label["max_value"]." </b>: ". format_for_graph(return_moduledata_max_value ($id, $period));
|
||||
echo "</td><td><b>";
|
||||
echo $lang_label["avg_value"]." </b>: ". format_for_graph(return_moduledata_avg_value ($id, $period));
|
||||
echo "</td><td><b>";
|
||||
echo $lang_label["min_value"]." </b>: ". format_for_graph(return_moduledata_min_value ($id, $period));
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
if ($zoom > 1) {
|
||||
echo "
|
||||
<script type='text/javascript'>
|
||||
window.resizeTo($width + 10, $height + 80);
|
||||
</script>
|
||||
";
|
||||
}
|
||||
|
||||
$graph_type = "sparse";
|
||||
if (isset($_GET["type"]))
|
||||
$graph_type = entrada_limpia($_GET["type"]);
|
||||
|
||||
|
||||
echo "<img src='fgraph.php?tipo=$graph_type&draw_alerts=$draw_alerts&draw_events=$draw_events&id=$id&zoom=$zoom&label=$label&height=$height&width=$width&period=$period&avg_only=$avg_only' border=0 alt=''>";
|
||||
|
||||
echo "<table width=450 cellspacing=1 cellpadding=1 class='databox' style='margin-left: 20px'>";
|
||||
echo "<tr><td><b>";
|
||||
echo $lang_label["max_value"]." </b>: ". format_for_graph(return_moduledata_max_value ($id, $period));
|
||||
echo "</td><td><b>";
|
||||
echo $lang_label["avg_value"]." </b>: ". format_for_graph(return_moduledata_avg_value ($id, $period));
|
||||
echo "</td><td><b>";
|
||||
echo $lang_label["min_value"]." </b>: ". format_for_graph(return_moduledata_min_value ($id, $period));
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
?>
|
||||
|
||||
<script type='text/javascript' src='../include/javascript/x_core.js'></script>
|
||||
|
@ -204,6 +219,8 @@ echo "</table>";
|
|||
<?php
|
||||
echo "<input type='hidden' name='id' value='$id'>";
|
||||
echo "<input type='hidden' name='label' value='$label'>";
|
||||
if (isset($_GET["type"]))
|
||||
echo "<input type='hidden' name='type' value='".$_GET["type"]."'>";
|
||||
?>
|
||||
<TABLE class='databox_frame' cellspacing=5>
|
||||
</td><td>
|
||||
|
|
Loading…
Reference in New Issue