2009-09-14 Sancho Lerena <slerena@artica.es>

* general/error_dbconfig.php, 
	  general/error_authconfig.php
	  general/error_emptyconfig.php: Error messages have it's own page.

	* config_process.php, functions_config.php: Removed "inline" error pages, 
	and moved out. Auto_update is not set to ON if not present, just once, and
	this is managed by extension itself.

	* functions.php: Added function "return_graphtype" to calculate graphtype
	depending on id_module_type.

	* styles/install.css: Some style fixes.

	* operation/agentes/estado_monitores.php: Some code cleanup using the new 
	function to get graphtype.

	* operation/agentes/estado_ultimopaquete.php: Some code cleanup with the
	new function to get graphtype and fixed a bug in data timestamp calculation.

	* operation/agentes/status_monitor.php: monitor list now show quick links 
	to graph and show latest data, like the main agent view.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1935 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2009-09-14 01:02:44 +00:00
parent 7cddfea944
commit d52a1c4791
14 changed files with 299 additions and 137 deletions

View File

@ -1,3 +1,27 @@
2009-09-14 Sancho Lerena <slerena@artica.es>
* general/error_dbconfig.php,
general/error_authconfig.php
general/error_emptyconfig.php: Error messages have it's own page.
* config_process.php, functions_config.php: Removed "inline" error pages,
and moved out. Auto_update is not set to ON if not present, just once, and
this is managed by extension itself.
* functions.php: Added function "return_graphtype" to calculate graphtype
depending on id_module_type.
* styles/install.css: Some style fixes.
* operation/agentes/estado_monitores.php: Some code cleanup using the new
function to get graphtype.
* operation/agentes/estado_ultimopaquete.php: Some code cleanup with the
new function to get graphtype and fixed a bug in data timestamp calculation.
* operation/agentes/status_monitor.php: monitor list now show quick links
to graph and show latest data, like the main agent view.
2009-09-11 Miguel de Dios <miguel.dedios@artica.es>
* operation/events/events.php: change the order to include and write

View File

@ -0,0 +1,51 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// 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 for 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.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Pandora FMS - The Flexible Monitoring System - Console error</title>
<meta http-equiv="expires" content="0">
<meta http-equiv="content-type" content="text/html; charset=utf8">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="author" content="Sancho Lerena">
<meta name="copyright" content="This is GPL software. Created by Sancho Lerena and others">
<meta name="keywords" content="pandora, monitoring, system, GPL, software">
<meta name="robots" content="index, follow">
<link rel="icon" href="images/pandora.ico" type="image/ico">
<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">
</head>
<body>
<div id="container">
<div id="main">
<div align='center'>
<div id='login_f'>
<h1 id="log_f" class="error">Problem with Pandora FMS auth system</h1>
<div>
<img src="images/pandora_logo.png" border="0"></a>
</div>
<div class="msg">
Cannot override authorization variables from the config database. Remove them from your database by executing:<br><br><pre>DELETE FROM tconfig WHERE token = "auth";</pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,54 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// 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 for 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.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Pandora FMS - The Flexible Monitoring System - Console error</title>
<meta http-equiv="expires" content="0">
<meta http-equiv="content-type" content="text/html; charset=utf8">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="author" content="Sancho Lerena">
<meta name="copyright" content="This is GPL software. Created by Sancho Lerena and others">
<meta name="keywords" content="pandora, monitoring, system, GPL, software">
<meta name="robots" content="index, follow">
<link rel="icon" href="images/pandora.ico" type="image/ico">
<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">
</head>
<body>
<div id="container">
<div id="main">
<div align='center'>
<div id='login_f'>
<h1 id="log_f" class="error">Problem with Pandora FMS database</h1>
<div>
<img src="images/pandora_logo.png" border="0"></a>
</div>
<div class="msg">
Cannot connect to the database, please check your database setup in the <b>include/config.php</b> file or read the documentation on how to setup Pandora FMS.<i><br /><br />
Probably one or more of your user, database or hostname values are incorrect or
the database server is not running.</i><br /><br /><span class="error">
<b>MySQL ERROR:</b> '. mysql_error().'</span>
<br />&nbsp;
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,55 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// 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 for 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.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Pandora FMS - The Flexible Monitoring System - Console error</title>
<meta http-equiv="expires" content="0">
<meta http-equiv="content-type" content="text/html; charset=utf8">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="author" content="Sancho Lerena">
<meta name="copyright" content="This is GPL software. Created by Sancho Lerena and others">
<meta name="keywords" content="pandora, monitoring, system, GPL, software">
<meta name="robots" content="index, follow">
<link rel="icon" href="images/pandora.ico" type="image/ico">
<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">
</head>
<body>
<div id="container">
<div id="main">
<div align='center'>
<div id='login_f'>
<h1 id="log_f" class="error">Empty configuration table</h1>
<div>
<img src="images/pandora_logo.png" border="0"></a>
</div>
<div class="msg">
Cannot load configuration variables from database. Please check your database setup in the
<b>include/config.php</b> file or read the documentation on how to setup Pandora FMS.<i><br /><br />
Most likely your database schema has been created but there are is no data in it, you have a problem with the database access credentials or your schema is out of date.
<br><br>Pandora FMS Console cannot find <i>include/config.php</i> or this file has invalid
permissions and HTTP server cannot read it. Please read documentation to fix this problem.
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -30,6 +30,8 @@
<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">
</head>
<body>
<div id="container">
<div id="main">
<div align='center'>
<div id='login_f'>
<h1 id="log_f" class="error">Installer active</h1>
@ -44,5 +46,7 @@
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -30,6 +30,8 @@
<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">
</head>
<body>
<div id="container">
<div id="main">
<div align='center'>
<div id='login_f'>
<h1 id="log_f" class="error">No configuration file found</h1>
@ -41,9 +43,12 @@
permissions and HTTP server cannot read it. Please read documentation to fix this problem.
</div>
<div class="msg">
You can also try to run the <a href="install.php">installation wizard</a> to create one.
You may try to run the <b><a href="install.php">installation wizard</a></b> to create one.
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -29,6 +29,8 @@
<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">
</head>
<body>
<div id="container">
<div id="main">
<div align='center'>
<div id='login_f'>
<h1 id="log_f" class="error">Bad permission for include/config.php</h1>
@ -44,5 +46,7 @@
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -22,38 +22,16 @@
/**
* Pandora build version and version
*/
$build_version = 'PC090904';
$build_version = 'PC090914';
$pandora_version = 'v3.0-dev';
$config['start_time'] = microtime (true);
//Non-persistent connection. If you want persistent conn change it to mysql_pconnect()
$config['dbconnection'] = mysql_connect ($config["dbhost"], $config["dbuser"], $config["dbpass"]);
$config['dbconnection'] = mysql_pconnect ($config["dbhost"], $config["dbuser"], $config["dbpass"]);
if (! $config['dbconnection']) {
exit ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Pandora FMS Error</title>
<link rel="stylesheet" href="./include/styles/pandora.css" type="text/css">
</head>
<body>
<div style="align:center">
<div id="db_f">
<div>
<a href="index.php"><img src="images/pandora_logo.png" border="0" alt="logo" /></a>
</div>
<div id="db_ftxt">
<h1 id="log_f" class="error">Pandora FMS Console Error DB-001</h1>
Cannot connect to the database, please check your database setup in the
<b>include/config.php</b> file or read the documentation on how to setup Pandora FMS.<i><br /><br />
Probably one or more of your user, database or hostname values are incorrect or
the database server is not running.</i><br /><br /><span class="error">
<b>MySQL ERROR:</b> '. mysql_error().'</span>
<br />&nbsp;
</div>
</div>
</body>
</html>');
include ($config["homedir"]."/general/error_authconfig.php");
exit;
}
mysql_select_db ($config["dbname"]);

View File

@ -1010,5 +1010,35 @@ function index_array ($array, $index = 'id', $value = 'name') {
return $retval;
}
/**
* Return a graph type (string) given a module_type
*
* This function is useful to determine what kind of graph will be
* used, depending on the source data type, depending if it's
* numeric, boolean or a string type.
*
* @param int Id of module type
* @return string Graph type, as used in stat_win.php (Graphs launcher)
*/
function return_graphtype ($id_module_type){
if (($id_module_type == 3)
OR ($id_module_type == 10)
OR ($id_module_type == 17)
OR ($id_module_type == 23)){
return "string";
}
elseif (($id_module_type == 2)
OR ($id_module_type == 6)
OR ($id_module_type == 21)
OR ($id_module_type == 18)
OR ($id_module_type == 9)) {
return "boolean";
}
return "sparse";
}
?>

View File

@ -122,22 +122,8 @@ function process_config () {
$configs = get_db_all_rows_in_table ('tconfig');
if (empty ($configs)) {
exit ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Pandora FMS Error</title>
<link rel="stylesheet" href="./include/styles/pandora.css" type="text/css">
</head><body><div align="center">
<div id="db_f">
<div>
<a href="index.php"><img src="images/pandora_logo.png" border="0" alt="logo" /></a>
</div>
<div id="db_ftxt">
<h1 id="log_f" class="error">Pandora FMS Console Error DB-002</h1>
Cannot load configuration variables from database. Please check your database setup in the
<b>include/config.php</b> file or read the documentation on how to setup Pandora FMS.<i><br /><br />
Most likely your database schema has been created but there are is no data in it, you have a problem with the database access credentials or your schema is out of date.
</i><br />
</div>
</div></body></html>');
include ($config["homedir"]."/general/error_emptyconfig.php");
exit;
}
/* Compatibility fix */
@ -147,25 +133,8 @@ function process_config () {
$config['language'] = $c['value'];
break;
case "auth":
exit ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Pandora FMS Error</title>
<link rel="stylesheet" href="./include/styles/pandora.css" type="text/css">
</head>
<body>
<div align="center">
<div id="db_f">
<div>
<a href="index.php"><img src="images/pandora_logo.png" border="0" alt="logo" /></a>
</div>
<div id="db_ftxt">
<h1 id="log_f" class="error">Pandora FMS Console Error DB-003</h1>
Cannot override authorization variables from the config database. Remove them from your database by executing:
DELETE FROM tconfig WHERE token = "auth";
<br />
</div>
</div></body></html>');
include ($config["homedir"]."/general/error_authconfig.php");
exit;
default:
$config[$c['token']] = $c['value'];
}
@ -231,9 +200,14 @@ function process_config () {
update_config_value ('agentaccess', true);
}
if (!isset ($config["autoupdate"])){
update_config_value ('autoupdate', true);
}
// This is not set here. The first time, when no
// setup is done, update_manager extension manage it
// the first time make a conenction and disable itself
// Not Managed here !
// if (!isset ($config["autoupdate"])){
// update_config_value ('autoupdate', true);
// }
if (!isset ($config["auth"])) {
require_once ($config["homedir"]."/include/auth/mysql.php");

View File

@ -22,7 +22,7 @@ h1 {
font-size: 18px;
color: #ffffff;
}
lef
h2 {
font: bold 1em Arial, Sans-serif;
text-transform: uppercase;
@ -31,7 +31,7 @@ h2 {
div#install_container {
margin: 0 auto;
margin-top: 35px;
margin-top: 15px;
width: 600px;
}
div#logo_img {
@ -41,7 +41,7 @@ div#logo_img {
div#wizard {
text-align: left;
border: 1px solid #999;
margin-top: 3em;
margin-top: 1em;
padding: 20px;
padding-left: 20px;
width: 600px;

View File

@ -120,28 +120,14 @@ foreach ($modules as $module) {
$data[4] = print_status_image($status, $title, true);
if (($module["id_tipo_modulo"] == 3)
OR ($module["id_tipo_modulo"] == 10)
OR ($module["id_tipo_modulo"] == 17)
OR ($module["id_tipo_modulo"] == 23)){
$graph_type = "string";
$salida = substr(salida_limpia($module["datos"]),0,12);
}
elseif (($module["id_tipo_modulo"] == 2)
OR ($module["id_tipo_modulo"] == 6)
OR ($module["id_tipo_modulo"] == 21)
OR ($module["id_tipo_modulo"] == 18)
OR ($module["id_tipo_modulo"] == 9)) {
$graph_type = "boolean";
$salida = format_numeric($module["datos"]);
}
else {
$graph_type = "sparse";
if (is_numeric($module["datos"])){
$salida = format_numeric($module["datos"]);
} else {
$salida = "<span title='".$module['datos']."' style='white-space: nowrap;'>".substr(salida_limpia($module["datos"]),0,12)."</span>";
}
$data[5] .= $salida;
$graph_type = return_graphtype ($module["id_tipo_modulo"]);
if ($module['history_data'] == 1){
$nombre_tipo_modulo = get_moduletype_name ($module["id_tipo_modulo"]);
$handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"];

View File

@ -147,32 +147,16 @@ foreach ($modules as $module) {
echo "<td class='".$tdcolor."f9' colspan='2' title='".$module["datos"]."'>";
echo substr(salida_limpia($module["datos"]),0,12);
} else {
// String uses colspan2 and different graphtype
if (($module["id_tipo_modulo"] == 3)
OR ($module["id_tipo_modulo"] == 10)
OR ($module["id_tipo_modulo"] == 17)
OR ($module["id_tipo_modulo"] == 23)){
$graph_type = "string";
echo "<td class='".$tdcolor."f9' colspan=2 title='".salida_limpia($module["datos"])."'>";
}
elseif (($module["id_tipo_modulo"] == 2)
OR ($module["id_tipo_modulo"] == 6)
OR ($module["id_tipo_modulo"] == 21)
OR ($module["id_tipo_modulo"] == 18)
OR ($module["id_tipo_modulo"] == 9)) {
$graph_type = "boolean";
echo "<td class=".$tdcolor.">";
}
else {
$graph_type = "sparse";
echo "<td class=".$tdcolor.">";
}
// Kind of data
if (is_numeric($module["datos"])) {
$graph_type = return_graphtype ($module["id_tipo_modulo"]);
if (is_numeric($module["datos"])){
echo "<td class=".$tdcolor.">";
echo format_for_graph($module["datos"] );
} else
} else {
echo "<td class='".$tdcolor."f9' colspan=2 title='".salida_limpia($module["datos"])."'>";
echo substr(salida_limpia($module["datos"]),0,42);
}
$handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"];
@ -204,24 +188,19 @@ foreach ($modules as $module) {
echo "<td class=".$tdcolor."></td>";
}
echo "<td class='".$tdcolor."f9'>";
if ($module["timestamp"] == "0000-00-00 00:00:00"){
if ($module["utimestamp"] == 0){
echo __('Never');
} else {
$ahora = get_system_time ();
// Async modules
if (($module["id_tipo_modulo"] > 20) AND ($module["id_tipo_modulo"] < 100)){
echo human_time_comparation($module["timestamp"]);
$seconds = get_system_time () - $module["utimestamp"];
if ($module['id_tipo_modulo'] < 21 && $module["module_interval"] > 0 && $module["utimestamp"] > 0 && $seconds >= ($module["module_interval"] * 2)) {
echo '<span class="redb">';
} else {
if ( ($ahora - $module["utimestamp"]) > ($real_interval*2)) {
echo "<font color='red'>";
echo human_time_comparation($module["timestamp"]);
echo "</font>";
} else
echo human_time_comparation($module["timestamp"]);
echo '<span>';
}
}
print_timestamp ($module["utimestamp"], false);
echo '</span>';
echo "</td></tr>";
}
echo '</table>';

View File

@ -138,6 +138,8 @@ $sql = "SELECT tagente_modulo.id_agente_modulo,
tagente.intervalo AS agent_interval,
tagente.nombre AS agent_name,
tagente_modulo.nombre AS module_name,
tagente_modulo.id_agente_modulo,
tagente_modulo.history_data,
tagente_modulo.flag AS flag,
tagente.id_grupo AS id_group,
tagente.id_agente AS id_agent,
@ -166,13 +168,10 @@ $table->data = array ();
$table->size = array ();
$table->align = array ();
$table->head[0] = "";
$table->align[0] = "center";
$table->head[1] = __('Agent');
$table->head[2] = __('Type');
$table->align[2] = "center";
$table->align[2] = "left";
$table->head[3] = __('Module name');
@ -182,8 +181,14 @@ $table->align[4] = "center";
$table->head[5] = __('Status');
$table->align[5] = "center";
$table->head[6] = __('Timestamp');
$table->align[6] = "right";
$table->head[6] = __('Graph');
$table->align[6] = "left";
$table->head[7] = __('Data');
$table->align[7] = "left";
$table->head[8] = __('Timestamp');
$table->align[8] = "right";
$rowPair = true;
$iterator = 0;
@ -196,14 +201,6 @@ foreach ($result as $row) {
$iterator++;
$data = array ();
//TODO: This should be processed locally. Don't rely on other URL's to do our dirty work. Maybe a process_agentmodule_flag function
$data[0] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row["id_agent"].'&id_agente_modulo='.$row["id_agente_modulo"].'&flag=1&refr=60">';
if ($row["flag"] == 0) {
$data[0] .= '<img src="images/target.png" />';
} else {
$data[0] .= '<img src="images/refresh.png" />';
}
$data[0] .= '</a>';
$data[1] = '<strong><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row["id_agent"].'">';
$data[1] .= strtoupper (substr ($row["agent_name"], 0, 25));
@ -223,16 +220,37 @@ foreach ($result as $row) {
$data[5] = print_status_image(STATUS_MODULE_WARNING, $row["datos"], true);
}
$data[6] = "";
if ($row['history_data'] == 1){
$graph_type = return_graphtype ($row["module_type"]);
$nombre_tipo_modulo = get_moduletype_name ($row["module_type"]);
$handle = "stat".$nombre_tipo_modulo."_".$row["id_agente_modulo"];
$url = 'include/procesos.php?agente='.$row["id_agente_modulo"];
$win_handle=dechex(crc32($row["id_agente_modulo"].$row["module_name"]));
$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$row["id_agente_modulo"]."&label=".$row["module_name"]."&refresh=600','day_".$win_handle."')";
$data[6] = '<a href="javascript:'.$link.'"><img src="images/chart_curve.png" border=0></a>';
$data[6] .= "&nbsp;<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$row["id_agent"]."&tab=data_view&period=86400&id=".$row["id_agente_modulo"]."'><img border=0 src='images/binary.png'></a>";
}
if (is_numeric($row["datos"]))
$data[7] = format_numeric($row["datos"]);
else
$data[7] = "<span title='".$row['datos']."' style='white-space: nowrap;'>".substr(salida_limpia($row["datos"]),0,12)."</span>";
$seconds = get_system_time () - $row["utimestamp"];
if ($seconds >= ($row["module_interval"] * 2)) {
$option = array ("html_attr" => 'class="redb"');
} else {
$option = array ();
}
$data[6] = print_timestamp ($row["utimestamp"], true, $option);
$data[8] = print_timestamp ($row["utimestamp"], true, $option);
array_push ($table->data, $data);
}