From d52a1c4791274d51f4c4806b9f6a874c8325d6c4 Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 14 Sep 2009 01:02:44 +0000 Subject: [PATCH] 2009-09-14 Sancho Lerena * 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 --- pandora_console/ChangeLog | 24 ++++++++ pandora_console/general/error_authconfig.php | 51 +++++++++++++++++ pandora_console/general/error_dbconfig.php | 54 ++++++++++++++++++ pandora_console/general/error_emptyconfig.php | 55 +++++++++++++++++++ pandora_console/general/error_install.php | 4 ++ pandora_console/general/error_noconfig.php | 7 ++- pandora_console/general/error_perms.php | 4 ++ pandora_console/include/config_process.php | 30 ++-------- pandora_console/include/functions.php | 30 ++++++++++ pandora_console/include/functions_config.php | 50 ++++------------- pandora_console/include/styles/install.css | 6 +- .../operation/agentes/estado_monitores.php | 22 ++------ .../agentes/estado_ultimopaquete.php | 49 +++++------------ .../operation/agentes/status_monitor.php | 50 +++++++++++------ 14 files changed, 299 insertions(+), 137 deletions(-) create mode 100644 pandora_console/general/error_authconfig.php create mode 100644 pandora_console/general/error_dbconfig.php create mode 100644 pandora_console/general/error_emptyconfig.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a1b0f609ae..0df4708913 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,27 @@ +2009-09-14 Sancho Lerena + + * 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 * operation/events/events.php: change the order to include and write diff --git a/pandora_console/general/error_authconfig.php b/pandora_console/general/error_authconfig.php new file mode 100644 index 0000000000..7c3accbc85 --- /dev/null +++ b/pandora_console/general/error_authconfig.php @@ -0,0 +1,51 @@ + + + + +Pandora FMS - The Flexible Monitoring System - Console error + + + + + + + + + + + + +
+
+
+
+

Problem with Pandora FMS auth system

+
+ +
+
+ Cannot override authorization variables from the config database. Remove them from your database by executing:

DELETE FROM tconfig WHERE token = "auth";
+
+ +
+
+
+
+ + + diff --git a/pandora_console/general/error_dbconfig.php b/pandora_console/general/error_dbconfig.php new file mode 100644 index 0000000000..6f8e751925 --- /dev/null +++ b/pandora_console/general/error_dbconfig.php @@ -0,0 +1,54 @@ + + + + +Pandora FMS - The Flexible Monitoring System - Console error + + + + + + + + + + + + +
+
+
+
+

Problem with Pandora FMS database

+
+ +
+
+ Cannot connect to the database, please check your database setup in the include/config.php file or read the documentation on how to setup Pandora FMS.

+ Probably one or more of your user, database or hostname values are incorrect or + the database server is not running.


+ MySQL ERROR: '. mysql_error().' +
  +
+
+
+
+
+ + + diff --git a/pandora_console/general/error_emptyconfig.php b/pandora_console/general/error_emptyconfig.php new file mode 100644 index 0000000000..38b818a390 --- /dev/null +++ b/pandora_console/general/error_emptyconfig.php @@ -0,0 +1,55 @@ + + + + +Pandora FMS - The Flexible Monitoring System - Console error + + + + + + + + + + + + +
+
+
+
+

Empty configuration table

+
+ +
+
+ Cannot load configuration variables from database. Please check your database setup in the + include/config.php file or read the documentation on how to setup Pandora FMS.

+ 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. +

Pandora FMS Console cannot find include/config.php or this file has invalid + permissions and HTTP server cannot read it. Please read documentation to fix this problem. +
+ +
+
+
+
+ + + diff --git a/pandora_console/general/error_install.php b/pandora_console/general/error_install.php index acb3ae7ea7..8598c779b6 100644 --- a/pandora_console/general/error_install.php +++ b/pandora_console/general/error_install.php @@ -30,6 +30,8 @@ +
+

Installer active

@@ -44,5 +46,7 @@
+
+ diff --git a/pandora_console/general/error_noconfig.php b/pandora_console/general/error_noconfig.php index 26859966fb..fa1ad657c3 100644 --- a/pandora_console/general/error_noconfig.php +++ b/pandora_console/general/error_noconfig.php @@ -30,6 +30,8 @@ +
+

No configuration file found

@@ -41,9 +43,12 @@ permissions and HTTP server cannot read it. Please read documentation to fix this problem.
- You can also try to run the installation wizard to create one. + You may try to run the installation wizard to create one.
+
+ + diff --git a/pandora_console/general/error_perms.php b/pandora_console/general/error_perms.php index 9b9f1d608c..2125b0c905 100644 --- a/pandora_console/general/error_perms.php +++ b/pandora_console/general/error_perms.php @@ -29,6 +29,8 @@ +
+

Bad permission for include/config.php

@@ -44,5 +46,7 @@
+
+ diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 1dd7692151..f3209b6a31 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -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 (' - - - Pandora FMS Error - - - -
-
-
- logo -
-
-

Pandora FMS Console Error DB-001

- Cannot connect to the database, please check your database setup in the - include/config.php file or read the documentation on how to setup Pandora FMS.

- Probably one or more of your user, database or hostname values are incorrect or - the database server is not running.


- MySQL ERROR: '. mysql_error().' -
  -
-
- - '); + include ($config["homedir"]."/general/error_authconfig.php"); + exit; } mysql_select_db ($config["dbname"]); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 8023a12694..da942fe4c9 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -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"; +} + ?> diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 3fed3086d5..1f191dd7d7 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -122,22 +122,8 @@ function process_config () { $configs = get_db_all_rows_in_table ('tconfig'); if (empty ($configs)) { - exit (' - Pandora FMS Error - -
-
-
- logo -
-
-

Pandora FMS Console Error DB-002

- Cannot load configuration variables from database. Please check your database setup in the - include/config.php file or read the documentation on how to setup Pandora FMS.

- 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. -

-
-
'); + 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 (' - - - Pandora FMS Error - - - -
-
-
- logo -
-
-

Pandora FMS Console Error DB-003

- Cannot override authorization variables from the config database. Remove them from your database by executing: - DELETE FROM tconfig WHERE token = "auth"; -
-
-
'); + 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"); diff --git a/pandora_console/include/styles/install.css b/pandora_console/include/styles/install.css index be5cd8cb7c..d1b79128a0 100644 --- a/pandora_console/include/styles/install.css +++ b/pandora_console/include/styles/install.css @@ -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; diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index f02a68985c..9a0e26e336 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -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 = "".substr(salida_limpia($module["datos"]),0,12).""; } $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"]; diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index 46a0edc784..afe2fa4c2f 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -147,32 +147,16 @@ foreach ($modules as $module) { echo ""; 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 ""; - } - 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 ""; - } - else { - $graph_type = "sparse"; - echo ""; - } - // Kind of data - if (is_numeric($module["datos"])) { + + $graph_type = return_graphtype ($module["id_tipo_modulo"]); + if (is_numeric($module["datos"])){ + echo ""; echo format_for_graph($module["datos"] ); - } else + } else { + echo ""; 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 ""; } - echo ""; - 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 ''; } else { - if ( ($ahora - $module["utimestamp"]) > ($real_interval*2)) { - echo ""; - echo human_time_comparation($module["timestamp"]); - echo ""; - } else - echo human_time_comparation($module["timestamp"]); + echo ''; } } + print_timestamp ($module["utimestamp"], false); + echo ''; echo ""; } echo ''; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 9f0656358f..a1851ab0fe 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -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] = ''; - if ($row["flag"] == 0) { - $data[0] .= ''; - } else { - $data[0] .= ''; - } - $data[0] .= ''; $data[1] = ''; $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] = ''; + $data[6] .= " "; + } + + if (is_numeric($row["datos"])) + $data[7] = format_numeric($row["datos"]); + else + $data[7] = "".substr(salida_limpia($row["datos"]),0,12).""; + $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); }