2009-01-22 Sancho Lerena <slerena@artica.es>

* images/*: Added more icons and backgrouns for visual console.
	
	* map_builder.php: Added support for warning image. Shows in preview. Fixed
	grabbing image info if no file provided.
	 
	* functions_visualmap.php, functions_db.php: Added support for warning status
	in the maps. Also fixed status propagation from linked maps on agent object.
	
	* include/auth/mysql.php: Fixed typo when update password.
	
	* pandoradb_migrate_20_to_21.php: Added some missing lines for tusuario 
	table (comments).



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1393 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2009-01-22 19:34:11 +00:00
parent 30f8018f84
commit c4d38a3362
23 changed files with 133 additions and 44 deletions

View File

@ -1,3 +1,18 @@
2009-01-22 Sancho Lerena <slerena@artica.es>
* images/*: Added more icons and backgrouns for visual console.
* map_builder.php: Added support for warning image. Shows in preview. Fixed
grabbing image info if no file provided.
* functions_visualmap.php, functions_db.php: Added support for warning status
in the maps. Also fixed status propagation from linked maps on agent object.
* include/auth/mysql.php: Fixed typo when update password.
* pandoradb_migrate_20_to_21.php: Added some missing lines for tusuario
table (comments).
2009-01-22 Evi Vanoost <vanooste@rcbi.rochester.edu>
* include/auth/ldap.php: Finally fixed (hopefully) the last major bug

View File

@ -115,10 +115,11 @@ if ($update_layout) {
if ($get_background_info) {
$file = (string) get_parameter ('background');
$info = getimagesize ('images/console/background/'.$file);
$info['width'] = $info[0];
$info['height'] = $info[1];
if (file_exist('images/console/background/'.$file)){
$info = getimagesize ('images/console/background/'.$file);
$info['width'] = $info[0];
$info['height'] = $info[1];
}
if (defined ('AJAX')) {
echo json_encode ($info);
exit;
@ -340,6 +341,8 @@ if (! $edit_layout && ! $id_layout) {
continue;
if (strpos ($image_file, "_ok"))
continue;
if (strpos ($image_file, "_warning"))
continue;
$image_file = substr ($image_file, 0, strlen ($image_file) - 4);
$images_list[$image_file] = $image_file;
}
@ -577,6 +580,7 @@ $(document).ready (function () {
if (this.value != '') {
$("#image_preview").append ($('<img />').attr ('src', 'images/console/icons/' + this.value + '.png'));
$("#image_preview").append ($('<img />').attr ('src', 'images/console/icons/' + this.value + '_ok.png'));
$("#image_preview").append ($('<img />').attr ('src', 'images/console/icons/' + this.value + '_warning.png'));
$("#image_preview").append ($('<img />').attr ('src', 'images/console/icons/' + this.value + '_bad.png'));
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 513 B

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

View File

@ -216,7 +216,7 @@ function process_user_password ( $user, $password_old, $password_new ) {
return false;
}
return process_sql_update ("tusuario", array ("password" => md5 ($password_new)), array ("id_user" => $id_user));
return process_sql_update ("tusuario", array ("password" => md5 ($password_new)), array ("id_user" => $user));
}
function process_user_info ($id_user, $user_info) {
@ -256,4 +256,4 @@ function process_user_isadmin ($id_user, $is_admin) {
//Reference the global use authorization error to last auth error.
$config["auth_error"] = &$mysql_cache["auth_error"];
?>
?>

View File

@ -1609,20 +1609,31 @@ function format_array_to_update_sql ($values) {
function return_status_agent_module ($id_agentmodule = 0) {
$status = get_db_value ('estado', 'tagente_estado', 'id_agente_modulo', $id_agentmodule);
if ($status == 100) {
// We need to check if there are any alert on this item
$times_fired = get_db_value ('SUM(times_fired)', 'talert_template_modules',
'id_agent_module', $id_agentmodule);
if ($times_fired > 0) {
return 0;
}
// No alerts fired for this agent module
return 1;
} elseif ($status == 0) { // 0 is ok for estado field
return 1;
} else {
return 0;
$times_fired = get_db_value ('SUM(times_fired)', 'talert_template_modules', 'id_agent_module', $id_agentmodule);
if ($times_fired > 0) {
return 4; // Alert
}
return $status;
}
/**
* Get the worst status of all modules of a given agent.
*
* @param int Id agent to check.
*
* @return int Worst status of an agent for all of its modules
*/
function return_status_agent ($id_agent = 0) {
$status = get_db_sql ("SELECT MAX(estado)
FROM tagente_estado, tagente_modulo
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.id_agente = $id_agent");
// TODO: Check any alert for that agent who has recept alerts fired
return $status;
}
/**
@ -1639,25 +1650,34 @@ function return_status_agent_module ($id_agentmodule = 0) {
function return_status_layout ($id_layout = 0) {
$temp_status = 0;
$temp_total = 0;
$sql = sprintf ('SELECT id_agente_modulo, parent_item, id_layout_linked FROM `tlayout_data` WHERE `id_layout` = %d', $id_layout);
$sql = sprintf ('SELECT id_agente_modulo, parent_item, id_layout_linked, id_agent FROM `tlayout_data` WHERE `id_layout` = %d', $id_layout);
$result = get_db_all_rows_sql ($sql);
if ($result === false)
return 0;
foreach ($result as $rownum => $data) {
// Other Layout (Recursive!)
if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) {
$temp_status += return_status_layout ($data["id_layout_linked"]);
$temp_total++;
$temp_status = return_status_layout ($data["id_layout_linked"]);
if ($temp_status > $temp_total){
$temp_total = $temp_status;
}
// Module
} elseif ($data["id_agente_modulo"] != 0) {
$temp_status = return_status_agent_module ($data["id_agente_modulo"]);
if ($temp_status > $temp_total)
$temp_total = $temp_status;
// Agent
} else {
$temp_status += return_status_agent_module ($data["id_agente_modulo"]);
$temp_total++;
$temp_status = return_status_agent ($data["id_agent"]);
if ($temp_status > $temp_total)
$temp_total = $temp_status;
}
}
if ($temp_status == $temp_total) {
return 1;
}
return 0;
return $temp_total;
}
/**

View File

@ -2,7 +2,7 @@
// Pandora FMS - the Flexible Monitoring System
// ============================================
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
// Copyright (c) 2009 Artica Soluciones Tecnologicas, http://www.artica.es
// Please see http://pandora.sourceforge.net for full contribution list
// This program is free software; you can redistribute it and/or
@ -38,20 +38,25 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
// Linked to other layout ?? - Only if not module defined
if ($layout_data['id_layout_linked'] != 0) {
$status = return_status_layout ($layout_data['id_layout_linked']);
$status_parent = 3;
} else {
// Status for a simple module
if ($layout_data['id_agente_modulo'] != 0) {
$id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']);
$id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]);
// Item value
$status = return_status_agent_module ($layout_data['id_agente_modulo']);
if ($layout_data['no_link_color'] == 1)
$status_parent = -1;
$status_parent = 3;
else
$status_parent = return_status_agent_module ($id_agent_module_parent);
} else {
// Status for a whole agent
} elseif ($layout_data['id_agent'] != 0) {
$id_agent = $layout_data['id_agent'];
$agent_interval = get_agent_interval ($id_agent);
$sql = sprintf ('SELECT COUNT(*)
$sql = sprintf ('SELECT MAX(estado)
FROM tagente_estado, tagente_modulo
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0
@ -61,9 +66,12 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
OR (module_interval = 0
AND utimestamp >= UNIX_TIMESTAMP() - %d))',
$id_agent, $agent_interval * 2);
$status = get_db_sql ($sql);
$status_parent = $status;
} else {
$status = 3;
$status_parent = 3;
$id_agent = 0;
}
}
@ -72,34 +80,70 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
// Link image
//index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1
if ($status == 0) // Bad monitor
$z_index = 2;
elseif ($status == 2) // Alert
$z_index = 3;
elseif ($status == 2) // Warning
$z_index = 2;
elseif ($status == 4) // Alert
$z_index = 4;
else
$z_index = 1; // Print BAD over good
// Draw image
echo '<div style="z-index: '.$z_index.'; color: '.$layout_data['label_color'].'; position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
// Draw image
echo '<div style="z-index: '.$z_index.'; color: '.$layout_data['label_color'].'; position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
if (!isset($id_agent))
$id_agent = 0;
if ($show_links) {
if ($layout_data['id_layout_linked'] == "" || $layout_data['id_layout_linked'] == 0) {
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agent&tab=data'>";
} else {
// Link to an agent
if (($id_agent > 0) && ($layout_data['id_layout_linked'] == "" || $layout_data['id_layout_linked'] == 0)) {
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agent'>";
// Link to a map
} elseif ($layout_data['id_layout_linked']>0){
echo '<a href="index.php?sec=visualc&sec2=operation/visual_console/render_view&pure='.$config["pure"].'&id='.$layout_data['id_layout_linked'].'">';
// A void object
} else {
echo "<a href='#'>";
}
}
if ($status == 0) {
// Critical (BAD) or ALERT
if (($status == 1) OR ($status == 4)){
if ($layout_data['width'] != "" && $layout_data['width'] != 0)
echo '<img src="images/console/icons/'.$layout_data['image'].'_bad.png" width="'.$layout_data['width'].'" height="'.$layout_data['height'].'" title="'.$layout_data['label'].'">';
else
echo '<img src="images/console/icons/'.$layout_data['image'].'_bad.png"
title="'.$layout_data['label'].'">';
} else {
// Normal (OK)
} elseif ($status == 0){
if ($layout_data['width'] != "" && $layout_data['width'] != 0)
echo '<img src="images/console/icons/'.$layout_data['image'].'_ok.png" width="'.$layout_data['width'].'"
height="'.$layout_data['height'].'" title="'.$layout_data['label'].'">';
else
echo '<img src="images/console/icons/'.$layout_data['image'].'_ok.png"
title="'.$layout_data['label'].'">';
// Warning
} elseif ($status == 2){
if ($layout_data['width'] != "" && $layout_data['width'] != 0)
echo '<img src="images/console/icons/'.$layout_data['image'].'_warning.png" width="'.$layout_data['width'].'"
height="'.$layout_data['height'].'" title="'.$layout_data['label'].'">';
else
echo '<img src="images/console/icons/'.$layout_data['image'].'_warning.png"
title="'.$layout_data['label'].'">';
// Other (GREY)
} else {
if ($layout_data['width'] != "" && $layout_data['width'] != 0)
echo '<img src="images/console/icons/'.$layout_data['image'].'.png" width="'.$layout_data['width'].'"
height="'.$layout_data['height'].'" title="'.$layout_data['label'].'">';
else
echo '<img src="images/console/icons/'.$layout_data['image'].'.png"
title="'.$layout_data['label'].'">';
}
echo "</a>";
@ -108,6 +152,7 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
echo $layout_data['label'];
echo "</div>";
}
// SINGLE GRAPH (type = 1)
if ($layout_data['type'] == 1) { // single graph
@ -123,6 +168,8 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
echo '<img src="reporting/fgraph.php?tipo=sparse&id='.$layout_data['id_agente_modulo'].'&label='.$layout_data['label'].'&height='.$layout_data['height'].'&width='.$layout_data['width'].'&period='.$layout_data['period'].'" title="'.$layout_data['label'].'" border="0">';
echo "</a>";
echo "</div>";
// Line, not implemented in editor
} else if ($layout_data['type'] == 2) {
$line['id'] = $layout_data['id'];
$line['x'] = $layout_data['pos_x'];

View File

@ -171,9 +171,12 @@ DEFAULT '0', ADD `min_critical` DOUBLE( 18, 2 ) NOT NULL DEFAULT
`min_ff_event` INT( 4 ) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE `tusuario` CHANGE `nombre_real` `fullname` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `tusuario` CHANGE `comentarios` `comments` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `tusuario` CHANGE `id_usuario` `id_user` VARCHAR( 60 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0';
ALTER TABLE `tusuario` CHANGE `fecha_registro` `last_connect` BIGINT( 20 ) NOT NULL DEFAULT '0';
ALTER TABLE `tusuario` ADD UNIQUE (`id_user`);
ALTER TABLE `tusuario` ADD `registered` BIGINT( 20 ) NOT NULL DEFAULT '0' AFTER `last_connect` ;
ALTER TABLE `tusuario` ADD `firstname` VARCHAR( 255 ) NOT NULL AFTER `fullname` , ADD `lastname` VARCHAR( 255 ) NOT NULL AFTER `firstname` , ADD `middlename` VARCHAR( 255 ) NOT NULL AFTER `lastname`;
ALTER TABLE `tusuario` CHANGE `direccion` `email` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , CHANGE `telefono` `phone` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , CHANGE `nivel` `is_admin` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'
ALTER TABLE `tusuario` CHANGE `direccion` `email` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , CHANGE `telefono` `phone` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , CHANGE `nivel` `is_admin` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';