2007-04-18 Sancho Lerena <slerena@artica.es>

* include/styles/pandora.css: Added frame and changed basic form input 
	styles (fixed the old problem with radio and checkboxes).
	
	* include/functions_db.php: Finished function
	agent_add_address(). Added functions: agent_delete_address(),
	give_agent_address() and give_agent_address_from_list().

	* include/languages/language_en.php: More strings !

	* include/functions.php: Added numeric render for graph Y scale
	and for numeric data output in screen: format_for_graph().
	
	* pandoradb.sql: Several small fixes and cleanup (deleted drop check).

	* operation/agentes/estado_alertas.php: Fixed old bug with
	visualization of alerts (min/max) vs (max/min). Now alert is a
	real value, not integer.
	
	* operation/agentes/datos_agente.php: Better render for numeric
	(float) data.
	
	* operation/agentes/estado_ultimopaquete.php: Better render for numeric
	(float) data and fixed a small costemic bug.
	
	* operation/agentes/estado_generalagente.php: Fixed a small
	costemic bug, list of ip's have some white space before and this
	have better visualization for user due to combo style stripping
	some space.
	
	* reporting/fgraph.php: Graph improvement: graphs now could show
	alerts associated to an agent and draw alert limits. Preprocessor
	function is now used to render axis label with (M,K) symbols and
	decimal commas. Title and subtitle has been improved.
		
	* reporting/stat_win.php: Graph menu improvement. Fully completed
	work. This should work for final version without more changes.
	
	* godmode/agentes/agent_template.php: Template/Wizard module
	assigment form for agent.
	
	* godmode/agentes/alert_manager.php: Several fixes (links) and
	alert max/min render.
	
	* godmode/agentes/configurar_agente.php: Fixed several navitation
	bugs. Added agent ip addition/deletion code.
	
	* godmode/agentes/agent_manager.php: Address list management code.
	
	* godmode/modules/module_list.php: Deleted link to "module type
	editor" and create button: This has no sense since there is no
	moduletype editor yet :-)



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@425 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2007-04-18 09:58:26 +00:00
parent 4de10dde97
commit a2a5c0fd02
17 changed files with 761 additions and 398 deletions

View File

@ -1,3 +1,57 @@
2007-04-18 Sancho Lerena <slerena@artica.es>
* include/styles/pandora.css: Added frame and changed basic form input
styles (fixed the old problem with radio and checkboxes).
* include/functions_db.php: Finished function
agent_add_address(). Added functions: agent_delete_address(),
give_agent_address() and give_agent_address_from_list().
* include/languages/language_en.php: More strings !
* include/functions.php: Added numeric render for graph Y scale
and for numeric data output in screen: format_for_graph().
* pandoradb.sql: Several small fixes and cleanup (deleted drop check).
* operation/agentes/estado_alertas.php: Fixed old bug with
visualization of alerts (min/max) vs (max/min). Now alert is a
real value, not integer.
* operation/agentes/datos_agente.php: Better render for numeric
(float) data.
* operation/agentes/estado_ultimopaquete.php: Better render for numeric
(float) data and fixed a small costemic bug.
* operation/agentes/estado_generalagente.php: Fixed a small
costemic bug, list of ip's have some white space before and this
have better visualization for user due to combo style stripping
some space.
* reporting/fgraph.php: Graph improvement: graphs now could show
alerts associated to an agent and draw alert limits. Preprocessor
function is now used to render axis label with (M,K) symbols and
decimal commas. Title and subtitle has been improved.
* reporting/stat_win.php: Graph menu improvement. Fully completed
work. This should work for final version without more changes.
* godmode/agentes/agent_template.php: Template/Wizard module
assigment form for agent.
* godmode/agentes/alert_manager.php: Several fixes (links) and
alert max/min render.
* godmode/agentes/configurar_agente.php: Fixed several navitation
bugs. Added agent ip addition/deletion code.
* godmode/agentes/agent_manager.php: Address list management code.
* godmode/modules/module_list.php: Deleted link to "module type
editor" and create button: This has no sense since there is no
moduletype editor yet :-)
2007-04-16 Manuel Arostegui <marostegui@artica.es> 2007-04-16 Manuel Arostegui <marostegui@artica.es>
* pandora_console.spec: Small changes to adapt the RPM to the * pandora_console.spec: Small changes to adapt the RPM to the

View File

@ -71,15 +71,27 @@ if (isset($_GET["creacion"])){
sec2=operation/agentes/ver_agente&id_agente=".$id_agente."'> sec2=operation/agentes/ver_agente&id_agente=".$id_agente."'>
<img src='images/lupa.gif' border='0' align='middle'></a>"; <img src='images/lupa.gif' border='0' align='middle'></a>";
} }
?>
<tr><td class="datos2"><b><?php echo $lang_label["ip_address"]?></b> echo '<tr><td class="datos2">';
<td class="datos2"> echo '<b>'.$lang_label["ip_address"].'</b>';
<input type="text" name="direccion" size="30" value=" echo '<td class="datos2">';
<?php echo $direccion_agente ?>"></td> echo '<input type="text" name="direccion" size="12" value="'.$direccion_agente.'">';
<!-- Combo for group --> echo "&nbsp;&nbsp;&nbsp;&nbsp;";
<tr><td class="datos"><b><?php echo $lang_label["group"]?></b>
<td class="datos"><select name="grupo" class="w130"> echo '<select name="address_list">';
<?php $sql1 = "SELECT * FROM taddress, taddress_agent
WHERE taddress.id_a = taddress_agent.id_a
AND taddress_agent.id_agent = $id_agente";
if ($result=mysql_query($sql1))
while ($row=mysql_fetch_array($result)){
echo "<option value='".salida_limpia($row["ip"])."'>".salida_limpia($row["ip"])."&nbsp;&nbsp;";
}
echo "<input name='delete_ip' type=checkbox value='1'> ".$lang_label["delete_sel"];
echo "</td>";
echo '<tr><td class="datos"><b>'.$lang_label["group"].'</b>';
echo '<td class="datos"><select name="grupo" class="w130">';
if (isset($grupo)){ if (isset($grupo)){
echo "<option value='".$grupo."'>".dame_grupo($grupo); echo "<option value='".$grupo."'>".dame_grupo($grupo);
} }

View File

@ -0,0 +1,171 @@
<?PHP
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development and project architecture and management
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Load global vars
require("include/config.php");
// Access control
if (give_acl($id_user, 0, "AW")!=1) {
audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access agent manager");
require ("general/noaccess.php");
exit;
};
// ==========================
// TEMPLATE ASSIGMENT LOGIC
// ==========================
if (isset($_POST["template_id"])){
// Take agent data
$sql1='SELECT * FROM tagente WHERE id_agente = '.$id_agente;
$result=mysql_query($sql1);
if ($row=mysql_fetch_array($result)){
$intervalo = $row["intervalo"];
$nombre_agente = $row["nombre"];
$direccion_agente =$row["direccion"];
$ultima_act = $row["ultimo_contacto"];
$ultima_act_remota =$row["ultimo_contacto_remoto"];
$comentarios = $row["comentarios"];
$id_grupo = $row["id_grupo"];
$id_os= $row["id_os"];
$os_version = $row["os_version"];
$agent_version = $row["agent_version"];
$disabled= $row["disabled"];
$agent_type= $row["agent_type"];
$server = $row["id_server"];
}
$id_np = $_POST["template_id"];
$sql1 = "SELECT * FROM tnetwork_profile_component
WHERE id_np = $id_np";
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
$sql2 = "SELECT * FROM tnetwork_component
WHERE id_nc = ".$row["id_nc"];
$result2=mysql_query($sql2);
while ($row2=mysql_fetch_array($result2)){
// Insert each module from tnetwork_component into agent
$module_sql = "INSERT INTO tagente_modulo
(id_agente, id_tipo_modulo, descripcion, nombre, max, min, module_interval, tcp_port, tcp_send, tcp_rcv, snmp_community, snmp_oid, ip_target, id_module_group)
VALUES ( $id_agente,
'".$row2["type"]."',
'".$row2["description"]."',
'".$row2["name"]."',
'".$row2["max"]."',
'".$row2["min"]."',
'".$row2["module_interval"]."',
'".$row2["tcp_port"]."',
'".$row2["tcp_send"]."',
'".$row2["tcp_rcv"]."',
'".$row2["snmp_community"]."',
'".$row2["snmp_oid"]."',
'$direccion_agente',
'".$row2["id_module_group"]."'
)";
mysql_query ($module_sql);
}
}
echo "<div class='suc'>";
echo "Modules added successfully";
echo "</div>";
}
// Main header
echo "<h2>".$lang_label["agent_conf"]." &gt; ".$lang_label["network_templates"];
echo "</h2>";
// ==========================
// TEMPLATE ASSIGMENT FORM
// ==========================
echo "<h3>".$lang_label["available_templates"]."</h3>";
echo "<table width=300 border=0>";
echo "<tr><td><br>";
echo "<form method=post action='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente=$id_agente'>";
echo "<select name='template_id'>";
$sql1='SELECT * FROM tnetwork_profile ORDER BY name';
$result=mysql_query($sql1);
if (mysql_num_rows($result))
while ($row=mysql_fetch_array($result))
echo "<option value='".$row["id_np"]."'>".$row["name"];
echo "</select>";
echo "<td>";
echo "<input type='submit' class='sub next' name='crt' value='".$lang_label["assign"]."'>";
echo "</table>";
echo "</form>";
// ==========================
// MODULE VISUALIZATION TABLE
// ==========================
echo "<h3>".$lang_label["assigned_modules"]."</h3>";
$sql1='SELECT * FROM tagente_modulo WHERE id_agente = "'.$id_agente.'"
ORDER BY id_module_group, nombre ';
$result=mysql_query($sql1);
if ($row=mysql_num_rows($result)){
echo '<table width="700" cellpadding="3" cellspacing="3" class="fon">';
echo '<tr>';
echo "<th>".$lang_label["module_name"];
echo "<th>".$lang_label["type"];
echo "<th>".$lang_label["description"];
echo "<th width=50>".$lang_label["action"];
$color=1;$last_modulegroup = "0";
while ($row=mysql_fetch_array($result)){
if ($color == 1){
$tdcolor="datos";
$color =0;
} else {
$tdcolor="datos2";
$color =1;
}
$id_tipo = $row["id_tipo_modulo"];
$nombre_modulo =$row["nombre"];
$descripcion = $row["descripcion"];
echo "<tr><td class='".$tdcolor."_id'>".$nombre_modulo;
echo "<td class='".$tdcolor."f9'>";
if ($id_tipo > 0) {
echo "<img src='images/".show_icon_type($id_tipo)."' border=0>";
}
echo "<td class='$tdcolor' title='$descripcion'>".substr($descripcion,0,30)."</td>";
echo "<td class='$tdcolor'>";
if ($id_tipo != -1)
echo "<a href='index.php?sec=gagente&
tab=module&
sec2=godmode/agentes/configurar_agente&tab=template&
id_agente=".$id_agente."&
delete_module=".$row["id_agente_modulo"]."'>
<img src='images/cross.png' border=0 alt='".$lang_label["delete"]."'>
</b></a> &nbsp; ";
echo "<a href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&
id_agente=".$id_agente."&
tab=module&
update_module=".$row["id_agente_modulo"]."#modules'>
<img src='images/config.gif' border=0 alt='".$lang_label["update"]."' onLoad='type_change()'></b></a>";
}
echo "<tr><td colspan='7'><div class='raya'></div></td></tr>";
echo "</table>";
} else
echo "<div class='nf'>No modules</div>";
?>

View File

@ -65,17 +65,32 @@ $result=mysql_query($sql1);
$string = $string."<tr><td class='$tdcolor'>".$nombre_modulo."/".$tipo_modulo; $string = $string."<tr><td class='$tdcolor'>".$nombre_modulo."/".$tipo_modulo;
$string = $string."<td class=$tdcolor>".$nombre_alerta; $string = $string."<td class=$tdcolor>".$nombre_alerta;
$string = $string."<td class='$tdcolor'>".$row3["time_threshold"]; $string = $string."<td class='$tdcolor'>".$row3["time_threshold"];
$string = $string."<td class='$tdcolor'>".$row3["dis_min"]."/".$row3["dis_max"];
$mytempdata = fmod($row3["dis_min"], 1);
if ($mytempdata == 0)
$mymin = intval($row3["dis_min"]);
else
$mymin = $row3["dis_min"];
$mymin = format_for_graph($mymin );
$mytempdata = fmod($row3["dis_max"], 1);
if ($mytempdata == 0)
$mymax = intval($row3["dis_max"]);
else
$mymax = $row3["dis_max"];
$mymax = format_for_graph($mymax );
$string = $string."<td class='$tdcolor'>".$mymin." / ".$mymax;
$string = $string."<td class='$tdcolor'>".salida_limpia($row3["descripcion"]); $string = $string."<td class='$tdcolor'>".salida_limpia($row3["descripcion"]);
$string = $string."<td class='$tdcolor'>"; $string = $string."<td class='$tdcolor'>";
$id_grupo = dame_id_grupo($id_agente); $id_grupo = dame_id_grupo($id_agente);
if (give_acl($id_user, $id_grupo, "LW")==1){ if (give_acl($id_user, $id_grupo, "LW")==1){
$string = $string."<a href='index.php?sec=gagente& $string = $string."<a href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente& sec2=godmode/agentes/configurar_agente&tab=alert&
id_agente=".$id_agente."&delete_alert=".$row3["id_aam"]."'> id_agente=".$id_agente."&delete_alert=".$row3["id_aam"]."'>
<img src='images/cross.png' border=0 alt='".$lang_label["delete"]."'></a> &nbsp; "; <img src='images/cross.png' border=0 alt='".$lang_label["delete"]."'></a> &nbsp; ";
$string = $string."<a href='index.php?sec=gagente& $string = $string."<a href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente& sec2=godmode/agentes/configurar_agente&tab=alert&
id_agente=".$id_agente."&update_alert=".$row3["id_aam"]."#alerts'> id_agente=".$id_agente."&update_alert=".$row3["id_aam"]."#alerts'>
<img src='images/config.gif' border=0 alt='".$lang_label["update"]."'></a>"; <img src='images/config.gif' border=0 alt='".$lang_label["update"]."'></a>";
} }

View File

@ -1,6 +1,7 @@
<?php <?php
// Pandora FMS - the Free monitoring system // Pandora FMS - the Free monitoring system
// ======================================== // ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com // Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development and project architecture and management // Main PHP/SQL code development and project architecture and management
// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com // Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com
@ -32,8 +33,12 @@ if (give_acl($id_user, 0, "AW")!=1) {
if (isset($_GET["id_agente"])) if (isset($_GET["id_agente"]))
$id_agente = $_GET["id_agente"]; $id_agente = $_GET["id_agente"];
else else {
$id_agente = -1; $id_agente = -1;
if (isset($_POST["update_agent"])) { // if modified some agent paramenter
$id_agente = entrada_limpia($_POST["id_agente"]);
}
}
// Init vars // Init vars
$descripcion = ""; $descripcion = "";
@ -149,7 +154,7 @@ echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=
echo "</li>"; echo "</li>";
echo "<li class='nomn'>"; echo "<li class='nomn'>";
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=templatet&id_agente=$id_agente'><img src='images/network.gif' width='16' class='top' border=0>&nbsp; NC Templates</a>"; echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente=$id_agente'><img src='images/network.gif' width='16' class='top' border=0>&nbsp; NC Templates</a>";
echo "</li>"; echo "</li>";
echo "</ul>"; echo "</ul>";
@ -183,13 +188,6 @@ if (isset($_GET["delete_alert"])){ // if modified some parameter
} }
// Delete IP address
if (isset($_POST["delete_ip"])){
echo "DELETING IP ADDRESS ".$_POST["delete_ip"];
echo "<br>";
}
// Create alert // Create alert
// ============= // =============
if (isset($_POST["insert_alert"])){ // if created alert if (isset($_POST["insert_alert"])){ // if created alert
@ -259,6 +257,7 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
$id_agente = entrada_limpia($_POST["id_agente"]); $id_agente = entrada_limpia($_POST["id_agente"]);
$nombre_agente = entrada_limpia($_POST["agente"]); $nombre_agente = entrada_limpia($_POST["agente"]);
$direccion_agente = entrada_limpia($_POST["direccion"]); $direccion_agente = entrada_limpia($_POST["direccion"]);
$old_agent_address = give_agent_address ($id_agente);
$grupo = entrada_limpia($_POST["grupo"]); $grupo = entrada_limpia($_POST["grupo"]);
$intervalo = entrada_limpia($_POST["intervalo"]); $intervalo = entrada_limpia($_POST["intervalo"]);
$comentarios = entrada_limpia($_POST["comentarios"]); $comentarios = entrada_limpia($_POST["comentarios"]);
@ -266,6 +265,10 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
$id_os = entrada_limpia($_POST["id_os"]); $id_os = entrada_limpia($_POST["id_os"]);
$disabled = entrada_limpia($_POST["disabled"]); $disabled = entrada_limpia($_POST["disabled"]);
$id_server = entrada_limpia($_POST["id_server"]); $id_server = entrada_limpia($_POST["id_server"]);
if ($direccion_agente != $old_agent_address){
agent_add_address ($id_agente, $direccion_agente);
}
if ($id_server != ""){ if ($id_server != ""){
$sql_update ="UPDATE tagente $sql_update ="UPDATE tagente
SET disabled = ".$disabled." , id_os = ".$id_os." , modo = ".$modo." , nombre = '".$nombre_agente."', direccion = '".$direccion_agente."', id_grupo = '".$grupo."', intervalo = '".$intervalo."', comentarios = '".$comentarios."', id_server = '".$id_server."' SET disabled = ".$disabled." , id_os = ".$id_os." , modo = ".$modo." , nombre = '".$nombre_agente."', direccion = '".$direccion_agente."', id_grupo = '".$grupo."', intervalo = '".$intervalo."', comentarios = '".$comentarios."', id_server = '".$id_server."'
@ -275,6 +278,13 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
SET disabled = ".$disabled." , id_os = ".$id_os." , modo = ".$modo." , nombre = '".$nombre_agente."', direccion = '".$direccion_agente."', id_grupo = '".$grupo."', intervalo = '".$intervalo."', comentarios = '".$comentarios."' SET disabled = ".$disabled." , id_os = ".$id_os." , modo = ".$modo." , nombre = '".$nombre_agente."', direccion = '".$direccion_agente."', id_grupo = '".$grupo."', intervalo = '".$intervalo."', comentarios = '".$comentarios."'
WHERE id_agente = '".$id_agente."'"; WHERE id_agente = '".$id_agente."'";
} }
// Delete one of associateds IP's ?
if (isset($_POST["delete_ip"])) {
$delete_ip = $_POST["address_list"];
agent_delete_address ($id_agente, $delete_ip);
}
$result=mysql_query($sql_update); $result=mysql_query($sql_update);
if (! $result) { if (! $result) {
echo "<h3 class='error'>".$lang_label["update_agent_no"]."</h3>"; echo "<h3 class='error'>".$lang_label["update_agent_no"]."</h3>";
@ -618,6 +628,8 @@ case "module": require "module_manager.php";
break; break;
case "alert": require "alert_manager.php"; case "alert": require "alert_manager.php";
break; break;
case "template":require "agent_template.php";
break;
} }

View File

@ -83,9 +83,7 @@ if (give_acl($id_user, 0, "PM")==1) {
border='0'> border='0'>
</td> </td>
<td class='$tdcolor'> <td class='$tdcolor'>
<b><a href='index.php?sec=gmodules& <b>".$row["nombre"]."
sec2=godmode/modules/manage_modules&
id_module=".$row["id_tipo"]."'>".$row["nombre"]."</a>
</b></td> </b></td>
<td class='$tdcolor'> <td class='$tdcolor'>
".give_modulecategory_name ($row["categoria"])." ".give_modulecategory_name ($row["categoria"])."
@ -100,7 +98,9 @@ if (give_acl($id_user, 0, "PM")==1) {
echo "<tr><td colspan='4' align='right'>"; echo "<tr><td colspan='4' align='right'>";
echo "<form method=post action='index.php?sec=gmodules& echo "<form method=post action='index.php?sec=gmodules&
sec2=godmode/modules/manage_modules&create=1'>"; sec2=godmode/modules/manage_modules&create=1'>";
/* not used yet
echo "<input type='submit' class='sub next' name='crt' value='".$lang_label["create_module"]."'>"; echo "<input type='submit' class='sub next' name='crt' value='".$lang_label["create_module"]."'>";
*/
echo "</form></td></tr></table>"; echo "</form></td></tr></table>";
} // Fin pagina } // Fin pagina

View File

@ -363,7 +363,9 @@ function pagination ($count, $url, $offset ) {
} }
} }
// ---------------------------------------------------------------
// Render data in a fashion way :-) // Render data in a fashion way :-)
// ---------------------------------------------------------------
function format_numeric ( $number, $decimals=2, $dec_point=".", $thousands_sep=",") { function format_numeric ( $number, $decimals=2, $dec_point=".", $thousands_sep=",") {
if ($number == 0) if ($number == 0)
return 0; return 0;
@ -374,4 +376,16 @@ function format_numeric ( $number, $decimals=2, $dec_point=".", $thousands_sep="
return number_format ($number, 0, $dec_point, $thousands_sep); return number_format ($number, 0, $dec_point, $thousands_sep);
} }
// ---------------------------------------------------------------
// Render numeric data in a easy way to the user
// ---------------------------------------------------------------
function format_for_graph ( $number ) {
if ($number > "1000000")
return number_format ($number/1000000, 1, ".", ",")." M";
if ($number > "1000")
return number_format ($number/1000, 1, ".", ",")." K";
return $number;
}
?> ?>

View File

@ -923,32 +923,119 @@ function give_network_profile_name ($id_np){
function agent_add_address ($id_agent, $ip_address) { function agent_add_address ($id_agent, $ip_address) {
require("config.php"); require("config.php");
$query1="SELECT * FROM taddress_agent WHERE id_agent= $id_agent";
$resq1=mysql_query($query1);
$address_exist = 0; $address_exist = 0;
while ($rowdup=mysql_fetch_array($resq1)){ $id_address =-1;
$sql_3='SELECT ip FROM taddress WHERE id_a = '.$rowdup["id_a"]; $address_attached = 0;
$result_3=mysql_query($sql_3);
$row3=mysql_fetch_array($result_3); // Check if already is attached to agent
if ($row3[0] == $ip_address) $query1="SELECT * FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a
AND ip = '$ip_address'
AND id_agent = $id_agent";
if ($resq1=mysql_query($query1)){
if ($rowdup=mysql_fetch_array($resq1)){
$address_attached = 1;
}
}
if ($address_attached == 1)
return;
// Look for a record with this IP Address
$query1="SELECT * FROM taddress WHERE ip = '$ip_address'";
if ($resq1=mysql_query($query1)){
if ($rowdup=mysql_fetch_array($resq1)){
$id_address = $rowdup["id_a"];
$address_exist = 1; $address_exist = 1;
} }
if ($address_exist == 1){
// Add address
} }
if ($address_exist == 0){
$sql_2='SELECT id_a FROM taddress_agent WHERE id_agent = '.$id_agent; // Create IP address in tadress table
$result_t=mysql_query($sql_2); $query = "INSERT INTO taddress
while ($row=mysql_fetch_array($result_t)){ (ip) VALUES
$sql_3='SELECT ip FROM taddress WHERE id_a = '.$row[0]; ('$ip_address')";
$result_3=mysql_query($sql_3); $res = mysql_query ($query);
$row3=mysql_fetch_array($result_3); $id_address = mysql_insert_id ();
if ($direccion_agente != $row3[0])
echo "<option>".salida_limpia($row3[0]);
} }
// Add address to agent
$query = "INSERT INTO taddress_agent
(id_a, id_agent) VALUES
($id_address,$id_agent)";
$res = mysql_query ($query);
// Change main address in agent to whis one
/* Not needed, configurar_agente does automatically on every update
$query = "UPDATE tagente
(direccion) VALUES
($ip_address)
WHERE id_agente = $id_agent ";
$res = mysql_query ($query);
*/
}
// ---------------------------------------------------------------
// De-associate IP address to an agent (delete)
// ---------------------------------------------------------------
function agent_delete_address ($id_agent, $ip_address) {
require("config.php");
$address_exist = 0;
$id_address =-1;
$query1="SELECT * FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a
AND ip = '$ip_address'
AND id_agent = $id_agent";
if ($resq1=mysql_query($query1)){
$rowdup=mysql_fetch_array($resq1);
$id_ag = $rowdup["id_ag"];
$id_a = $rowdup["id_a"];
$sql_3="DELETE FROM taddress_agent
WHERE id_ag = $id_ag";
$result_3=mysql_query($sql_3);
}
// Need to change main address ?
if (give_agent_address ($id_agent) == $ip_address){
$new_ip = give_agent_address_from_list ($id_agent);
// Change main address in agent to whis one
$query = "UPDATE tagente
(direccion) VALUES
($new_ip)
WHERE id_agente = $id_agent ";
$res = mysql_query ($query);
}
}
// ---------------------------------------------------------------
// Returns (main) agent address given id
// ---------------------------------------------------------------
function give_agent_address ($id_agent){
require("config.php");
$query1="SELECT * FROM tagente WHERE id_agente = $id_agent";
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["direccion"];
else
$pro = "";
return $pro;
}
// ---------------------------------------------------------------
// Returns the first agent address given id taken from associated addresses
// ---------------------------------------------------------------
function give_agent_address_from_list ($id_agent){
require("config.php");
$query1="SELECT * FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a
AND id_agent = $id_agent";
if ($resq1=mysql_query($query1)){
$rowdup=mysql_fetch_array($resq1);
$pro=$rowdup["ip"];
}
else
$pro = "";
return $pro;
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------

View File

@ -750,6 +750,9 @@ $lang_label["no_netprofiles"]="There are no defined network profiles";
$lang_label["site_news"]="Site news"; $lang_label["site_news"]="Site news";
$lang_label["at"]="At"; $lang_label["at"]="At";
$lang_label["says"]="says"; $lang_label["says"]="says";
$lang_label["delete_sel"]="Delete selected";
$lang_label["available_templates"]="Available templates";
$lang_label["assign"]="Assign";
global $lang_label; global $lang_label;
global $help_label; global $help_label;
?> ?>

View File

@ -32,21 +32,38 @@
font-family: Verdana, sans-serif, Arial, Helvetica; font-family: Verdana, sans-serif, Arial, Helvetica;
font-size: 11px; font-size: 11px;
} }
select, textarea, input {
font-size: 12px; input {
padding: 4px;
border:1px solid #eee;
font: normal 1em/1.5em Verdana, sans-serif;
} }
textarea { textarea {
border: 1px solid #c0c0c0; padding:4px;
padding: 5px; font: normal 1em/1.5em Verdana, sans-serif;
border:1px solid #eee;
height:100px;
} }
input { input.button {
border: 1px solid #c0c0c0; margin: 0;
padding: 2px 3px 4px 3px; font: bold 1em Arial, Sans-serif;
height: 23px; border: 1px solid #CCC;
background: #FFF;
padding: 2px 3px;
margin: 10px 15px;
} }
option { select {
height: 16px; padding: 2px;
border:1px solid #eee;
font: normal 1em/1.5em Verdana, sans-serif;
} }
checkbox {
padding: 4px;
border:1px solid #eee;
font: normal 1em/1.5em Verdana, sans-serif;
}
h1, h2 { h1, h2 {
color: #103a3a; color: #103a3a;
padding-bottom: 15px; padding-bottom: 15px;
@ -584,4 +601,23 @@ span.users, span.agents, span.data, span.alerts, span.time {
padding-top: 25px; padding-top: 25px;
text-align: center; text-align: center;
clear: both; clear: both;
}
/* New styles for data box */
.databox_color {
margin: 10px 15px;
border: 1px solid #f2f2f2;
border-left: 3px solid #EC981F;
}
.databox {
margin: 10px 15px;
border: 1px solid #f2f2f2;
background-color: #FAFAFA;
}
.databox_frame {
margin: 10px 15px;
border: 1px solid #f2f2f2;
} }

View File

@ -79,20 +79,13 @@ function datos_raw($id_agente_modulo, $periodo){
echo "<tr>"; echo "<tr>";
echo "<td class='".$tdcolor."' style='width:150px'>".$row["timestamp"]; echo "<td class='".$tdcolor."' style='width:150px'>".$row["timestamp"];
echo "<td class='".$tdcolor."'>"; echo "<td class='".$tdcolor."'>";
if (($row["datos"] != 0) AND (is_numeric($row["datos"]))) { if (is_numeric($row["datos"])) {
$mytempdata = fmod($row["datos"], $row["datos"]); $mytempdata = fmod($row["datos"], 1);
if ($mytempdata == 0) if ($mytempdata == 0)
$myvalue = intval($row["datos"]); $myvalue = intval($row["datos"]);
else else
$myvalue = $row["datos"]; $myvalue = $row["datos"];
if ($myvalue > 1000000) { // Add sufix "M" for millions echo format_for_graph($myvalue );
$mytempdata = $myvalue / 1000000;
echo $mytempdata." M";
} elseif ( $myvalue > 1000){ // Add sufix "K" for thousands
$mytempdata = $myvalue / 1000;
echo $mytempdata." K";
} else
echo substr($myvalue,0,12);
} else } else
echo substr($row["datos"],0,12); echo substr($row["datos"],0,12);
} }

View File

@ -42,7 +42,22 @@ if (comprueba_login() == 0) {
echo "<td class='".$tdcolor."'>".dame_nombre_alerta($data["id_alerta"]); echo "<td class='".$tdcolor."'>".dame_nombre_alerta($data["id_alerta"]);
echo "<td class='".$tdcolor."'>".$data["nombre"]; echo "<td class='".$tdcolor."'>".$data["nombre"];
echo "<td class='".$tdcolor."'>".$data["descripcion"]; echo "<td class='".$tdcolor."'>".$data["descripcion"];
echo "<td class='".$tdcolor."'>".$data["dis_max"]."/".$data["dis_min"];
$mytempdata = fmod($data["dis_min"], 1);
if ($mytempdata == 0)
$mymin = intval($data["dis_min"]);
else
$mymin = $data["dis_min"];
$mymin = format_for_graph($mymin );
$mytempdata = fmod($data["dis_max"], 1);
if ($mytempdata == 0)
$mymax = intval($data["dis_max"]);
else
$mymax = $data["dis_max"];
$mymax = format_for_graph($mymax );
echo "<td class='".$tdcolor."'>".$mymin." / ".$mymax;
echo "<td class='".$tdcolor."'>".$data["time_threshold"]; echo "<td class='".$tdcolor."'>".$data["time_threshold"];
if ($data["last_fired"] == "0000-00-00 00:00:00") { if ($data["last_fired"] == "0000-00-00 00:00:00") {
echo "<td class='".$tdcolor."f9'>".$lang_label["never"]; echo "<td class='".$tdcolor."f9'>".$lang_label["never"];

View File

@ -78,7 +78,7 @@ if (comprueba_login() == 0) {
// Show all address for this agent, show first the main IP (taken from tagente table) // Show all address for this agent, show first the main IP (taken from tagente table)
echo "<select name='notused' size=1>"; echo "<select style='padding:0px' name='notused' size=1>";
echo "<option>".salida_limpia($direccion_agente); echo "<option>".salida_limpia($direccion_agente);
$sql_2='SELECT id_a FROM taddress_agent WHERE id_agent = '.$id_agente; $sql_2='SELECT id_a FROM taddress_agent WHERE id_agent = '.$id_agente;
$result_t=mysql_query($sql_2); $result_t=mysql_query($sql_2);
@ -87,13 +87,11 @@ if (comprueba_login() == 0) {
$result_3=mysql_query($sql_3); $result_3=mysql_query($sql_3);
$row3=mysql_fetch_array($result_3); $row3=mysql_fetch_array($result_3);
if ($direccion_agente != $row3[0]) if ($direccion_agente != $row3[0])
echo "<option>".salida_limpia($row3[0]); echo "<option value='".salida_limpia($row3[0])."'>".salida_limpia($row3[0])."&nbsp;&nbsp;";
} }
echo "</select>"; echo "</select>";
if ($agent_type == 0) { if ($agent_type == 0) {
echo '<tr> echo '<tr>
<td class="datos"><b>'.$lang_label["os"].'</b></td> <td class="datos"><b>'.$lang_label["os"].'</b></td>
@ -120,7 +118,7 @@ if (comprueba_login() == 0) {
echo '<tr> echo '<tr>
<td class="datos2"><b>'.salida_limpia($lang_label["group"]).'</b></td> <td class="datos2"><b>'.salida_limpia($lang_label["group"]).'</b></td>
<td class="datos2" colspan="2"> <td class="datos2" colspan="2">
<img class="bot" src="images/groups_small/'.show_icon_group($row["id_grupo"]).'.png" >&nbsp;&nbsp; '.dame_grupo($id_grupo).'<br>'.dame_grupo($id_grupo).'</td></tr>'; <img class="bot" src="images/groups_small/'.show_icon_group($id_grupo).'.png" >&nbsp;&nbsp; '.dame_grupo($id_grupo).'</td></tr>';
if ($agent_type == 0) { if ($agent_type == 0) {
echo '<tr><td class="datos"><b>'.$lang_label["agentversion"].'</b> echo '<tr><td class="datos"><b>'.$lang_label["agentversion"].'</b>
<td class="datos" colspan=2>'.salida_limpia($agent_version).'</td>'; <td class="datos" colspan=2>'.salida_limpia($agent_version).'</td>';

View File

@ -157,30 +157,23 @@ if (comprueba_login() == 0) {
AND ($row3["id_tipo_modulo"] != 10) AND ($row3["id_tipo_modulo"] != 10)
AND ($row3["id_tipo_modulo"] != 17)){ AND ($row3["id_tipo_modulo"] != 17)){
echo "<td class=".$tdcolor.">"; echo "<td class=".$tdcolor.">";
if (($row3["datos"] != 0) AND (is_numeric($row3["datos"]))) { if (is_numeric($row3["datos"])) {
$mytempdata = fmod($row3["datos"], 1); $mytempdata = fmod($row3["datos"], 1);
if ($mytempdata == "0") if ($mytempdata == 0)
$myvalue = intval($row3["datos"]); $myvalue = intval($row3["datos"]);
else else
$myvalue = $row3["datos"]; $myvalue = $row3["datos"];
if ($myvalue > 1000000) { // Add sufix "M" for millions echo format_for_graph($myvalue );
$mytempdata = $myvalue / 1000000; } else
echo format_numeric($mytempdata)." M"; echo substr($row["datos"],0,12);
} elseif ( $myvalue > 1000){ // Add sufix "K" for thousands
$mytempdata = $myvalue / 1000;
echo format_numeric ($mytempdata)." K";
} else
echo substr($myvalue,0,12);
} elseif ($row3["datos"] == 0)
echo "0";
else
echo substr($row3["datos"],0,12);
$handle = "stat".$nombre_tipo_modulo."_".$row3["id_agente_modulo"]; $handle = "stat".$nombre_tipo_modulo."_".$row3["id_agente_modulo"];
$url = 'reporting/procesos.php?agente='.$row3["id_agente_modulo"]; $url = 'reporting/procesos.php?agente='.$row3["id_agente_modulo"];
$win_handle=dechex(crc32($row3["id_agente_modulo"].$row3["nombre"])); $win_handle=dechex(crc32($row3["id_agente_modulo"].$row3["nombre"]));
echo "<td class=".$tdcolor." width='78'>"; echo "<td class=".$tdcolor." width='78'>";
$graph_label = entrada_limpia($row3["nombre"]." - ".$row3["id_agente_modulo"]); $graph_label = entrada_limpia($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.gif' border=0></a>&nbsp;"; 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.gif' border=0></a>&nbsp;";

View File

@ -1,8 +1,13 @@
--
-- Table structure for table `estado_consola`
--
DROP TABLE IF EXISTS `estado_consola`; -- Pandora FMS tables for active console (not officially included )
CREATE TABLE `vistas_consola` (
`idVista` int(5) NOT NULL auto_increment,
`nombre` varchar(50) NOT NULL,
`descripcion` varchar(250) NOT NULL,
PRIMARY KEY (`idVista`)
) ENGINE=InnoDB;
CREATE TABLE `estado_consola` ( CREATE TABLE `estado_consola` (
`id_usuario` varchar(50) NOT NULL, `id_usuario` varchar(50) NOT NULL,
`idPerfilActivo` int(5) NOT NULL, `idPerfilActivo` int(5) NOT NULL,
@ -12,11 +17,7 @@ CREATE TABLE `estado_consola` (
PRIMARY KEY (`id_usuario`) PRIMARY KEY (`id_usuario`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `objeto_consola`
--
DROP TABLE IF EXISTS `objeto_consola`;
CREATE TABLE `objeto_consola` ( CREATE TABLE `objeto_consola` (
`id_objeto` int(5) NOT NULL auto_increment, `id_objeto` int(5) NOT NULL auto_increment,
`nom_img` varchar(50) NOT NULL, `nom_img` varchar(50) NOT NULL,
@ -26,25 +27,17 @@ CREATE TABLE `objeto_consola` (
`id_tipo` varchar(20) NOT NULL, `id_tipo` varchar(20) NOT NULL,
`idVista` int(5) NOT NULL, `idVista` int(5) NOT NULL,
PRIMARY KEY (`id_objeto`) PRIMARY KEY (`id_objeto`)
) ENGINE=InnoDB AUTO_INCREMENT=37; ) ENGINE=InnoDB;
--
-- Table structure for table `perfil`
--
DROP TABLE IF EXISTS `perfil`;
CREATE TABLE `perfil` ( CREATE TABLE `perfil` (
`idPerfil` int(5) NOT NULL auto_increment, `idPerfil` int(5) NOT NULL auto_increment,
`Nombre` varchar(50) NOT NULL, `Nombre` varchar(50) NOT NULL,
`Descripcion` varchar(250) NOT NULL, `Descripcion` varchar(250) NOT NULL,
PRIMARY KEY (`idPerfil`) PRIMARY KEY (`idPerfil`)
) ENGINE=InnoDB AUTO_INCREMENT=3; ) ENGINE=InnoDB;
--
-- Table structure for table `perfil_vista`
--
DROP TABLE IF EXISTS `perfil_vista`;
CREATE TABLE `perfil_vista` ( CREATE TABLE `perfil_vista` (
`idPerfil` int(5) NOT NULL, `idPerfil` int(5) NOT NULL,
`idVista` int(5) NOT NULL, `idVista` int(5) NOT NULL,
@ -52,33 +45,22 @@ CREATE TABLE `perfil_vista` (
PRIMARY KEY (`idPerfil`,`idVista`) PRIMARY KEY (`idPerfil`,`idVista`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `relacion_estado`
--
DROP TABLE IF EXISTS `relacion_estado`;
CREATE TABLE `relacion_estado` ( CREATE TABLE `relacion_estado` (
`id_objeto` int(5) NOT NULL, `id_objeto` int(5) NOT NULL,
`relacion` varchar(50) NOT NULL, `relacion` varchar(50) NOT NULL,
PRIMARY KEY (`id_objeto`) PRIMARY KEY (`id_objeto`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `relacion_objetos`
--
DROP TABLE IF EXISTS `relacion_objetos`;
CREATE TABLE `relacion_objetos` ( CREATE TABLE `relacion_objetos` (
`idObjeto1` int(5) NOT NULL, `idObjeto1` int(5) NOT NULL,
`idObjeto2` int(5) NOT NULL, `idObjeto2` int(5) NOT NULL,
PRIMARY KEY (`idObjeto1`,`idObjeto2`) PRIMARY KEY (`idObjeto1`,`idObjeto2`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
-- -- Pandora FMS official tables
-- Table structure for table `taddress`
--
DROP TABLE IF EXISTS `taddress`;
CREATE TABLE `taddress` ( CREATE TABLE `taddress` (
`id_a` bigint(20) unsigned NOT NULL auto_increment, `id_a` bigint(20) unsigned NOT NULL auto_increment,
`ip` varchar(15) NOT NULL default '', `ip` varchar(15) NOT NULL default '',
@ -86,11 +68,7 @@ CREATE TABLE `taddress` (
PRIMARY KEY (`id_a`) PRIMARY KEY (`id_a`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `taddress_agent`
--
DROP TABLE IF EXISTS `taddress_agent`;
CREATE TABLE `taddress_agent` ( CREATE TABLE `taddress_agent` (
`id_ag` bigint(20) unsigned NOT NULL auto_increment, `id_ag` bigint(20) unsigned NOT NULL auto_increment,
`id_a` bigint(20) unsigned NOT NULL default '0', `id_a` bigint(20) unsigned NOT NULL default '0',
@ -98,26 +76,17 @@ CREATE TABLE `taddress_agent` (
PRIMARY KEY (`id_ag`) PRIMARY KEY (`id_ag`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tagent_access`
--
DROP TABLE IF EXISTS `tagent_access`;
CREATE TABLE `tagent_access` ( CREATE TABLE `tagent_access` (
`id_ac` bigint(20) unsigned NOT NULL auto_increment, `id_ac` bigint(20) unsigned NOT NULL auto_increment,
`id_agent` int(11) NOT NULL default '0', `id_agent` int(11) NOT NULL default '0',
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00', `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`utimestamp` bigint(20) NOT NULL default '0', `utimestamp` bigint(20) NOT NULL default '0',
PRIMARY KEY (`id_ac`), PRIMARY KEY (`id_ac`),
KEY `agent_index` (`id_agent`), KEY `agent_index` (`id_agent`)
UNIQUE (`id_agent`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tagente`
--
DROP TABLE IF EXISTS `tagente`;
CREATE TABLE `tagente` ( CREATE TABLE `tagente` (
`id_agente` mediumint(8) unsigned NOT NULL auto_increment, `id_agente` mediumint(8) unsigned NOT NULL auto_increment,
`nombre` varchar(100) NOT NULL default '', `nombre` varchar(100) NOT NULL default '',
@ -137,11 +106,7 @@ CREATE TABLE `tagente` (
PRIMARY KEY (`id_agente`) PRIMARY KEY (`id_agente`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tagente_datos`
--
DROP TABLE IF EXISTS `tagente_datos`;
CREATE TABLE `tagente_datos` ( CREATE TABLE `tagente_datos` (
`id_agente_datos` bigint(10) unsigned NOT NULL auto_increment, `id_agente_datos` bigint(10) unsigned NOT NULL auto_increment,
`id_agente_modulo` mediumint(8) unsigned NOT NULL default '0', `id_agente_modulo` mediumint(8) unsigned NOT NULL default '0',
@ -153,11 +118,7 @@ CREATE TABLE `tagente_datos` (
KEY `data_index2` (`id_agente`,`id_agente_modulo`) KEY `data_index2` (`id_agente`,`id_agente_modulo`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tagente_datos_inc`
--
DROP TABLE IF EXISTS `tagente_datos_inc`;
CREATE TABLE `tagente_datos_inc` ( CREATE TABLE `tagente_datos_inc` (
`id_adi` bigint(20) unsigned NOT NULL auto_increment, `id_adi` bigint(20) unsigned NOT NULL auto_increment,
`id_agente_modulo` bigint(20) NOT NULL default '0', `id_agente_modulo` bigint(20) NOT NULL default '0',
@ -167,11 +128,7 @@ CREATE TABLE `tagente_datos_inc` (
KEY `data_inc_index_1` (`id_agente_modulo`) KEY `data_inc_index_1` (`id_agente_modulo`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tagente_datos_string`
--
DROP TABLE IF EXISTS `tagente_datos_string`;
CREATE TABLE `tagente_datos_string` ( CREATE TABLE `tagente_datos_string` (
`id_tagente_datos_string` bigint(20) unsigned NOT NULL auto_increment, `id_tagente_datos_string` bigint(20) unsigned NOT NULL auto_increment,
`id_agente_modulo` int(11) NOT NULL default '0', `id_agente_modulo` int(11) NOT NULL default '0',
@ -184,11 +141,7 @@ CREATE TABLE `tagente_datos_string` (
KEY `data_string_index_2` (`id_agente`) KEY `data_string_index_2` (`id_agente`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tagente_estado`
--
DROP TABLE IF EXISTS `tagente_estado`;
CREATE TABLE `tagente_estado` ( CREATE TABLE `tagente_estado` (
`id_agente_estado` int(10) unsigned NOT NULL auto_increment, `id_agente_estado` int(10) unsigned NOT NULL auto_increment,
`id_agente_modulo` int(20) NOT NULL default '0', `id_agente_modulo` int(20) NOT NULL default '0',
@ -206,22 +159,14 @@ CREATE TABLE `tagente_estado` (
KEY `status_index_2` (`id_agente_modulo`,`estado`) KEY `status_index_2` (`id_agente_modulo`,`estado`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
# Database: pandora
# Table: 'tmodule'
#
CREATE TABLE `tmodule` ( CREATE TABLE `tmodule` (
`id_module` int(11) unsigned NOT NULL auto_increment, `id_module` int(11) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
PRIMARY KEY (`id_module`), PRIMARY KEY (`id_module`),
UNIQUE (name)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tagente_modulo`
--
DROP TABLE IF EXISTS `tagente_modulo`;
CREATE TABLE `tagente_modulo` ( CREATE TABLE `tagente_modulo` (
`id_agente_modulo` bigint(100) unsigned NOT NULL auto_increment, `id_agente_modulo` bigint(100) unsigned NOT NULL auto_increment,
`id_agente` int(11) NOT NULL default '0', `id_agente` int(11) NOT NULL default '0',
@ -244,11 +189,7 @@ CREATE TABLE `tagente_modulo` (
KEY `tam_agente` (`id_agente`) KEY `tam_agente` (`id_agente`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `talert_snmp`
--
DROP TABLE IF EXISTS `talert_snmp`;
CREATE TABLE `talert_snmp` ( CREATE TABLE `talert_snmp` (
`id_as` int(10) unsigned NOT NULL auto_increment, `id_as` int(10) unsigned NOT NULL auto_increment,
`id_alert` int(10) unsigned NOT NULL default '0', `id_alert` int(10) unsigned NOT NULL default '0',
@ -269,11 +210,7 @@ CREATE TABLE `talert_snmp` (
PRIMARY KEY (`id_as`) PRIMARY KEY (`id_as`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `talerta`
--
DROP TABLE IF EXISTS `talerta`;
CREATE TABLE `talerta` ( CREATE TABLE `talerta` (
`id_alerta` int(10) unsigned NOT NULL auto_increment, `id_alerta` int(10) unsigned NOT NULL auto_increment,
`nombre` varchar(100) NOT NULL default '', `nombre` varchar(100) NOT NULL default '',
@ -282,11 +219,7 @@ CREATE TABLE `talerta` (
PRIMARY KEY (`id_alerta`) PRIMARY KEY (`id_alerta`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `talerta_agente_modulo`
--
DROP TABLE IF EXISTS `talerta_agente_modulo`;
CREATE TABLE `talerta_agente_modulo` ( CREATE TABLE `talerta_agente_modulo` (
`id_aam` int(11) unsigned NOT NULL auto_increment, `id_aam` int(11) unsigned NOT NULL auto_increment,
`id_agente_modulo` int(11) NOT NULL default '0', `id_agente_modulo` int(11) NOT NULL default '0',
@ -295,8 +228,8 @@ CREATE TABLE `talerta_agente_modulo` (
`al_campo2` varchar(255) default '', `al_campo2` varchar(255) default '',
`al_campo3` mediumtext default '', `al_campo3` mediumtext default '',
`descripcion` varchar(255) default '', `descripcion` varchar(255) default '',
`dis_max` bigint(12) default NULL, `dis_max` double(18,2) default NULL,
`dis_min` bigint(12) default NULL, `dis_min` double(18,2) default NULL,
`time_threshold` int(11) NOT NULL default '0', `time_threshold` int(11) NOT NULL default '0',
`last_fired` datetime NOT NULL default '2004-01-01 00:00:00', `last_fired` datetime NOT NULL default '2004-01-01 00:00:00',
`max_alerts` int(4) NOT NULL default '1', `max_alerts` int(4) NOT NULL default '1',
@ -307,11 +240,7 @@ CREATE TABLE `talerta_agente_modulo` (
PRIMARY KEY (`id_aam`) PRIMARY KEY (`id_aam`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tattachment`
--
DROP TABLE IF EXISTS `tattachment`;
CREATE TABLE `tattachment` ( CREATE TABLE `tattachment` (
`id_attachment` bigint(20) unsigned NOT NULL auto_increment, `id_attachment` bigint(20) unsigned NOT NULL auto_increment,
`id_incidencia` bigint(20) NOT NULL default '0', `id_incidencia` bigint(20) NOT NULL default '0',
@ -322,11 +251,7 @@ CREATE TABLE `tattachment` (
PRIMARY KEY (`id_attachment`) PRIMARY KEY (`id_attachment`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tconfig`
--
DROP TABLE IF EXISTS `tconfig`;
CREATE TABLE `tconfig` ( CREATE TABLE `tconfig` (
`id_config` int(10) unsigned NOT NULL auto_increment, `id_config` int(10) unsigned NOT NULL auto_increment,
`token` varchar(100) NOT NULL default '', `token` varchar(100) NOT NULL default '',
@ -334,11 +259,7 @@ CREATE TABLE `tconfig` (
PRIMARY KEY (`id_config`) PRIMARY KEY (`id_config`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tconfig_os`
--
DROP TABLE IF EXISTS `tconfig_os`;
CREATE TABLE `tconfig_os` ( CREATE TABLE `tconfig_os` (
`id_os` int(10) unsigned NOT NULL auto_increment, `id_os` int(10) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
@ -347,11 +268,7 @@ CREATE TABLE `tconfig_os` (
PRIMARY KEY (`id_os`) PRIMARY KEY (`id_os`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tevento`
--
DROP TABLE IF EXISTS `tevento`;
CREATE TABLE `tevento` ( CREATE TABLE `tevento` (
`id_evento` bigint(20) unsigned NOT NULL auto_increment, `id_evento` bigint(20) unsigned NOT NULL auto_increment,
`id_agente` bigint(20) NOT NULL default '0', `id_agente` bigint(20) NOT NULL default '0',
@ -366,11 +283,7 @@ CREATE TABLE `tevento` (
KEY `indice_2` (`timestamp`,`id_evento`) KEY `indice_2` (`timestamp`,`id_evento`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tgrupo`
--
DROP TABLE IF EXISTS `tgrupo`;
CREATE TABLE `tgrupo` ( CREATE TABLE `tgrupo` (
`id_grupo` mediumint(8) unsigned NOT NULL auto_increment, `id_grupo` mediumint(8) unsigned NOT NULL auto_increment,
`nombre` varchar(100) NOT NULL default '', `nombre` varchar(100) NOT NULL default '',
@ -379,11 +292,7 @@ CREATE TABLE `tgrupo` (
PRIMARY KEY (`id_grupo`) PRIMARY KEY (`id_grupo`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tincidencia`
--
DROP TABLE IF EXISTS `tincidencia`;
CREATE TABLE `tincidencia` ( CREATE TABLE `tincidencia` (
`id_incidencia` bigint(20) unsigned NOT NULL auto_increment, `id_incidencia` bigint(20) unsigned NOT NULL auto_increment,
`inicio` datetime NOT NULL default '0000-00-00 00:00:00', `inicio` datetime NOT NULL default '0000-00-00 00:00:00',
@ -402,22 +311,14 @@ CREATE TABLE `tincidencia` (
KEY `incident_index_1` (`id_usuario`,`id_incidencia`) KEY `incident_index_1` (`id_usuario`,`id_incidencia`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tlanguage`
--
DROP TABLE IF EXISTS `tlanguage`;
CREATE TABLE `tlanguage` ( CREATE TABLE `tlanguage` (
`id_language` varchar(6) NOT NULL default '', `id_language` varchar(6) NOT NULL default '',
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
PRIMARY KEY (`id_language`) PRIMARY KEY (`id_language`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tlink`
--
DROP TABLE IF EXISTS `tlink`;
CREATE TABLE `tlink` ( CREATE TABLE `tlink` (
`id_link` int(10) unsigned zerofill NOT NULL auto_increment, `id_link` int(10) unsigned zerofill NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
@ -425,11 +326,7 @@ CREATE TABLE `tlink` (
PRIMARY KEY (`id_link`) PRIMARY KEY (`id_link`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tmensajes`
--
DROP TABLE IF EXISTS `tmensajes`;
CREATE TABLE `tmensajes` ( CREATE TABLE `tmensajes` (
`id_mensaje` bigint(20) unsigned NOT NULL auto_increment, `id_mensaje` bigint(20) unsigned NOT NULL auto_increment,
`id_usuario_origen` varchar(100) NOT NULL default '', `id_usuario_origen` varchar(100) NOT NULL default '',
@ -441,22 +338,14 @@ CREATE TABLE `tmensajes` (
PRIMARY KEY (`id_mensaje`) PRIMARY KEY (`id_mensaje`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tmodule_group`
--
DROP TABLE IF EXISTS `tmodule_group`;
CREATE TABLE `tmodule_group` ( CREATE TABLE `tmodule_group` (
`id_mg` bigint(20) unsigned NOT NULL auto_increment, `id_mg` bigint(20) unsigned NOT NULL auto_increment,
`name` varchar(150) NOT NULL default '', `name` varchar(150) NOT NULL default '',
PRIMARY KEY (`id_mg`) PRIMARY KEY (`id_mg`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tnetwork_component`
--
DROP TABLE IF EXISTS `tnetwork_component`;
CREATE TABLE `tnetwork_component` ( CREATE TABLE `tnetwork_component` (
`id_nc` mediumint(12) unsigned NOT NULL auto_increment, `id_nc` mediumint(12) unsigned NOT NULL auto_increment,
`name` varchar(50) NOT NULL, `name` varchar(50) NOT NULL,
@ -475,11 +364,7 @@ CREATE TABLE `tnetwork_component` (
PRIMARY KEY (`id_nc`) PRIMARY KEY (`id_nc`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tnetwork_component_group`
--
DROP TABLE IF EXISTS `tnetwork_component_group`;
CREATE TABLE `tnetwork_component_group` ( CREATE TABLE `tnetwork_component_group` (
`id_sg` mediumint(8) unsigned NOT NULL auto_increment, `id_sg` mediumint(8) unsigned NOT NULL auto_increment,
`name` varchar(200) NOT NULL default '', `name` varchar(200) NOT NULL default '',
@ -487,11 +372,7 @@ CREATE TABLE `tnetwork_component_group` (
PRIMARY KEY (`id_sg`) PRIMARY KEY (`id_sg`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tnetwork_profile`
--
DROP TABLE IF EXISTS `tnetwork_profile`;
CREATE TABLE `tnetwork_profile` ( CREATE TABLE `tnetwork_profile` (
`id_np` mediumint(8) unsigned NOT NULL auto_increment, `id_np` mediumint(8) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
@ -499,11 +380,7 @@ CREATE TABLE `tnetwork_profile` (
PRIMARY KEY (`id_np`) PRIMARY KEY (`id_np`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tnetwork_profile_component`
--
DROP TABLE IF EXISTS `tnetwork_profile_component`;
CREATE TABLE `tnetwork_profile_component` ( CREATE TABLE `tnetwork_profile_component` (
`id_npc` mediumint(8) unsigned NOT NULL auto_increment, `id_npc` mediumint(8) unsigned NOT NULL auto_increment,
`id_nc` mediumint(8) unsigned NOT NULL default '0', `id_nc` mediumint(8) unsigned NOT NULL default '0',
@ -511,11 +388,7 @@ CREATE TABLE `tnetwork_profile_component` (
PRIMARY KEY (`id_npc`) PRIMARY KEY (`id_npc`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tnota`
--
DROP TABLE IF EXISTS `tnota`;
CREATE TABLE `tnota` ( CREATE TABLE `tnota` (
`id_nota` mediumint(8) unsigned NOT NULL auto_increment, `id_nota` mediumint(8) unsigned NOT NULL auto_increment,
`id_usuario` varchar(100) NOT NULL default '0', `id_usuario` varchar(100) NOT NULL default '0',
@ -524,11 +397,7 @@ CREATE TABLE `tnota` (
PRIMARY KEY (`id_nota`) PRIMARY KEY (`id_nota`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tnota_inc`
--
DROP TABLE IF EXISTS `tnota_inc`;
CREATE TABLE `tnota_inc` ( CREATE TABLE `tnota_inc` (
`id_nota_inc` mediumint(8) unsigned NOT NULL auto_increment, `id_nota_inc` mediumint(8) unsigned NOT NULL auto_increment,
`id_incidencia` mediumint(9) NOT NULL default '0', `id_incidencia` mediumint(9) NOT NULL default '0',
@ -536,20 +405,12 @@ CREATE TABLE `tnota_inc` (
PRIMARY KEY (`id_nota_inc`) PRIMARY KEY (`id_nota_inc`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `torigen`
--
DROP TABLE IF EXISTS `torigen`;
CREATE TABLE `torigen` ( CREATE TABLE `torigen` (
`origen` varchar(100) NOT NULL default '' `origen` varchar(100) NOT NULL default ''
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tperfil`
--
DROP TABLE IF EXISTS `tperfil`;
CREATE TABLE `tperfil` ( CREATE TABLE `tperfil` (
`id_perfil` int(10) unsigned NOT NULL auto_increment, `id_perfil` int(10) unsigned NOT NULL auto_increment,
`name` varchar(60) NOT NULL default '', `name` varchar(60) NOT NULL default '',
@ -566,11 +427,7 @@ CREATE TABLE `tperfil` (
PRIMARY KEY (`id_perfil`) PRIMARY KEY (`id_perfil`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `trecon_task`
--
DROP TABLE IF EXISTS `trecon_task`;
CREATE TABLE `trecon_task` ( CREATE TABLE `trecon_task` (
`id_rt` int(10) unsigned NOT NULL auto_increment, `id_rt` int(10) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
@ -588,11 +445,7 @@ CREATE TABLE `trecon_task` (
PRIMARY KEY (`id_rt`) PRIMARY KEY (`id_rt`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tserver`
--
DROP TABLE IF EXISTS `tserver`;
CREATE TABLE `tserver` ( CREATE TABLE `tserver` (
`id_server` int(10) unsigned NOT NULL auto_increment, `id_server` int(10) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
@ -611,11 +464,7 @@ CREATE TABLE `tserver` (
PRIMARY KEY (`id_server`) PRIMARY KEY (`id_server`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tsesion`
--
DROP TABLE IF EXISTS `tsesion`;
CREATE TABLE `tsesion` ( CREATE TABLE `tsesion` (
`ID_sesion` bigint(4) unsigned NOT NULL auto_increment, `ID_sesion` bigint(4) unsigned NOT NULL auto_increment,
`ID_usuario` varchar(60) NOT NULL default '0', `ID_usuario` varchar(60) NOT NULL default '0',
@ -627,11 +476,7 @@ CREATE TABLE `tsesion` (
PRIMARY KEY (`ID_sesion`) PRIMARY KEY (`ID_sesion`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `ttipo_modulo`
--
DROP TABLE IF EXISTS `ttipo_modulo`;
CREATE TABLE `ttipo_modulo` ( CREATE TABLE `ttipo_modulo` (
`id_tipo` smallint(5) unsigned NOT NULL auto_increment, `id_tipo` smallint(5) unsigned NOT NULL auto_increment,
`nombre` varchar(100) NOT NULL default '', `nombre` varchar(100) NOT NULL default '',
@ -641,11 +486,7 @@ CREATE TABLE `ttipo_modulo` (
PRIMARY KEY (`id_tipo`) PRIMARY KEY (`id_tipo`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `ttrap`
--
DROP TABLE IF EXISTS `ttrap`;
CREATE TABLE `ttrap` ( CREATE TABLE `ttrap` (
`id_trap` bigint(20) unsigned NOT NULL auto_increment, `id_trap` bigint(20) unsigned NOT NULL auto_increment,
`source` varchar(50) NOT NULL default '', `source` varchar(50) NOT NULL default '',
@ -660,13 +501,9 @@ CREATE TABLE `ttrap` (
`id_usuario` varchar(150) default '', `id_usuario` varchar(150) default '',
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00', `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id_trap`) PRIMARY KEY (`id_trap`)
) ENGINE=InnoDB COMMENT='SNMP Trap table'; ) ENGINE=InnoDB;
--
-- Table structure for table `tusuario`
--
DROP TABLE IF EXISTS `tusuario`;
CREATE TABLE `tusuario` ( CREATE TABLE `tusuario` (
`id_usuario` varchar(60) NOT NULL default '0', `id_usuario` varchar(60) NOT NULL default '0',
`nombre_real` varchar(125) NOT NULL default '', `nombre_real` varchar(125) NOT NULL default '',
@ -678,11 +515,7 @@ CREATE TABLE `tusuario` (
`nivel` tinyint(1) NOT NULL default '0' `nivel` tinyint(1) NOT NULL default '0'
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `tusuario_perfil`
--
DROP TABLE IF EXISTS `tusuario_perfil`;
CREATE TABLE `tusuario_perfil` ( CREATE TABLE `tusuario_perfil` (
`id_up` bigint(20) unsigned NOT NULL auto_increment, `id_up` bigint(20) unsigned NOT NULL auto_increment,
`id_usuario` varchar(100) NOT NULL default '', `id_usuario` varchar(100) NOT NULL default '',
@ -692,18 +525,6 @@ CREATE TABLE `tusuario_perfil` (
PRIMARY KEY (`id_up`) PRIMARY KEY (`id_up`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--
-- Table structure for table `vistas_consola`
--
DROP TABLE IF EXISTS `vistas_consola`;
CREATE TABLE `vistas_consola` (
`idVista` int(5) NOT NULL auto_increment,
`nombre` varchar(50) NOT NULL,
`descripcion` varchar(250) NOT NULL,
PRIMARY KEY (`idVista`)
) ENGINE=InnoDB AUTO_INCREMENT=7;
CREATE TABLE `tnews` ( CREATE TABLE `tnews` (
`id_news` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `id_news` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
@ -712,5 +533,4 @@ CREATE TABLE `tnews` (
`text` TEXT NOT NULL DEFAULT '', `text` TEXT NOT NULL DEFAULT '',
`utimestamp` DATETIME NOT NULL DEFAULT 0, `utimestamp` DATETIME NOT NULL DEFAULT 0,
PRIMARY KEY(`id_news`) PRIMARY KEY(`id_news`)
) ) ENGINE = InnoDB;
ENGINE = InnoDB;

View File

@ -72,7 +72,7 @@ function dame_fecha_grafico_timestamp ($timestamp) {
return date('d/m H:i', $timestamp); return date('d/m H:i', $timestamp);
} }
function graphic_combined_module ($module_list, $weight_list, $periodo, $width, $height , $title, $unit_name, $show_event=0, $show_alert=0 ) { function graphic_combined_module ($module_list, $weight_list, $periodo, $width, $height, $title, $unit_name, $show_event=0, $show_alert=0 ) {
include ("../include/config.php"); include ("../include/config.php");
require ("../include/languages/language_".$language_code.".php"); require ("../include/languages/language_".$language_code.".php");
require_once 'Image/Graph.php'; require_once 'Image/Graph.php';
@ -121,7 +121,6 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
$valores[$x][6] = 0; // Event $valores[$x][6] = 0; // Event
} }
// Init other general variables // Init other general variables
if ($show_event == 1){ if ($show_event == 1){
// If we want to show events in graphs // If we want to show events in graphs
$sql1="SELECT utimestamp FROM tevento WHERE id_agente = $id_agente AND utimestamp > $fechatope"; $sql1="SELECT utimestamp FROM tevento WHERE id_agente = $id_agente AND utimestamp > $fechatope";
@ -136,7 +135,7 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
} }
} }
$alert_high = 0; $alert_high = 0;
$alert_low = 0; $alert_low = 10000000;
if ($show_alert == 1){ if ($show_alert == 1){
// If we want to show alerts limits // If we want to show alerts limits
$sql1="SELECT * FROM talerta_agente_modulo where id_agente_modulo = ".$id_agente_modulo; $sql1="SELECT * FROM talerta_agente_modulo where id_agente_modulo = ".$id_agente_modulo;
@ -144,9 +143,8 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
while ($row=mysql_fetch_array($result)){ while ($row=mysql_fetch_array($result)){
if ($row["dis_max"] > $alert_high) if ($row["dis_max"] > $alert_high)
$alert_high = $row["dis_max"]; $alert_high = $row["dis_max"];
if ($row["dis_max"] > $alert_high) if ($row["dis_min"] < $alert_low)
$min = $row["dis_min"]; $alert_low = $row["dis_min"];
} }
} }
@ -224,11 +222,11 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
$title_period = "Last month"; $title_period = "Last month";
else else
$title_period = "Last ".format_numeric(($periodo / (3600*24)),2)." days"; $title_period = "Last ".format_numeric(($periodo / (3600*24)),2)." days";
$Graph->add( $Graph->add(
Image_Graph::vertical( Image_Graph::vertical(
Image_Graph::vertical( Image_Graph::vertical(
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.$title_period, 10)), $Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '. $title_period, 10)),
$Subtitle = Image_Graph::factory('title', array(' '.$title, 7)), $Subtitle = Image_Graph::factory('title', array(' '.$title, 7)),
90 90
), ),
@ -321,8 +319,8 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
graphic_error (); graphic_error ();
} }
function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events, function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $show_event,
$width, $height , $title, $unit_name ) { $width, $height , $title, $unit_name, $show_alert ) {
include ("../include/config.php"); include ("../include/config.php");
require ("../include/languages/language_".$language_code.".php"); require ("../include/languages/language_".$language_code.".php");
@ -337,8 +335,29 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events,
$id_agente = dame_agente_id($nombre_agente); $id_agente = dame_agente_id($nombre_agente);
$nombre_modulo = dame_nombre_modulo_agentemodulo($id_agente_modulo); $nombre_modulo = dame_nombre_modulo_agentemodulo($id_agente_modulo);
// intervalo - This is the number of "rows" we are divided the time to fill data. if ($show_event == 1)
// more interval, more resolution, and slower. $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 // periodo - Gap of time, in seconds. This is now to (now-periodo) secs
// Init tables // Init tables
@ -349,6 +368,22 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events,
$valores[$x][3] = $fechatope + ($horasint*($x+1)); // [3] Botom limit $valores[$x][3] = $fechatope + ($horasint*($x+1)); // [3] Botom limit
$valores[$x][4] = 0; // MIN $valores[$x][4] = 0; // MIN
$valores[$x][5] = 0; // MAX $valores[$x][5] = 0; // MAX
$valores[$x][6] = 0; // 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 // Init other general variables
$max_value = 0; $max_value = 0;
@ -436,7 +471,7 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events,
$Graph->add( $Graph->add(
Image_Graph::vertical( Image_Graph::vertical(
Image_Graph::vertical( Image_Graph::vertical(
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.$title_period, 10)), $Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - ".$title_period, 10)),
$Subtitle = Image_Graph::factory('title', array(' '.$title, 7)), $Subtitle = Image_Graph::factory('title', array(' '.$title, 7)),
90 90
), ),
@ -459,24 +494,42 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events,
$dataset[1]->setName("Avg."); $dataset[1]->setName("Avg.");
$dataset[2] = Image_Graph::factory('dataset'); $dataset[2] = Image_Graph::factory('dataset');
$dataset[2]->setName("Min."); $dataset[2]->setName("Min.");
// Event dataset creation
if ($show_event == 1){
$dataset_event = Image_Graph::factory('dataset');
$dataset_event -> setName("Event Fired");
}
// ... and populated with data ... // ... and populated with data ...
for ($cc=0; $cc <= $resolution; $cc++) { for ($cc=0; $cc <= $resolution; $cc++) {
$tdate = date('d/m', $valores[$cc][2])."\n".date('H:i', $valores[$cc][2]); $tdate = date('d/m', $valores[$cc][2])."\n".date('H:i', $valores[$cc][2]);
$dataset[1]->addPoint($tdate, $valores[$cc][0]); $dataset[1]->addPoint($tdate, $valores[$cc][0]);
$dataset[0]->addPoint($tdate, $valores[$cc][5]); $dataset[0]->addPoint($tdate, $valores[$cc][5]);
$dataset[2]->addPoint($tdate, $valores[$cc][4]); $dataset[2]->addPoint($tdate, $valores[$cc][4]);
//echo "$cc -- $tdate - ".$valores[$cc][0]." -- ".$valores[$cc][4]."--".$valores[$cc][5]."<br>"; if (($show_event == 1) AND (isset($real_event[$cc]))) {
$dataset_event->addPoint($tdate, $valores[$cc][5]);
}
} }
if ($max_value > 0){ 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 // create the 1st plot as smoothed area chart using the 1st dataset
$Plot =& $Plotarea->addNew('area', array(&$dataset)); $Plot =& $Plotarea->addNew('area', array(&$dataset));
$Plot->setLineColor('yellow@0.1'); $Plot->setLineColor('yellow@0.1');
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
// $AxisX->Hide(); // $AxisX->Hide();
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'format_for_graph'));
$AxisY->setLabelOption("showtext",true); $AxisY->setLabelOption("showtext",true);
$AxisY->setLabelInterval(ceil($max_value / 5)); $AxisY->setLabelInterval(ceil($max_value / 5));
$AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO); $AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO);
@ -498,12 +551,19 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events,
$FillArray->addColor('blue@0.7'); $FillArray->addColor('blue@0.7');
$FillArray->addColor('green@0.7'); $FillArray->addColor('green@0.7');
$FillArray->addColor('black@0.7'); $FillArray->addColor('black@0.7');
$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); $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(); $Graph->done();
} else } else
graphic_error (); graphic_error ();
@ -1701,10 +1761,16 @@ else
// Draw Events ? // Draw Events ?
if ( isset($_GET["draw_events"]) and $_GET["draw_events"]==0 ) if ( isset($_GET["draw_events"]))
$draw_events = 0; $draw_events = $_GET["draw_events"];
else else
$draw_events = 1; $draw_events = 0;
// Draw alert limits ?
if ( isset($_GET["draw_alerts"]))
$draw_alerts = $_GET["draw_alerts"];
else
$draw_alerts = 0;
// Image handler // Image handler
// ***************** // *****************
@ -1712,7 +1778,7 @@ if ( isset($_GET["draw_events"]) and $_GET["draw_events"]==0 )
if (isset($_GET["tipo"])){ if (isset($_GET["tipo"])){
if ($_GET["tipo"] == "sparse"){ if ($_GET["tipo"] == "sparse"){
grafico_modulo_sparse($id, $period, $draw_events, $width, $height , $label, $unit_name); grafico_modulo_sparse($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts);
} }
elseif ($_GET["tipo"] =="estado_incidente") elseif ($_GET["tipo"] =="estado_incidente")
grafico_incidente_estados(); grafico_incidente_estados();

View File

@ -2,10 +2,15 @@
// Pandora - the Free monitoring system // Pandora - the Free monitoring system
// ==================================== // ====================================
// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com // Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
// Copyright (c) 2005-2006 Artica Soluciones Tecnol<6F>icas S.L, info@artica.es // Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es
// Copyright (c) 2006-2007 Jonathan Barajas, jonathan.barajas[AT]gmail[DOT]com
// Javascript Active Console code.
// Copyright (c) 2006 Jose Navarro <contacto@indiseg.net>
// Additions to Pandora FMS 1.2 graph code and new XML reporting template management
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -15,76 +20,111 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Cargamos variables globales // Global & session management
session_start();
include ("../include/config.php"); include ("../include/config.php");
session_start();
include ("../include/functions.php"); include ("../include/functions.php");
include("../include/functions_db.php"); include("../include/functions_db.php");
include("../include/languages/language_".$language_code.".php"); include("../include/languages/language_".$language_code.".php");
if (comprueba_login() == 0) { // Access control
// Has access to this page ??? if (comprueba_login() != 0) {
$REMOTE_ADDR = getenv ("REMOTE_ADDR");
audit_db("Unknown",$REMOTE_ADDR, "ACL Violation","Trying to access graph window without auth");
require ("general/noaccess.php");
exit;
}
// Parsing the refresh before sending any header // Parsing the refresh before sending any header
if (isset($_GET['refresh']) and is_numeric($_GET['refresh']) and $_GET['refresh']>0) { if (isset($_GET['refresh']) and is_numeric($_GET['refresh']) and $_GET['refresh']>0) {
header( 'refresh: ' . $_GET['refresh'] ); header( 'refresh: ' . $_GET['refresh'] );
}
// CSS
echo '<style>';
include("../include/styles/pandora.css");
echo '</style>';
// Get input parameters
if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) {
echo "<h3 class='error'>".$lang_label["graf_error"]."</h3>";
exit;
} }
// Read styles
echo '<style>';
include("../include/styles/pandora.css");
echo '</style>';
// Get input parameters
if (isset($_GET["label"]))
$label = entrada_limpia($_GET["label"]);
if (isset($_GET["event"])) if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) {
$draw_events = entrada_limpia($_GET["event"]); echo "<h3 class='error'>".$lang_label["graf_error"]."</h3>";
else exit;
$draw_events = 0; }
if (isset($_GET["refresh"])) if (isset($_GET["draw_events"]))
$refresh = entrada_limpia($_GET["refresh"]); $draw_events = entrada_limpia($_GET["draw_events"]);
else else
$refresh = 0; $draw_events = 0;
if (isset($_GET["period"]))
$period = entrada_limpia($_GET["period"]);
else
$period = 86400; // 1 day default period
if (isset($_GET["id"])) if (isset($_GET["period"]))
$id = entrada_limpia($_GET["id"]); $period = entrada_limpia($_GET["period"]);
else else
$id = 0; $period = 3600; // 1 hour (the most fast query possible)
if (isset($_GET["width"]))
$width = entrada_limpia($_GET["width"]);
else
$width = 525;
if (isset($_GET["height"])) switch ($period) {
$height = entrada_limpia ($_GET["height"]); case 3600: $period_label = "Hour";
else break;
$height = 200; case 21600: $period_label = "6 Hours";
break;
case 43200: $period_label = "12 Hous";
break;
case 86400: $period_label = "Day";
break;
case 604800: $period_label = "Last Week";
break;
case 1296000: $period_label = "15 Days";
break;
case 2592000: $period_label = "Last Month";
break;
case 5184000: $period_label = "Two Month";
break;
case 15552000: $period_label = "Six Months";
break;
default: $period_label = "--";
}
if (isset($_GET["draw_alerts"]))
$draw_alerts = entrada_limpia($_GET["draw_alerts"]);
else
$draw_alerts = 0;
if (isset($_GET["refresh"]))
$refresh = entrada_limpia($_GET["refresh"]);
else
$refresh = 0;
if (isset($_GET["period"]))
$period = entrada_limpia($_GET["period"]);
else
$period = 86400; // 1 day default period
if (isset($_GET["id"]))
$id = entrada_limpia($_GET["id"]);
else
$id = 0;
if (isset($_GET["width"]))
$width = entrada_limpia($_GET["width"]);
else
$width = 525;
if (isset($_GET["height"]))
$height = entrada_limpia ($_GET["height"]);
else
$height = 220;
if (isset($_GET["label"])) if (isset($_GET["label"]))
$label = entrada_limpia ($_GET["label"]); $label = entrada_limpia ($_GET["label"]);
else else
$label = ""; $label = "";
if (isset($_GET["zoom"])){ if (isset($_GET["zoom"])){
$zoom = entrada_limpia ($_GET["zoom"]); $zoom = entrada_limpia ($_GET["zoom"]);
$height=$height*$zoom; $height=$height*$zoom;
$width=$width*$zoom; $width=$width*$zoom;
} }
else else
$zoom = "1"; $zoom = "1";
echo "<img src='fgraph.php?tipo=sparse&id=$id&zoom=$zoom&label=$label&height=$height&width=$width&period=$period' border=0 alt=''>"; 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' border=0 alt=''>";
}
?> ?>
@ -94,19 +134,17 @@ if (comprueba_login() == 0) {
<style type='text/css'><!-- <style type='text/css'><!--
.menu { .menu {
color:#000; background:#ccc; margin:2px; padding:2px; color:#000; background:#ccc;
font-family:verdana,arial,sans-serif,helvetica; font-size:10px; margin-left: 10px;
padding-left: 10px; padding-top: 10px;
font-family:arial,sans-serif,verdana; font-size:10px;
border:1px solid #000; border:1px solid #000;
position:absolute; position:absolute;
margin:0; width:550px; height:220px; margin:0; width:325px; height:220px;
visibility:hidden; visibility:hidden;
filter:alpha(opacity=95); filter:alpha(opacity=95);
-moz-opacity: 0.95; -moz-opacity: 0.95;
opacity: 0.95; opacity: 0.95;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
} }
--></style> --></style>
@ -116,8 +154,8 @@ if (comprueba_login() == 0) {
var defOffset = 2; var defOffset = 2;
var defSlideTime = 200; var defSlideTime = 200;
var tnActive = 0; var tnActive = 0;
var visibleMargin = 5; var visibleMargin = 3;
var menuW = 550; var menuW = 325;
var menuH = 220; var menuH = 220;
window.onload = function() { window.onload = function() {
var d; var d;
@ -159,32 +197,68 @@ if (comprueba_login() == 0) {
<body> <body>
<div id='divmenu' class='menu'> <div id='divmenu' class='menu'>
<b>Configuration Menu</b><br>Please, make your changes and apply with <i>Reload</i> button<BR><BR> <b>Pandora FMS Graph configuration menu</b><br>Please, make your changes and apply with <i>Reload</i> button
<form method='get' action='stat_win.php'> <form method='get' action='stat_win.php'>
<table> <?php
<tr><td><B>Actual configuration</B> <BR></td> echo "<input type='hidden' name='id' value='$id'>";
<td><B>Configurable parameters</B> <BR></td> echo "<input type='hidden' name='label' value='$label'>";
</tr> ?>
<tr><td> <TABLE class='databox_frame' cellspacing=5>
<?php
echo "<input type='hidden' name='id' value='$id'>";
echo "<input type='hidden' name='refresh' value='$refresh'>";
echo "<input type='hidden' name='zoom' value='$zoom'>";
echo "<input type='hidden' name='event' value='$draw_events'>";
?>
</td><td> </td><td>
<?php <?php
echo "Refresh <input type='text' name='refresh' value='" . $refresh . "'> seconds <br>"; echo "<tr><td>";
echo "Zoom <input type='text' name='zoom' value='" . $zoom . "'> % <br>"; echo "Refresh time (sec)";
echo "Show events <input type='text' name='draw_events' value='" . $draw_events . "'> ( 1 or 0 ) <br>"; echo "<td>";
echo "<input type='text' size=5 name='refresh' value='" . $refresh . "'>";
echo "<tr><td>";
echo "Zoom factor (1x)";
echo "<td>";
echo "<select name=zoom>";
echo "<option value='$zoom'>"."x".$zoom;
echo "<option value='1'>"."x1";
echo "<option value='2'>"."x2";
echo "<option value='3'>"."x3";
echo "<option value='4'>"."x4";
echo "</select>";
echo "<tr><td>";
echo "Range of time";
echo "<td>";
echo "<select name='period'>";
echo "<option value=$period>".$period_label;
echo "<option value=3600>"."Hour";
echo "<option value=21600>"."6 Hours";
echo "<option value=43200>"."12 Hours";
echo "<option value=86400>"."Last day";
echo "<option value=604800>"."Last Week";
echo "<option value=1296000>"."15 days";
echo "<option value=2592000>"."Last Month";
echo "<option value=5184000>"."Two Month";
echo "<option value=15552000>"."Six Months";
echo "</select>";
echo "<tr><td>";
echo "Show events ";
echo "<td>";
if ($draw_events == 1)
echo "<input type='checkbox' name='draw_events' CHECKED value=1>";
else
echo "<input type='checkbox' name='draw_events' value=1>";
echo "<tr><td>";
echo "Show alert ";
echo "<td>";
if ($draw_alerts == 1)
echo "<input type='checkbox' name='draw_alerts' value=1 CHECKED>";
else
echo "<input type='checkbox' name='draw_alerts' value=1>";
echo "<td>";
echo "<input type='submit' class='sub next' value='GO'>";
?> ?>
</td></tr> </td></tr>
</table> </table>
<input type="submit" value="reload">
</form> </form>
</div> </div>