2008-06-23 Sancho Lerena <slerena@gmail.com>

* pandoradb.sql: Removed table "tquicksession". Not ever used.

	* pandoradb_data.sql: Updated Scheme build.

	* agent_manager.php: Removed a debug "echo".

	* db_sanity.php: Added feature to delete id_module 0 modules.

	* 3.png: Added image for AIX in network maps.

	* functions_db.php: Fixed a div0 in return_moduledata_avg_value(). 
	Added server_status() that calculate modules for each server kind,
	and return a consistent LAG calculation.

	* menu.php: Better Server view menu visualization.

	* estado_ultimopaquete.php: Don't show disabled modules anymore.

	* vier_server.php,
	tactical.php: Removed old server status code, and used server_status()
	function to get all data.

	* graph_viewer.php: Added ACL checks for each graph element.

	* fgraph.php: Negative values are now rendered in single graphs.

	* pandoradb*.sql (1.3 to 2.0, and 1.3 to 2.0): Deleted, not working.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@894 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2008-06-23 14:36:22 +00:00
parent f5a7114a87
commit 2fdf0e435b
18 changed files with 219 additions and 547 deletions

View File

@ -1,4 +1,34 @@
2008-06-20 Esteban Sanchez <estebans@artica.es>
2008-06-23 Sancho Lerena <slerena@gmail.com>
* pandoradb.sql: Removed table "tquicksession". Not ever used.
* pandoradb_data.sql: Updated Scheme build.
* agent_manager.php: Removed a debug "echo".
* db_sanity.php: Added feature to delete id_module 0 modules.
* 3.png: Added image for AIX in network maps.
* functions_db.php: Fixed a div0 in return_moduledata_avg_value().
Added server_status() that calculate modules for each server kind,
and return a consistent LAG calculation.
* menu.php: Better Server view menu visualization.
* estado_ultimopaquete.php: Don't show disabled modules anymore.
* vier_server.php,
tactical.php: Removed old server status code, and used server_status()
function to get all data.
* graph_viewer.php: Added ACL checks for each graph element.
* fgraph.php: Negative values are now rendered in single graphs.
2008-06-23 Esteban Sanchez <estebans@artica.es>
* functions_db.php: Fixed get_agents_in_group() to handle "All" group
properly and make it capable to get disabled agents or not. Style

View File

@ -160,7 +160,6 @@ echo '</b></td><td class="datos">';
echo '<select name="plugin_server" class="w130">';
echo "<option value='".$id_plugin_server."'>".give_server_name($id_plugin_server);
$sql1 = 'SELECT id_server, name FROM tserver where plugin_server = 1 ORDER BY name';
echo $sql1;
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
echo "<option value='".$row["id_server"]."'>".$row["name"]."</option>";

View File

@ -74,6 +74,9 @@ if ($sanity == 1) {
$sql = "DELETE FROM tagente_estado WHERE id_agente_modulo = $id_agente_modulo";
mysql_query ($sql);
}
echo "Deleting bad module (id 0)<br>";
$sql = "DELETE FROM tagente_modulo WHERE id_modulo = 0";
mysql_query ($sql);
}
echo "<br>";

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -2,10 +2,10 @@
// Begin of automatic config file
$config["dbname"]="pandora"; // MySQL DataBase name
$config["dbuser"]="pandora"; // DB User
$config["dbpass"]="dstxhvec"; // DB Password
$config["dbpass"]="pandora"; // DB Password
$config["dbhost"]="localhost"; // DB Host
$config["homedir"]="/var/www/pandora/"; // Config homedir
$config["homeurl"]="http://localhost/pandora"; // Base URL
$config["homedir"]="/var/www/pandora_console/"; // Config homedir
$config["homeurl"]="http://localhost/pandora_console"; // Base URL
// End of automatic config file
?><?php

View File

@ -1447,7 +1447,10 @@ function return_moduledata_avg_value ($id_agent_module, $period, $date = 0) {
$previous_data = get_previous_data ($id_agent_module, $datelimit);
if ($previous_data)
return ($previous_data['datos'] + $sum) / ($total + 1);
return $sum / $total;
if ($total > 0)
return $sum / $total;
else
return 0;
}
/**
@ -1845,4 +1848,71 @@ function smal_event_table ($filter = "", $limit = 10, $width = 440) {
}
echo "</table>";
}
/**
* Get statistical information for a given server
*
* @param id_server
*
* @return : Serverifo array with following keys:
type - Type of server (descriptive)
modules_total - Total of modules for this kind of servers
modules - Modules running on this server
module_lag - of modules of time
lag - Lag time in sec
*/
function server_status ($id_server) {
$server = get_db_row_sql ( "SELECT * FROM tserver WHERE id_server = $id_server" );
$serverinfo = array();
if ($server["network_server"] == 1)
$serverinfo["type"]="network";
elseif ($server["data_server"] == 1)
$serverinfo["type"]="data";
elseif ($server["plugin_server"] == 1)
$serverinfo["type"]="plugin";
elseif ($server["wmi_server"] == 1)
$serverinfo["type"]="wmi";
elseif ($server["recon_server"] == 1)
$serverinfo["type"]="recon";
elseif ($server["snmp_server"] == 1)
$serverinfo["type"]="snmp";
elseif ($server["prediction_server"] == 1)
$serverinfo["type"]="prediction";
// Get type of modules that runs this server
$moduletype = get_db_sql ("SELECT MAX(id_modulo) FROM tagente_estado, tagente_modulo WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.running_by = $id_server ORDER BY tagente_modulo.id_agente_modulo ");
if ($moduletype != ""){
$serverinfo["modules_total"] = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE tagente_modulo.disabled = 0 AND tagente_modulo.id_modulo = $moduletype");
$serverinfo["modules"] = get_db_sql ("SELECT COUNT(tagente_estado.running_by) FROM tagente_estado, tagente_modulo WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_modulo.id_modulo = $moduletype AND tagente_estado.running_by = $id_server");
$serverinfo["module_lag"] = get_db_sql ("SELECT COUNT(tagente_estado.last_execution_try) FROM tagente_estado, tagente_modulo, tagente WHERE tagente_estado.last_execution_try > 0 AND tagente_estado.running_by=$id_server AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.id_modulo = $moduletype AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200) ");
// Lag over 1200 secons is not lag, is module without contacting data in several time.or with a
// 1200 sec is 20 min
$serverinfo["lag"] = get_db_sql ("SELECT MAX(tagente_estado.last_execution_try - tagente_estado.current_interval) FROM tagente_estado, tagente_modulo, tagente WHERE tagente_estado.last_execution_try > 0 AND tagente_estado.running_by=$id_server AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.id_modulo = $moduletype AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200) ");
if ($serverinfo["lag"] == "")
$serverinfo["lag"] = 0;
else
$serverinfo["lag"] = $serverinfo["lag"] ;
} else {
$serverinfo["modules_total"] = 0;
$serverinfo["modules"] = 0;
$serverinfo["module_lag"] = 0;
$serverinfo["lag"] = 0;
}
$nowtime = time();
if ($serverinfo["lag"] != 0){
$serverinfo["lag"] = $nowtime - $serverinfo["lag"];
}
return $serverinfo;
}
?>

View File

@ -31,7 +31,7 @@ $timestamp_lof = $row_t["ultimo_contacto"];
$intervalo_agente = $row_t["intervalo"];
// Get last packet
$sql3='SELECT * FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente = '.$id_agente.' AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo ORDER BY id_module_group, nombre';
$sql3='SELECT * FROM tagente_modulo, tagente_estado WHERE tagente_modulo.disabled = 0 AND tagente_modulo.id_agente = '.$id_agente.' AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo ORDER BY id_module_group, nombre';
$label_group=0;
$last_label = "";
echo "<h2>".$lang_label["ag_title"]." &gt; ";

View File

@ -112,7 +112,6 @@ function create_node($agent, $simple = 0) {
if (strlen($name) > 12)
$name = substr($name,0,12);
if ($simple == 0){
// Set node icon
if (file_exists('images/networkmap/' . $agent['id_os'] . '.png')) {

View File

@ -172,12 +172,7 @@
// Server information
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Get total modules defined (network)
$total_modules_network = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4 AND id_tipo_modulo < 19 AND id_tipo_modulo != 100");
// Get total modules defined (data)
$total_modules_data = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo < 5 OR id_tipo_modulo = 100");
// Connect DataBase
$sql='SELECT * FROM tserver';
$result=mysql_query($sql);
if (mysql_num_rows($result)){
@ -214,130 +209,43 @@
$description = $row["description"];
$version = $row["version"];
$modules_server = 0;
if (($network_server == 1) OR ($data_server == 1)){
// Get total modules defined for this server (data modules)
$sql2 = "SELECT COUNT(running_by) FROM tagente_estado WHERE running_by = $id_server";
$result2=mysql_query($sql2);
$row2=mysql_fetch_array($result2);
$modules_server = $row2[0];
echo "<tr><td class='$tdcolor'>";
echo "<b>$name</b>";
echo "<td class='$tdcolor' align='middle'>";
if ($status ==0){
echo "<img src='images/pixel_red.png' width=20 height=20>";
} else {
echo "<img src='images/pixel_green.png' width=20 height=20>";
}
echo "<td class='$tdcolor' align='middle'>";
if (($network_server == 1) OR ($data_server == 1)){
// Progress bar calculations
if ($network_server == 1){
$total_modules_network_LAG = get_db_sql ("SELECT COUNT( tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tagente_estado WHERE id_network_server = $id_server AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.id_tipo_modulo > 4 AND tagente_modulo.id_tipo_modulo < 19 AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND (((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP()) OR tagente_modulo.flag = 1 );");
if ($modules_server == 0)
$percentil = 0;
if ($modules_server > 0)
$percentil = $modules_server / ($total_modules_network / 100);
else
$percentil = 0;
$total_modules_temp = $total_modules_network;
} else {
$total_modules_network_LAG = get_db_sql ("SELECT COUNT( tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tagente_estado WHERE tagente_estado.running_by = $id_server AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND (((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP()) OR tagente_modulo.flag = 1 );");
if ($total_modules_data == 0)
$percentil = 0;
else
$percentil = $modules_server / ($total_modules_data / 100);
$total_modules_temp = $total_modules_data;
}
} elseif ($recon_server == 1){
$sql2 = "SELECT COUNT(id_rt) FROM trecon_task WHERE id_network_server = $id_server";
$result2=mysql_query($sql2);
$row2=mysql_fetch_array($result2);
$modules_server = $row2[0];
$sql2 = "SELECT COUNT(id_rt) FROM trecon_task";
$result2=mysql_query($sql2);
$row2=mysql_fetch_array($result2);
$total_modules = $row2[0];
if ($total_modules == 0)
$percentil = 0;
else
$percentil = $modules_server / ($total_modules / 100);
$total_modules_temp = $total_modules;
}
else
echo "-";
if (($network_server == 1) OR ($data_server == 1) OR ($recon_server == 1)){
if ($percentil > 100)
$percentil = 100;
// Progress bar render
echo '<img src="reporting/fgraph.php?tipo=progress&percent='.$percentil.'&height=18&width=80">';
}
// Number of modules
echo "<td class='$tdcolor'>";
if (($recon_server ==1) OR ($network_server == 1) OR ($data_server == 1))
echo $modules_server . " / ". $total_modules_temp;
else
echo "-";
// LAG CHECK
echo "<td class='$tdcolor'>";
// Calculate lag: get oldest module of any proc_type, for this server,
// and calculate difference in seconds
// Get total modules defined for this server
if (($network_server == 1) OR ($data_server == 1)){
if ($network_server == 1)
$sql1 = "SELECT MIN(last_execution_try),current_interval FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY current_interval ORDER BY 1";
if ($data_server == 1)
// This only checks for agent with a last_execution_try of at
// maximun: ten times it's interval.... if is bigger, it probably
// will be because an agent down
$sql1 = "SELECT MAX(last_execution_try), current_interval, id_agente FROM tagente_estado WHERE last_execution_try > 0 AND (tagente_estado.last_execution_try + (tagente_estado.current_interval *10) > UNIX_TIMESTAMP()) AND running_by=$id_server GROUP BY id_agente ORDER BY 1 ASC LIMIT 1";
$nowtime = time();
$maxlag=0;
if ($result1=mysql_query($sql1))
while ($row1=mysql_fetch_array($result1)){
if (($row1[0] + $row1[1]) < $nowtime){
$maxlag2 = $nowtime - ($row1[0] + $row1[1]);
// More than 5 times module interval is not lag, is a big
// problem in agent, network or servers..
if ($maxlag2 < ($row1[1]*5))
if ($maxlag2 > $maxlag)
$maxlag = $maxlag2;
}
}
if ($maxlag < 60)
echo $maxlag." sec";
elseif ($maxlag < 86400)
echo format_numeric($maxlag/60) . " min";
elseif ($maxlag > 86400)
echo "+1 ".$lang_label["day"];
echo " - ".$total_modules_network_LAG ." ".lang_string("modules");
} elseif ($recon_server == 1) {
$sql1 = "SELECT * FROM trecon_task WHERE id_network_server = $id_server";
$result1=mysql_query($sql1);
$nowtime = time();
$maxlag=0;$maxlag2=0;
while ($row1=mysql_fetch_array($result1)){
if (($row1["utimestamp"] + $row1["interval_sweep"]) < $nowtime){
$maxlag2 = $nowtime - ($row1["utimestamp"] + $row1["interval_sweep"]);
if ($maxlag2 > $maxlag)
$maxlag = $maxlag2;
}
}
if ($maxlag < 60)
echo $maxlag." sec";
elseif ($maxlag < 86400)
echo format_numeric($maxlag/60) . " min";
elseif ($maxlag > 86400)
echo "+1 ".$lang_label["day"];
} else
echo "--";
$serverinfo = server_status ($id_server);
// Name of server
echo "<tr><td class='$tdcolor'>";
echo $name;
// Status
echo "<td class='$tdcolor' align='middle'>";
if ($status ==0){
echo "<img src='images/pixel_red.png' width=20 height=20>";
} else {
echo "<img src='images/pixel_green.png' width=20 height=20>";
}
// Load
echo "<td class='$tdcolor' align='middle'>";
if ($serverinfo["modules_total"] > 0)
$percentil = $serverinfo["modules"] / ( $serverinfo["modules_total"]/ 100);
else
$percentil = 0;
if ($percentil > 100)
$percentil = 100;
// Progress bar render
echo '<img src="reporting/fgraph.php?tipo=progress&percent='.$percentil.'&height=18&width=80">';
// Modules
echo "<td class='$tdcolor' align='middle'>";
echo $serverinfo["modules"] . " ".lang_string("of")." ". $serverinfo["modules_total"];
// Lag
echo "<td class='$tdcolor' align='middle'>";
echo human_time_description_raw ($serverinfo["lag"]) . " / ". $serverinfo["module_lag"];
}
echo '</table>';

View File

@ -121,7 +121,7 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) {
// Server view
if ( isset($_GET["sec2"]) && $_GET["sec2"] == "operation/servers/view_server") {
if ( isset($_GET["sec"]) && $_GET["sec"] == "estado_server") {
echo '<div id="op2s">';
} else {
echo '<div id="op2">';

View File

@ -78,12 +78,15 @@ if (isset($_GET["view_graph"])){
while ( $row2 = mysql_fetch_array($res2)){
$weight = $row2["weight"];
$id_agent_module = $row2["id_agent_module"];
if (!isset($modules)){
$modules = $id_agent_module;
$weights = $weight;
} else {
$modules = $modules.",".$id_agent_module;
$weights = $weights.",".$weight;
$id_grupo = get_db_sql ("SELECT id_grupo FROM tagente, tagente_modulo WHERE tagente_modulo.id_agente_modulo = $id_agent_module AND tagente.id_agente = tagente_modulo.id_agente");
if (give_acl($config["id_user"], $id_grupo, "AR")==1){
if (!isset($modules)){
$modules = $id_agent_module;
$weights = $weight;
} else {
$modules = $modules.",".$id_agent_module;
$weights = $weights.",".$weight;
}
}
}
echo "<h2>".$lang_label["reporting"]." &gt; ";

View File

@ -36,13 +36,6 @@ if ((give_acl($id_user, 0, "AR")==0) AND (give_acl($id_user,0,"AW") == 0) AND (d
echo "<h2>".$lang_label["view_servers"]." &gt; ";
echo $lang_label["server_detail"]."</h2>";
// Get total modules defined (network)
$total_modules_network = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4 AND id_tipo_modulo != 100");
// Get total modules defined (data)
$total_modules_data = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo < 5 OR id_tipo_modulo = 100");
// Connect DataBase
$sql='SELECT * FROM tserver';
$result=mysql_query($sql);
if (mysql_num_rows($result)){
@ -87,133 +80,42 @@ if (mysql_num_rows($result)){
$description = $row["description"];
$version = $row["version"];
$modules_server = 0;
// Get total modules defined for this server (data modules)
$modules_server = get_db_sql ("SELECT COUNT(running_by) FROM tagente_estado WHERE running_by = $id_server");
echo "<tr><td class='$tdcolor'>";
// Recon server detail
if ($recon_server == 1)
if (give_acl($id_user, 0, "PM")==1)
echo "<b><a href='index.php?sec=estado_server&sec2=operation/servers/view_server_detail&server_id=$id_server'>$name</a></b> ";
else
echo "<b>$name</b>";
else
echo "<b>$name</b>";
// Status (bad or good)
echo "<td class='$tdcolor' align='middle'>";
if ($status ==0){
echo "<img src='images/pixel_red.png' width=20 height=20>";
} else {
echo "<img src='images/pixel_green.png' width=20 height=20>";
}
echo "<td class='$tdcolor' align='middle'>";
if (($snmp_server == 0) OR ($recon_server == 0)){
// Progress bar calculations
if ($network_server == 1){
if ($total_modules_network == 0)
$percentil = 0;
if ($total_modules_network > 0)
$percentil = $modules_server / ($total_modules_network / 100);
else
$percentil = 0;
$total_modules_temp = $total_modules_network;
$serverinfo = server_status ($id_server);
// Name of server
echo "<tr><td class='$tdcolor'>";
echo $name;
// Status
echo "<td class='$tdcolor' align='middle'>";
if ($status ==0){
echo "<img src='images/pixel_red.png' width=20 height=20>";
} else {
if ($total_modules_data == 0)
$percentil = 0;
else
$percentil = $modules_server / ($total_modules_data / 100);
$total_modules_temp = $total_modules_data;
echo "<img src='images/pixel_green.png' width=20 height=20>";
}
} elseif ($recon_server == 1){
$modules_server = get_db_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE id_network_server = $id_server");
$total_modules = get_db_sql ("SELECT COUNT(id_rt) FROM trecon_task");
if ($total_modules == 0)
// Load
echo "<td class='$tdcolor' align='middle'>";
if ($serverinfo["modules_total"] > 0)
$percentil = $serverinfo["modules"] / ( $serverinfo["modules_total"]/ 100);
else
$percentil = 0;
else
$percentil = $modules_server / ($total_modules / 100);
$total_modules_temp = $total_modules;
}
else
echo "-";
if ($percentil > 100)
$percentil = 100;
// Progress bar render
// Progress bar render
if ($snmp_server == 0) {
// Check bad values for percentile
if ($percentil > 100){
$percentil = 100;
}
if ($percentil < 0){
$percentil = 0;
}
echo '<img src="reporting/fgraph.php?tipo=progress&percent='.$percentil.'&height=18&width=80">';
}
echo '<img src="reporting/fgraph.php?tipo=progress&percent='.$percentil.'&height=18&width=80">';
// Modules
echo "<td class='$tdcolor' align='middle'>";
echo $serverinfo["modules"] . " ".lang_string("of")." ". $serverinfo["modules_total"];
// Lag
echo "<td class='$tdcolor' align='middle'>";
echo human_time_description_raw ($serverinfo["lag"]) . " / ". $serverinfo["module_lag"];
// Number of modules
echo "<td class='$tdcolor'>";
if (($recon_server ==1) OR ($network_server == 1) OR ($data_server == 1)){
echo $modules_server . ' / '. $total_modules_temp;
} else {
echo "-";
}
// LAG CHECK
echo "<td class='$tdcolor'>";
// Calculate lag: get oldest module of any proc_type, for this server,
// and calculate difference in seconds
// Get total modules defined for this server
if (($network_server == 1) OR ($data_server == 1) OR ($wmi_server == 1) OR ($plugin_server == 1)) {
if (($network_server == 1) OR ($wmi_server == 1) OR ($plugin_server == 1)) {
$sql1 = "SELECT MIN(last_execution_try),current_interval FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY current_interval ORDER BY 1";
} elseif ($data_server == 1){
// This only checks for agent with a last_execution_try of at
// maximun: ten times it's interval.... if is bigger, it probably
// will be because an agent down
$sql1 = "SELECT MAX(last_execution_try), current_interval, id_agente FROM tagente_estado WHERE last_execution_try > 0 AND (tagente_estado.last_execution_try + (tagente_estado.current_interval * 10) > UNIX_TIMESTAMP()) AND running_by=$id_server GROUP BY id_agente ORDER BY 1 ASC LIMIT 1";
}
$nowtime = time();
$maxlag=0;
if ($result1=mysql_query($sql1))
while ($row1=mysql_fetch_array($result1)){
if (($row1[0] + $row1[1]) < $nowtime){
$maxlag2 = $nowtime - ($row1[0] + $row1[1]);
// More than 5 times module interval is not lag, is a big
// problem in agent, network or servers..
if ($maxlag2 < ($row1[1]*5))
if ($maxlag2 > $maxlag)
$maxlag = $maxlag2;
}
}
if ($maxlag < 60)
echo $maxlag." sec";
elseif ($maxlag < 86400)
echo format_numeric($maxlag/60) . " min";
elseif ($maxlag > 86400)
echo "+1 ".$lang_label["day"];
} elseif ($recon_server == 1) {
$sql1 = "SELECT * FROM trecon_task WHERE id_network_server = $id_server";
$result1=mysql_query($sql1);
$nowtime = time();
$maxlag=0;$maxlag2=0;
while ($row1=mysql_fetch_array($result1)){
if (($row1["utimestamp"] + $row1["interval_sweep"]) < $nowtime){
$maxlag2 = $nowtime - ($row1["utimestamp"] + $row1["interval_sweep"]);
if ($maxlag2 > $maxlag)
$maxlag = $maxlag2;
}
}
if ($maxlag < 60)
echo $maxlag." sec";
elseif ($maxlag < 86400)
echo format_numeric($maxlag/60) . " min";
elseif ($maxlag > 86400)
echo "+1 ".$lang_label["day"];
} else {
echo "--";
}
echo "<td class='".$tdcolor."f9'>".substr($description,0,25)."</td>";
echo "<td class='$tdcolor' align='middle'>";
if ($network_server == 1){

View File

@ -688,15 +688,6 @@ CREATE TABLE `tserver_export` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Used to implement fast login (using a predefined hash)
CREATE TABLE `tquicksession` (
`id` int(20) unsigned NOT NULL auto_increment,
`id_user` varchar(250) NOT NULL default '',
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`pwdhash` varchar(250) NOT NULL default '',
PRIMARY KEY (`id`)
);
CREATE TABLE `tserver_export_data` (
`id` int(20) unsigned NOT NULL auto_increment,

View File

@ -1,106 +0,0 @@
----------------------------------------------------------------------
-- Database schema modifications to upgrade from 1.3 to 1.4 version
----------------------------------------------------------------------
-- Old tables deteled
--DROP TABLE tmodule;
--DROP TABLE talerta_agente_modulo;
-- There is not migration code yet, do not delete without make backup !
-- New tables
CREATE TABLE `tagent_data_image` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`id_agente_modulo` mediumint(8) unsigned NOT NULL default '0',
`blob` blob NOT NULL,
`filename` varchar(255) default '',
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`id_agente` mediumint(8) unsigned NOT NULL default '0',
`utimestamp` int(10) unsigned default '0',
PRIMARY KEY (`id`),
KEY `img_idx2` (`id_agente`,`id_agente_modulo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE tnotification (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(255) default '',
`description` varchar(255) default '',
`id_alerta` int(11) NOT NULL default '0',
`id_agent` int(11) NOT NULL default '0',
`al_f1` varchar(255) default '',
`al_f2` mediumtext NOT NULL,
`al_f3` mediumtext NOT NULL,
`alrec_f1` varchar(255) default '',
`alrec_f2` mediumtext NOT NULL,
`alrec_f3` mediumtext NOT NULL,
`recovery_notify` tinyint(3) default '0',
`disabled` tinyint(3) default '0',
`last_fired` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id_aam`),
KEY `tnotif_indx_1` (`id_alerta`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tnotification_component` (
`id` int(11) unsigned NOT NULL auto_increment,
`id_notification` int(11) NOT NULL default '0',
`id_agente_modulo` int(11) NOT NULL default '0',
`dis_max` double(18,2) default NULL,
`dis_min` double(18,2) default NULL,
`alert_text` varchar(255) default '',
`time_threshold` int(11) NOT NULL default '0',
`last_fired` datetime NOT NULL default '0000-00-00 00:00:00',
`max_alerts` int(4) NOT NULL default '1',
`min_alerts` int(4) NOT NULL default '0',
`logical_type` tinyint(3) NOT NULL default '0',
-- 0 OR, 1 AND, 2 NOT
`internal_counter` int(4) default '0',
`times_fired` int(11) NOT NULL default '0',
`disabled` int(4) default '0',
`time_from` TIME default '00:00:00',
`time_to` TIME default '00:00:00',
PRIMARY KEY (`id_aam`),
KEY `tnotifcom_indx_1` (`id_notification`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE tplugin (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
`description` mediumtext default "",
`max_timeout` int(4) UNSIGNED NOT NULL default 0,
`execute`varchar(250) NOT NULL,
PRIMARY KEY('id')
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tagent_plugin` (
`id` int(10) unsigned NOT NULL auto_increment,
`id_agent` int(11) NOT NULL default '0',
`id_plugin` int(11) NOT NULL default '0',
`net_dst` varchar(250) default '',
`net_port` varchar(250) default '',
`access_user` varchar(250) default '',
`access_pass` varchar(250) default '',
`field1` varchar(250) default '',
`field2` varchar(250) default '',
`field3` varchar(250) default '',
`field4` varchar(250) default '',
`field5` varchar(250) default ''
`id_module_group` int(4) unsigned default '0',
`flag` tinyint(3) unsigned default '1',
`disabled` tinyint(3) unsigned default '0',
`export` tinyint(3) unsigned default '0',
PRIMARY KEY (`id_agente_modulo`, `id_agente`),
KEY `tam_agente` (`id_agente`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Updated tables
ALTER TABLE tagente_modulo ADD COLUMN `disable` tinyint(3) unsigned NULL default 0;
ALTER TABLE tagente_modulo ADD COLUMN `export` tinyint(3) unsigned default '0';
ALTER TABLE tagente ADD COLUMN `id_parent` mediumint(8) unsigned default '0';
ALTER TABLE tagente_estado ADD COLUMN `id_agent_plugin` int(20) NOT NULL default '0';
ALTER TABLE tagente_modulo ADD COLUMN `predictive_id_module_source` bigint(100) unsigned default 0;

View File

@ -53,7 +53,7 @@ INSERT INTO `tconfig` VALUES
(6,'graph_res','5'),
(7,'step_compact','1'),
(8,'db_scheme_version','2.0'),
(9,'db_scheme_build','PD80401'),
(9,'db_scheme_build','PD80619'),
(13,'show_unknown','0'),
(14,'show_lastalerts','1'),
(15,'style','pandora'),

View File

@ -1,12 +0,0 @@
-- New data
UPDATE tconfig SET value = '1.4-dev' WHERE token = 'db_scheme_version';
UPDATE tconfig SET value = 'PD080121' WHERE token = 'db_scheme_build';
INSERT INTO `ttipo_modulo` VALUES (100,'keep_alive',-1,'KeepAlive','mod_keepalive.png'), (19, 'image_jpg',4,'Image JPG data', 'mod_image_jpg.png'), (20, 'image_png',4,'Image PNG data', 'mod_image_png.png'), (21, 'async_proc', 5, 'Asyncronous proc data', 'mod_async_proc.png'), (22, 'async_data', 5, 'Asyncronous numeric data', 'mod_async_data.png'), (23, 'async_string', 5, 'Asyncronous string data', 'mod_async_string.png'), (24, 'predictive', 5, 'Predictive Estimation Data', 'mod_predictive.png');
INSERT INTO tconfig (token, value) VALUES ('string_days_purge','7');
INSERT INTO tconfig (token, value) VALUES ('image_days_purge','2');

View File

@ -1,119 +0,0 @@
UPDATE tconfig SET value = '1.3' WHERE token = 'db_scheme_version';
UPDATE tconfig SET value = '1.3' WHERE token = 'db_scheme_build';
INSERT INTO tconfig (token, value) VALUES ('show_unknown','0');
INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1');
INSERT INTO tconfig (token, value) VALUES ('style','pandora');
UPDATE tconfig_os SET icon_name = 'so_aix.png' WHERE icon_name = 'so_aix.gif';
UPDATE tconfig_os SET icon_name = 'so_linux.png' WHERE icon_name = 'so_linux.gif';
UPDATE tconfig_os SET icon_name = 'so_solaris.png' WHERE icon_name = 'so_solaris.gif';
UPDATE tconfig_os SET icon_name = 'so_hpux.png' WHERE icon_name = 'so_hpux.gif';
UPDATE tconfig_os SET icon_name = 'so_beos.png' WHERE icon_name = 'so_beos.gif';
UPDATE tconfig_os SET icon_name = 'so_cisco.png' WHERE icon_name = 'so_cisco.gif';
UPDATE tconfig_os SET icon_name = 'so_mac.png' WHERE icon_name = 'so_mac.gif';
UPDATE tconfig_os SET icon_name = 'so_win.png' WHERE icon_name = 'so_win.gif';
UPDATE tconfig_os SET icon_name = 'so_other.png' WHERE icon_name = 'so_other.gif';
UPDATE tconfig_os SET icon_name = 'network.png' WHERE icon_name = 'network.gif';
UPDATE tgrupo SET icon = 'world', parent = 0, disabled = 0 WHERE id_grupo = 1;
UPDATE tgrupo SET icon = 'server_database', parent = 0, disabled = 0 WHERE id_grupo = 2;
UPDATE tgrupo SET icon = 'eye', parent = 0, disabled = 0 WHERE id_grupo = 3;
UPDATE tgrupo SET icon = 'firewall', parent = 0, disabled = 0 WHERE id_grupo = 4;
UPDATE tgrupo SET icon = 'database_gear', parent = 0, disabled = 0 WHERE id_grupo = 8;
UPDATE tgrupo SET icon = 'transmit', parent = 0, disabled = 0 WHERE id_grupo = 9;
UPDATE tgrupo SET icon = 'house', parent = 0, disabled = 0 WHERE id_grupo = 10;
UPDATE tgrupo SET icon = 'computer', parent = 0, disabled = 0 WHERE id_grupo = 11;
UPDATE tgrupo SET icon = 'applications', parent = 0, disabled = 0 WHERE id_grupo = 12;
INSERT INTO `tnetwork_component` VALUES (3,'Sysname','Get name of system using SNMP standard MIB',1,17,0,0,900,0,'','','public','.1.3.6.1.2.1.1.1.0',1);
INSERT INTO `tnetwork_component` VALUES (19,'Power #1','PowerSupply #1 status',6,18,0,0,300,0,'','','public',' .1.3.6.1.4.1.2334.2.1.5.8.0',4);
INSERT INTO `tnetwork_component` VALUES (20,'Power #2','PowerSupply #2 status',6,18,0,0,300,0,'','','public',' .1.3.6.1.4.1.2334.2.1.5.10.0',4);
INSERT INTO `tnetwork_component` VALUES (22,'HSRP Status','Get status of HSRP',2,18,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.106.1.2.1.1.15.12.106',2);
INSERT INTO `tnetwork_component` VALUES (24,'NIC #1 status','Status of NIC#1',10,18,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.8.1',2);
INSERT INTO `tnetwork_component` VALUES (25,'NIC #2 status','Status of NIC #2',10,18,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.8.2',2);
INSERT INTO `tnetwork_component` VALUES (26,'NIC #3 status','Status of NIC #3',10,18,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.8.3',2);
INSERT INTO `tnetwork_component` VALUES (27,'NIC #1 outOctects','Output throughtput on Interface #1',10,16,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.16.1',2);
INSERT INTO `tnetwork_component` VALUES (28,'NIC #2 outOctects','Output troughtput on interface #2',10,16,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.16.2',1);
INSERT INTO `tnetwork_component` VALUES (29,'NIC #3 outOctects','Output troughtput on Interface #3',10,16,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.16.3',2);
INSERT INTO `tnetwork_component` VALUES (30,'NIC #1 inOctects','Input troughtput on Interface #1',10,16,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.10.1',2);
INSERT INTO `tnetwork_component` VALUES (31,'NIC #2 inOctects','Input throughtput for interface #2',10,16,0,0,180,0,'','NULL','public','.1.3.6.1.2.1.2.2.1.10.2',2);
INSERT INTO `tnetwork_component` VALUES (32,'NIC #3 inOctects','Input throught on interface #3',10,16,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.10.3',2);
INSERT INTO `tnetwork_component` VALUES (34,'Host Alive','Check if host is alive using ICMP ping check.',10,6,0,0,120,0,'','','','',2);
INSERT INTO `tnetwork_component` VALUES (36,'Host Latency','Get host network latency in miliseconds, using ICMP.',10,7,0,0,180,0,'','','','',2);
INSERT INTO `tnetwork_component` VALUES (37,'Check HTTP Server','Test APACHE2 HTTP service remotely (Protocol response, not only openport)',10,9,0,0,300,80,'GET / HTTP/1.0^M^M','HTTP/1.1 200 OK','','',3);
INSERT INTO `tnetwork_component` VALUES (38,'Check FTP Server','Check FTP protocol, not only check port.',10,9,0,0,300,21,'QUIT','221','','',3);
INSERT INTO `tnetwork_component` VALUES (39,'Check SSH Server','Checks port 22 is opened',10,9,0,0,300,22,'','','','',2);
INSERT INTO `tnetwork_component` VALUES (40,'Check Telnet server','Check telnet port',10,9,0,0,300,23,'','','','',2);
INSERT INTO `tnetwork_component` VALUES (41,'Check SMTP server','Check if SMTP port it&#039;s open',10,9,0,0,300,25,'','','','',2);
INSERT INTO `tnetwork_component` VALUES (42,'Check POP3 server','Check POP3 port.',10,9,0,0,300,110,'','','','',2);
INSERT INTO `tnetwork_component` VALUES (43,'NIC #7 outOctects','Get outcoming octects from NIC #7',10,16,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.16.7',2);
INSERT INTO `tnetwork_component` VALUES (44,'NIC #7 inOctects','Get incoming octects from NIC #7',10,16,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.10.7',2);
INSERT INTO `tnetwork_component` VALUES (45,'NIC #4 Status','Get status of NIC #4',10,18,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.8.4',2);
INSERT INTO `tnetwork_component` VALUES (46,'NIC #5 Status','Get status of NIC #5',10,18,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.8.5',2);
INSERT INTO `tnetwork_component` VALUES (47,'NIC #6 Status','Get status of NIC #6',10,18,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.8.6',2);
INSERT INTO `tnetwork_component` VALUES (48,'NIC #7 Status','Get status of NIC #7',10,18,0,0,180,0,'','','public','.1.3.6.1.2.1.2.2.1.8.7',2);
INSERT INTO `tnetwork_component` VALUES (49,'CPU User','Linux User CPU Usage (%)',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.9.0',4);
INSERT INTO `tnetwork_component` VALUES (50,'CPU System','Linux System CPU usage',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.10.0',4);
INSERT INTO `tnetwork_component` VALUES (51,'System Context Change','Linux System Context changes ',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.8.0',4);
INSERT INTO `tnetwork_component` VALUES (52,'System Interrupts','Linux system interrupts ',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.7.0',4);
INSERT INTO `tnetwork_component` VALUES (53,'Sytem IO Sent','Linux System IO Sent ',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.5.0',4);
INSERT INTO `tnetwork_component` VALUES (54,'System IO Recv','Linux System IO Recv ',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.6.0',4);
INSERT INTO `tnetwork_component` VALUES (55,'System SwapIn ','Linux System Swap In',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.3.0',1);
INSERT INTO `tnetwork_component` VALUES (56,'System Buffer Memory','Linux System Buffer Memory (used as available memory)',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.4.14.0',4);
INSERT INTO `tnetwork_component` VALUES (57,'System Cached Memory','Linux System Cached Memory (used as free memory)',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.4.15.0',4);
INSERT INTO `tnetwork_component` VALUES (58,'System Processes','Total system process on any host',12,15,0,0,180,0,'','','public','.1.3.6.1.2.1.25.1.6.0',4);
INSERT INTO `tnetwork_component_group` VALUES (1,'General group',0);
INSERT INTO `tnetwork_component_group` VALUES (2,'Cisco MIBs',10);
INSERT INTO `tnetwork_component_group` VALUES (3,'Nortel MIBS',10);
INSERT INTO `tnetwork_component_group` VALUES (4,'3COM MIBs',10);
INSERT INTO `tnetwork_component_group` VALUES (5,'UNIX MIBs',12);
INSERT INTO `tnetwork_component_group` VALUES (6,'Packetshaper MIBs',10);
INSERT INTO `tnetwork_component_group` VALUES (7,'Nortel BPS 2000 MIBs',3);
INSERT INTO `tnetwork_component_group` VALUES (8,'Cisco Catalyst3750 MIBs',2);
INSERT INTO `tnetwork_component_group` VALUES (9,'Cisco AP120+',2);
INSERT INTO `tnetwork_component_group` VALUES (10,'Network Management',0);
INSERT INTO `tnetwork_component_group` VALUES (11,'Microsoft Windows MIB',12);
INSERT INTO `tnetwork_component_group` VALUES (12,'Operating Systems',0);
UPDATE ttipo_modulo SET icon = 'mod_data.png' WHERE icon = 'mod_data.gif';
UPDATE ttipo_modulo SET icon = 'mod_proc.png' WHERE icon = 'mod_proc.gif';
UPDATE ttipo_modulo SET icon = 'mod_string.png' WHERE icon = 'mod_string.gif';
UPDATE ttipo_modulo SET icon = 'mod_data_inc.png' WHERE icon = 'mod_data_inc.gif';
UPDATE ttipo_modulo SET icon = 'mod_icmp_proc.png' WHERE icon = 'mod_icmp_proc.gif';
UPDATE ttipo_modulo SET icon = 'mod_icmp_data.png' WHERE icon = 'mod_icmp_data.gif';
UPDATE ttipo_modulo SET icon = 'mod_tcp_data.png' WHERE icon = 'mod_tcp_data.gif';
UPDATE ttipo_modulo SET icon = 'mod_tcp_proc.png' WHERE icon = 'mod_tcp_proc.gif';
UPDATE ttipo_modulo SET icon = 'mod_tcp_string.png' WHERE icon = 'mod_tcp_string.gif';
UPDATE ttipo_modulo SET icon = 'mod_tcp_inc.png' WHERE icon = 'mod_tcp_inc.gif';
UPDATE ttipo_modulo SET icon = 'mod_udp_proc.png' WHERE icon = 'mod_udp_proc.gif';
UPDATE ttipo_modulo SET icon = 'mod_snmp_data.png' WHERE icon = 'mod_snmp_data.gif';
UPDATE ttipo_modulo SET icon = 'mod_snmp_inc.png' WHERE icon = 'mod_snmp_inc.gif';
UPDATE ttipo_modulo SET icon = 'mod_snmp_string.png' WHERE icon = 'mod_snmp_string.gif';
UPDATE ttipo_modulo SET icon = 'mod_snmp_proc.png' WHERE icon = 'mod_snmp_proc.gif';
INSERT INTO `tnews` VALUES (1,'admin','Welcome to Pandora FMS 1.3.1!','This is the new Pandora FMS Console. A lot of new features have been added since last version. Please read the documentation about it, and feel free to test any option.\r\n\r\nThe Pandora FMS Team.','2007-06-22 13:03:20');
INSERT INTO `tnetwork_profile` VALUES (1,'SNMP Basic management','Basic SNMP management (only first interface)');
INSERT INTO `tnetwork_profile` VALUES (2,'Basic Server','Check basic server services and network latency. This checks SSH, FTP and HTTP. Also a ICMP host alive check.');
INSERT INTO `tnetwork_profile` VALUES (3,'Linux SNMP','Linux SNMP Management');
INSERT INTO `tnetwork_profile_component` VALUES (1,24,1);
INSERT INTO `tnetwork_profile_component` VALUES (2,27,1);
INSERT INTO `tnetwork_profile_component` VALUES (3,30,1);
INSERT INTO `tnetwork_profile_component` VALUES (4,37,2);
INSERT INTO `tnetwork_profile_component` VALUES (5,38,2);
INSERT INTO `tnetwork_profile_component` VALUES (6,39,2);
INSERT INTO `tnetwork_profile_component` VALUES (7,36,2);
INSERT INTO `tnetwork_profile_component` VALUES (8,34,2);
INSERT INTO `tnetwork_profile_component` VALUES (9,51,3);
INSERT INTO `tnetwork_profile_component` VALUES (10,52,3);
INSERT INTO `tnetwork_profile_component` VALUES (11,53,3);
INSERT INTO `tnetwork_profile_component` VALUES (12,54,3);
INSERT INTO `tnetwork_profile_component` VALUES (13,55,3);
INSERT INTO `tnetwork_profile_component` VALUES (14,56,3);
INSERT INTO `tnetwork_profile_component` VALUES (15,57,3);

View File

@ -449,14 +449,6 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
$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];
*/
// Get the first data outsite (to the left---more old) of the interval given
$sql = sprintf ('SELECT datos, utimestamp FROM tagente_datos
WHERE id_agente = %d AND id_agente_modulo = %d
@ -470,26 +462,25 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
while ($row = mysql_fetch_array ($result)) {
$datos = $row[0];
$utimestamp = $row[1];
if ($datos >= 0) {
for ($i = 0; $i <= $resolution; $i++) {
if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){
$valores[$i][0]=$valores[$i][0]+$datos;
$valores[$i][1]++;
// Init min value
if ($valores[$i][4] == 0)
for ($i = 0; $i <= $resolution; $i++) {
if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){
$valores[$i][0]=$valores[$i][0]+$datos;
$valores[$i][1]++;
// Init min value
if ($valores[$i][4] == 0)
$valores[$i][4] = $datos;
else {
// Check min value
if ($datos < $valores[$i][4])
$valores[$i][4] = $datos;
else {
// Check min value
if ($datos < $valores[$i][4])
$valores[$i][4] = $datos;
}
// Check max value
if ($datos > $valores[$i][5])
$valores[$i][5] = $datos;
break;
}
}
// Check max value
if ($datos > $valores[$i][5])
$valores[$i][5] = $datos;
break;
}
}
}
}
// Calculate Average value for $valores[][0]
@ -504,6 +495,10 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
// Get max value for all graph
if ($valores[$i][5] > $max_value)
$max_value = $valores[$i][5];
// Get min value for all graph
if ($valores[$i][5] < $min_value)
$min_value = $valores[$i][5];
// Take prev. value
// TODO: CHeck if there are more than 24hours between
// data, if there are > 24h, module down.
@ -568,6 +563,7 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
$dataset_event = Image_Graph::factory('dataset');
$dataset_event -> setName("Event Fired");
}
// ... and populated with data ...
for ($i = 0; $i <= $resolution; $i++) {
$tdate = date('d/m', $valores[$i][2])."\n".date('H:i', $valores[$i][2]);
@ -583,7 +579,7 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
}
}
if ($max_value > 0){
if ($max_value != $min_value){
// Show alert limits
if ($show_alert == 1){
$Plot =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', IMAGE_GRAPH_AXIS_Y);
@ -607,15 +603,23 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
$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;
if (($min_value < 0) AND ($max_value > 0))
$AxisY->setLabelInterval( -1 * ceil(($min_value - $max_value)/ $yinterval ));
elseif ($min_value < 0)
$AxisY->setLabelInterval( -1 * ceil($min_value / $yinterval));
else
$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);