2009-01-20 Esteban Sanchez <estebans@artica.es>

* ChangeLog: Fixed tabs. Removed some conflict markups and a bit of
	style here and there.

	* index.php, godmode/setup/setup.php, include/styles/menu.css,
	operation/agentes/estado_agente.php,
	operation/agentes/estado_monitores.php,
	operation/agentes/estado_ultimopaquete.php,
	include/functions.php: Tab and spaces style correction.

	* godmode/reporting/map_builder.php: Use generic database functions
	for the insert. Now a node can represent a whole agent, changing to
	bad if any module has failed.

	* include/config_process.php: Use generic databse functions for
	inserts. Fixed an error when inserting loginhash_pwd token. Make the
	token a bit more complicated by multiplying two numbers.

	* include/functions_visual_map.php: Add support to agent nodes that
	will turn to bad icon when any module fails.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1363 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2009-01-20 16:43:49 +00:00
parent 41a7a38ca2
commit afe99a4587
11 changed files with 156 additions and 116 deletions

View File

@ -1,3 +1,25 @@
2009-01-20 Esteban Sanchez <estebans@artica.es>
* ChangeLog: Fixed tabs. Removed some conflict markups and a bit of
style here and there.
* index.php, godmode/setup/setup.php, include/styles/menu.css,
operation/agentes/estado_agente.php,
operation/agentes/estado_monitores.php,
operation/agentes/estado_ultimopaquete.php,
include/functions.php: Tab and spaces style correction.
* godmode/reporting/map_builder.php: Use generic database functions
for the insert. Now a node can represent a whole agent, changing to
bad if any module has failed.
* include/config_process.php: Use generic databse functions for
inserts. Fixed an error when inserting loginhash_pwd token. Make the
token a bit more complicated by multiplying two numbers.
* include/functions_visual_map.php: Add support to agent nodes that
will turn to bad icon when any module fails.
2009-01-20 Esteban Sanchez <estebans@artica.es> 2009-01-20 Esteban Sanchez <estebans@artica.es>
* include/javascript/jquery.js: Downgraded to 1.2. It was causing some * include/javascript/jquery.js: Downgraded to 1.2. It was causing some

View File

@ -147,18 +147,19 @@ if ($create_layout_data) {
$layout_data_width = (int) get_parameter ("width"); $layout_data_width = (int) get_parameter ("width");
$layout_data_height = (int) get_parameter ("height"); $layout_data_height = (int) get_parameter ("height");
$sql = sprintf ('INSERT INTO tlayout_data (id_layout, label, id_layout_linked, $values = array ('id_layout' => $id_layout,
label_color, image, type, id_agente_modulo, parent_item, period, no_link_color, 'label' => $layout_data_label,
width, height) 'id_layout_linked' => $layout_data_map_linked,
VALUES (%d, "%s", %d, "%s", "%s", %d, %d, %d, %d, 1, %d, %d)', 'label_color' => $layout_data_label_color,
$id_layout, $layout_data_label, 'image' => $layout_data_image,
$layout_data_map_linked, 'type' => $layout_data_type,
$layout_data_label_color, 'id_agente_modulo' => $layout_data_id_agent_module,
$layout_data_image, $layout_data_type, 'parent_item' => $layout_data_parent_item,
$layout_data_id_agent_module, 'period' => $layout_data_period * 3600,
$layout_data_parent_item, $layout_data_period * 3600, 'no_link_color' => 1,
$layout_data_width, $layout_data_height); 'width' => $layout_data_width,
$result = process_sql ($sql, 'insert_id'); 'height' => $layout_data_height);
$result = process_sql_insert ('tlayout_data', $values);
if ($result !== false) { if ($result !== false) {
echo '<h3 class="suc">'.__('Created successfully').'</h3>'; echo '<h3 class="suc">'.__('Created successfully').'</h3>';
@ -446,7 +447,7 @@ function agent_changed (event, id_agent, selected) {
}, },
function (data) { function (data) {
$('#form_layout_data_editor #module').empty (); $('#form_layout_data_editor #module').empty ();
$('#form_layout_data_editor #module').append ($('<option></option>').html ("--").attr ("value", 0)); $('#form_layout_data_editor #module').append ($('<option></option>').html ("<?php echo __('Any')?>").attr ("value", 0));
jQuery.each (data, function (i, val) { jQuery.each (data, function (i, val) {
s = html_entity_decode (val['nombre']); s = html_entity_decode (val['nombre']);
$('#form_layout_data_editor #module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo'])); $('#form_layout_data_editor #module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo']));

View File

@ -17,20 +17,20 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//Pandora Version //Pandora Version
$build_version = "PC090115"; $build_version = 'PC090120';
$pandora_version = "v2.1-dev"; $pandora_version = 'v2.1-dev';
// This is directory where placed "/attachment" directory, to upload files stores. // This is directory where placed "/attachment" directory, to upload files stores.
// This MUST be writtable by http server user, and should be in pandora root. // This MUST be writtable by http server user, and should be in pandora root.
// By default, Pandora adds /attachment to this, so by default is the pandora console home dir // By default, Pandora adds /attachment to this, so by default is the pandora console home dir
$config["attachment_store"] = $config["homedir"]."/attachment"; $config['attachment_store'] = $config['homedir'].'/attachment';
// Default font used for graphics (a Free TrueType font included with Pandora FMS) // Default font used for graphics (a Free TrueType font included with Pandora FMS)
$config["fontpath"] = $config["homedir"]."/reporting/FreeSans.ttf"; $config['fontpath'] = $config['homedir'].'/reporting/FreeSans.ttf';
// Style (pandora by default) // Style (pandora by default)
$config["style"] = "pandora"; $config['style'] = 'pandora';
// Read remaining config tokens from DB // Read remaining config tokens from DB
if (! mysql_connect ($config["dbhost"], $config["dbuser"], $config["dbpass"])) { if (! mysql_connect ($config["dbhost"], $config["dbuser"], $config["dbpass"])) {
@ -58,7 +58,7 @@ mysql_select_db ($config["dbname"]);
require_once ('functions_db.php'); require_once ('functions_db.php');
$configs = get_db_all_rows_in_table ('tconfig'); $configs = get_db_all_rows_in_table ('tconfig');
if (sizeof ($configs) == 0) { if (empty ($configs)) {
exit ('<html><head><title>Pandora FMS Error</title> exit ('<html><head><title>Pandora FMS Error</title>
<link rel="stylesheet" href="./include/styles/pandora.css" type="text/css"> <link rel="stylesheet" href="./include/styles/pandora.css" type="text/css">
</head><body><div align="center"> </head><body><div align="center">
@ -76,18 +76,19 @@ if (sizeof ($configs) == 0) {
</div></body></html>'); </div></body></html>');
} }
/* Compatibility fix */
foreach ($configs as $c) { foreach ($configs as $c) {
switch ($c["token"]) { switch ($c["token"]) {
case "language_code": case "language_code":
$config["language"] = $c["value"]; $config['language'] = $c['value'];
break; break;
default: default:
$config[$c["token"]] = $c["value"]; $config[$c['token']] = $c['value'];
} }
} }
if ($config["language"] == 'ast_es') { if ($config['language'] == 'ast_es') {
$help_code = 'ast'; $help_code = 'ast';
} else { } else {
$help_code = substr ($config["language"], 0, 2); $help_code = substr ($config["language"], 0, 2);
@ -112,47 +113,54 @@ if (file_exists ('./include/languages/'.$config["language"].'.mo')) {
$l10n->load_tables(); $l10n->load_tables();
} }
if (!isset ($config['date_format'])) {
$config['date_format'] = 'F j, Y, g:i a';
process_sql ("INSERT INTO tconfig (token,value) VALUES ('date_format', '".$config['date_format']."')");
}
if (!isset($config["event_view_hr"])){
$config["event_view_hr"] = 8;
process_sql ("INSERT INTO tconfig (token,value) VALUES ('event_view_hr', ".$config["event_view_hr"].")");
}
if (!isset($config["loginhash_pwd"])){
$config["loginhash_pwd"] = rand(0,1000)."pandorahash";
process_sql ("INSERT INTO tconfig (token,value) VALUES ('loginhash_pwd', ".$config["loginhash_pwd"].")");
}
if (isset ($config['homeurl']) && $config['homeurl'][0] != '/') { if (isset ($config['homeurl']) && $config['homeurl'][0] != '/') {
$config['homeurl'] = '/'.$config['homeurl']; $config['homeurl'] = '/'.$config['homeurl'];
} }
if (!isset ($config['date_format'])) {
$config['date_format'] = 'F j, Y, g:i a';
process_sql_insert ('tconfig', array ('token' => 'date_format',
'value' => $config['date_format']));
}
if (! isset ($config['event_view_hr'])) {
$config['event_view_hr'] = 8;
process_sql_insert ('tconfig', array ('token' => 'event_view_hr',
'value' => $config['event_view_hr']));
}
if (! isset ($config['loginhash_pwd'])) {
$config['loginhash_pwd'] = rand (0, 1000) * rand (0, 1000)."pandorahash";
process_sql_insert ('tconfig', array ('token' => 'loginhash_pwd',
'value' => $config["loginhash_pwd"]));
}
// If first time, make the trap2agent disable in DB
if (!isset($config["trap2agent"])){ if (!isset($config["trap2agent"])){
$config["trap2agent"] = 0; $config["trap2agent"] = 0;
process_sql ("INSERT INTO tconfig (token,value) VALUES ('trap2agent', 0)"); process_sql_insert ('tconfig', array ('token' => 'trap2agent',
'value' => $config['trap2agent']));
} }
if (!isset ($config["sla_period"]) || empty ($config["sla_period"])) { if (!isset ($config["sla_period"]) || empty ($config["sla_period"])) {
// Default period (in secs) for auto SLA calculation (for monitors) // Default period (in secs) for auto SLA calculation (for monitors)
$config["sla_period"] = 604800; $config["sla_period"] = 604800;
process_sql ("INSERT INTO tconfig (token,value) VALUES ('sla_period',604800)"); process_sql_insert ('tconfig', array ('token' => 'sla_period',
'value' => $config['sla_period']));
} }
if (!isset ($config["prominent_time"])) { if (!isset ($config["prominent_time"])) {
// Prominent time tells us what to show prominently when a timestamp is displayed. The comparation (... days ago) or the timestamp (full date) // Prominent time tells us what to show prominently when a timestamp is
// displayed. The comparation (... days ago) or the timestamp (full date)
$config["prominent_time"] = "comparation"; $config["prominent_time"] = "comparation";
process_sql ("INSERT INTO tconfig (token,value) VALUES ('prominent_time','comparation')"); process_sql_insert ('tconfig', array ('token' => 'prominent_time',
'value' => $config['prominent_time']));
} }
if (!isset ($config["timesource"])) { if (!isset ($config["timesource"])) {
// Prominent time tells us what to show prominently when a timestamp is displayed. The comparation (... days ago) or the timestamp (full date) // Prominent time tells us what to show prominently when a timestamp is
// displayed. The comparation (... days ago) or the timestamp (full date)
$config["timesource"] = "system"; $config["timesource"] = "system";
process_sql ("INSERT INTO tconfig (token,value) VALUES ('timesource','system')"); process_sql_insert ('tconfig', array ('token' => 'timesource',
'value' => $config['timesource']));
} }
?> ?>

View File

@ -423,11 +423,11 @@ function format_numeric ($number, $decimals = 1) {
* @return string A string with the number and the multiplier * @return string A string with the number and the multiplier
*/ */
function format_for_graph ($number , $decimals = 1, $dec_point = ".", $thousands_sep = ",") { function format_for_graph ($number , $decimals = 1, $dec_point = ".", $thousands_sep = ",") {
$shorts = array("","K","M","G","T","P"); $shorts = array ("","K","M","G","T","P");
$pos = 0; $pos = 0;
while ($number>=1000) { //as long as the number can be divided by 1000 while ($number >= 1000) { //as long as the number can be divided by 1000
$pos++; //Position in array starting with 0 $pos++; //Position in array starting with 0
$number = $number/1000; $number = $number / 1000;
} }
return format_numeric ($number, $decimals). $shorts[$pos]; //This will actually do the rounding and the decimals return format_numeric ($number, $decimals). $shorts[$pos]; //This will actually do the rounding and the decimals
@ -990,8 +990,8 @@ if (!function_exists ("mb_strtoupper")) {
*/ */
function unsafe_string ($string) { function unsafe_string ($string) {
if (get_magic_quotes_gpc () == 1) if (get_magic_quotes_gpc ())
$string = stripslashes ($string); return stripslashes ($string);
return $string; return $string;
} }
@ -1003,7 +1003,7 @@ function unsafe_string ($string) {
function safe_sql_string ($string) { function safe_sql_string ($string) {
if (get_magic_quotes_gpc () == 0) if (get_magic_quotes_gpc () == 0)
$string = mysql_escape_string ($string);
return $string; return $string;
return mysql_escape_string ($string);
} }
?> ?>

View File

@ -34,13 +34,13 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
$lines = array (); $lines = array ();
if ($layout_datas !== false) { if ($layout_datas !== false) {
foreach ($layout_datas as $layout_data) { foreach ($layout_datas as $layout_data) {
// Linked to other layout ?? - Only if not module defined // Linked to other layout ?? - Only if not module defined
if (($layout_data['id_layout_linked'] != 0) && ($layout_data['id_agente_modulo'] == 0)) { if ($layout_data['id_layout_linked'] != 0) {
$status = return_status_layout ($layout_data['id_layout_linked']); $status = return_status_layout ($layout_data['id_layout_linked']);
} else { } else {
$id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']); $id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']);
if ($layout_data['id_agente_modulo'] != 0) {
$id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]); $id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]);
// Item value // Item value
$status = return_status_agent_module ($layout_data['id_agente_modulo']); $status = return_status_agent_module ($layout_data['id_agente_modulo']);
@ -48,11 +48,23 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
$status_parent = -1; $status_parent = -1;
else else
$status_parent = return_status_agent_module ($id_agent_module_parent); $status_parent = return_status_agent_module ($id_agent_module_parent);
} else {
$interval = get_agent_interval ($id_agent);
$sql = sprintf ('SELECT COUNT(*)
FROM tagente_estado, tagente_modulo
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_agente = %d
AND (utimestamp >= UNIX_TIMESTAMP() - module_interval * 2
OR (module_interval = 0
AND utimestamp >= UNIX_TIMESTAMP() - %d))',
$id_agent, $interval * 2);
$status = get_db_sql ($sql);
}
} }
// STATIC IMAGE (type = 0) // STATIC IMAGE (type = 0)
if ($layout_data['type'] == 0) { if ($layout_data['type'] == 0) {
// Link image // Link image
//index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 //index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1
if ($status == 0) // Bad monitor if ($status == 0) // Bad monitor
@ -88,7 +100,7 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
echo "</a>"; echo "</a>";
// Draw label // Draw label
echo "<br>"; echo "<br />";
echo $layout_data['label']; echo $layout_data['label'];
echo "</div>"; echo "</div>";
} }

View File

@ -218,13 +218,13 @@ if ($agents !== false) {
$agent_down = 1; $agent_down = 1;
if ($async == 0) if ($async == 0)
$monitor_down++; $monitor_down++;
} else{ } else {
if ($module["estado"] == 2) if ($module["estado"] == 2)
$monitor_warning ++; $monitor_warning++;
elseif ($module["estado"]== 1) elseif ($module["estado"]== 1)
$monitor_critical ++; $monitor_critical++;
else else
$monitor_normal ++; $monitor_normal++;
} }
} }
// Color change for each line (1.2 beta2) // Color change for each line (1.2 beta2)
@ -248,7 +248,7 @@ if ($agents !== false) {
echo $nombre_agente; echo $nombre_agente;
echo "</strong></a></td>"; echo "</strong></a></td>";
// Show SO icon :) // Show SO icon
echo "<td class='$tdcolor' align='center'>"; echo "<td class='$tdcolor' align='center'>";
print_os_icon ($id_os, false); print_os_icon ($id_os, false);
echo "</td>"; echo "</td>";
@ -285,8 +285,7 @@ if ($agents !== false) {
if ($numero_modulos > 0){ if ($numero_modulos > 0){
if ($agent_down > 0) { if ($agent_down > 0) {
echo '<img src="images/pixel_fucsia.png" width="40" height="18" title="'.__('Agent down').'" />'; echo '<img src="images/pixel_fucsia.png" width="40" height="18" title="'.__('Agent down').'" />';
} } elseif ($monitor_critical > 0){
elseif ($monitor_critical > 0){
echo '<img src="images/pixel_red.png" width="40" height="18" title="'.__('At least one module in CRITICAL status').'" />'; echo '<img src="images/pixel_red.png" width="40" height="18" title="'.__('At least one module in CRITICAL status').'" />';
} elseif ($monitor_warning > 0) { } elseif ($monitor_warning > 0) {
echo '<img src="images/pixel_yellow.png" width="40" height="18" title="'.__('At least one module in WARNING status').'" />'; echo '<img src="images/pixel_yellow.png" width="40" height="18" title="'.__('At least one module in WARNING status').'" />';

View File

@ -86,8 +86,6 @@ foreach ($modules as $module) {
$data[4] .= substr(salida_limpia($module["datos"]),0,42) . '">'; $data[4] .= substr(salida_limpia($module["datos"]),0,42) . '">';
} }
if ($module["module_interval"] > 0) { if ($module["module_interval"] > 0) {
$data[5] = $module["module_interval"]; $data[5] = $module["module_interval"];
} else { } else {