2014-03-19 Alejandro Gallardo <alejandro.gallardo@artica.es>

* pandoradb_data.sql,
	  pandoradb.data.oracle.sql,
	  pandoradb.data.postgreSQL.sql: Deleted an old link
	and updated the link to the Pandora FMS documentation.

	* pandoradb.sql,
	  pandoradb.postgreSQL.sql,
	  pandoradb.oracle.sql,
	  extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql,
	  extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql,
	  extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql:
	Added the column "l2_network" to the table "tnetwork_map".

	* godmode/agentes/module_manager_editor_common.php:
	Added a help tip to a column of relations.

	* include/functions_modules.php: Improved the function
	"modules_relation_exists".

	* operation/agentes/networkmap.topology.php,
	  include/functions_networkmap.php,
	  operation/agentes/networkmap.php: Added a new option
	to show the relations between the agents interfaces.

	* operation/agentes/estado_monitores.php: Added a tooltip
	to show the relations of a monitor in the monitor list.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9618 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
alexhigh 2014-03-19 16:43:08 +00:00
parent 4494516a4e
commit f36f12be56
16 changed files with 219 additions and 52 deletions

View File

@ -1,3 +1,32 @@
2014-03-19 Alejandro Gallardo <alejandro.gallardo@artica.es>
* pandoradb_data.sql,
pandoradb.data.oracle.sql,
pandoradb.data.postgreSQL.sql: Deleted an old link
and updated the link to the Pandora FMS documentation.
* pandoradb.sql,
pandoradb.postgreSQL.sql,
pandoradb.oracle.sql,
extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql,
extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql,
extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql:
Added the column "l2_network" to the table "tnetwork_map".
* godmode/agentes/module_manager_editor_common.php:
Added a help tip to a column of relations.
* include/functions_modules.php: Improved the function
"modules_relation_exists".
* operation/agentes/networkmap.topology.php,
include/functions_networkmap.php,
operation/agentes/networkmap.php: Added a new option
to show the relations between the agents interfaces.
* operation/agentes/estado_monitores.php: Added a tooltip
to show the relations of a monitor in the monitor list.
2014-03-19 Vanessa Gil <vanessa.gil@artica.es>
* pandoradb.oracle.sql

View File

@ -63,6 +63,7 @@ CREATE TABLE IF NOT EXISTS `tmodule_relationship` (
-- ---------------------------------------------------------------------
ALTER TABLE `talert_snmp` ADD COLUMN `id_group` int(10) unsigned NOT NULL default '0';
/* 2014/03/19 */
-- ---------------------------------------------------------------------
-- Table `talert_snmp`
-- ---------------------------------------------------------------------
@ -76,3 +77,5 @@ ALTER TABLE `talert_snmp` ADD COLUMN `_snmp_f17_` text;
ALTER TABLE `talert_snmp` ADD COLUMN `_snmp_f18_` text;
ALTER TABLE `talert_snmp` ADD COLUMN `_snmp_f19_` text;
ALTER TABLE `talert_snmp` ADD COLUMN `_snmp_f20_` text;
ALTER TABLE `tnetwork_map` ADD COLUMN `l2_network` tinyint(1) unsigned NOT NULL default '0';

View File

@ -53,6 +53,7 @@ CREATE OR REPLACE TRIGGER tmodule_relationship_inc BEFORE INSERT ON tmodule_rela
-- ---------------------------------------------------------------------
ALTER TABLE talert_snmp ADD (id_group NUMBER(10, 0) default 0 NOT NULL);
/* 2014/03/19 */
-- ---------------------------------------------------------------------
-- Table `talert_snmp`
-- ---------------------------------------------------------------------
@ -66,3 +67,5 @@ ALTER TABLE talert_snmp ADD (_snmp_f17_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f18_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f19_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f20_ CLOB default '');
ALTER TABLE tnetwork_map ADD (l2_network NUMBER(1, 0) default 0 NOT NULL);

View File

@ -50,6 +50,7 @@ CREATE TABLE "tmodule_relationship" (
-- ---------------------------------------------------------------------
ALTER TABLE "talert_snmp" ADD COLUMN "id_group" INTEGER NOT NULL default 0;
/* 2014/03/19 */
-- ---------------------------------------------------------------------
-- Table "talert_snmp"
-- ---------------------------------------------------------------------
@ -63,3 +64,5 @@ ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f17_" text DEFAULT '';
ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f18_" text DEFAULT '';
ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f19_" text DEFAULT '';
ALTER TABLE "talert_snmp" ADD COLUMN "_snmp_f20_" text DEFAULT '';
ALTER TABLE "tnetwork_map" ADD COLUMN "l2_network" SMALLINT NOT NULL default 0;

View File

@ -563,7 +563,7 @@ $table_relations->style[3] = 'width: 10%; text-align: center;';
$table_relations->head[0] = __('Agent');
$table_relations->head[1] = __('Module');
$table_relations->head[2] = __('Changes');
$table_relations->head[2] = __('Changes'). ui_print_help_tip(__("Activate this to prevent the relation from being updated or deleted"), true);
$table_relations->head[3] = __('Delete');
// Create an invisible row to use their html to add new rows

View File

@ -1838,16 +1838,38 @@ function modules_get_relations ($params = array()) {
* Check if a relation already exists.
*
* @param int First module id.
* @param int Second module id.
* @param mixed (Optional) int The second module id. array The module ids filter.
*
* @return bool True if the relation exists, false otherwise.
*/
function modules_relation_exists ($id_module_a, $id_module_b) {
$sql = sprintf("SELECT id
FROM tmodule_relationship
WHERE (module_a = %d AND module_b = %d)
OR (module_b = %d AND module_a = %d)",
$id_module_a, $id_module_b, $id_module_a, $id_module_b);
function modules_relation_exists ($id_module, $id_module_other = false) {
if ($id_module_other === false) {
$sql = sprintf("SELECT id
FROM tmodule_relationship
WHERE module_a = %d
OR module_b = %d",
$id_module, $id_module);
} elseif (is_array($id_module_other)) {
$ids_other = 0;
if (!empty($id_module_other)) {
$ids_other = implode(",", $id_module_other);
}
$sql = sprintf("SELECT id
FROM tmodule_relationship
WHERE (module_a = %d AND module_b IN (%s))
OR (module_b = %d AND module_a IN (%s))",
$id_module, $ids_other, $id_module, $ids_other);
} else {
$sql = sprintf("SELECT id
FROM tmodule_relationship
WHERE (module_a = %d AND module_b = %d)
OR (module_b = %d AND module_a = %d)",
$id_module, $id_module_other, $id_module, $id_module_other);
}
return (bool) db_get_row_sql($sql);
}

View File

@ -233,7 +233,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0,
$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
$relative = false, $text_filter = '') {
$relative = false, $text_filter = '', $l2_network = false) {
global $config;
@ -275,7 +275,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
if ($agents === false)
//return false;
$agents = array();
// Open Graph
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $font_size);
@ -290,7 +290,9 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$node_ref[$agent['id_agente']] = $node_count;
$node_count++;
}
$modules_node_ref = array();
$node_count = 1;
foreach ($agents as $agent) {
@ -309,30 +311,52 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
// Add node
$nodes[$node_count] = $agent;
if ($show_snmp_modules) {
// Get agent modules data of snmp_proc type
$modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0, 'id_tipo_modulo' => 18), true, false);
if ($l2_network || $show_snmp_modules) {
$filter = array();
$filter['disabled'] = 0;
$filter['id_tipo_modulo'] = 18; // Filter by remote_snmp_proc type
// Get agent modules data
$modules = agents_get_modules ($agent['id_agente'], '*', $filter, true, false);
if ($modules === false)
$modules = array();
// Parse modules
foreach ($modules as $key => $module) {
$node_count ++;
$agent_module = modules_get_agentmodule($key);
$alerts_module = db_get_sql('SELECT count(*) AS num
FROM talert_template_modules
WHERE id_agent_module = ' . $key);
// Try to get the interface name
if (preg_match ("/_(\w+)/" , (string)$module['nombre'], $matches)) {
if ($matches[1]) {
$module['nombre'] = $matches[1];
}
}
// Save node parent information to define edges later
$parents[$node_count] = $agent_module['parent'] = $agent['id_node'];
$parents[$node_count] = $module['parent'] = $agent['id_node'];
$agent_module['id_node'] = $node_count;
$agent_module['type'] = 'module';
$modules_node_ref[$module['id_agente_modulo']] = $module['id_node'] = $node_count;
$module['type'] = 'module';
// Add node
$nodes[$node_count] = $agent_module;
$nodes[$node_count] = $module;
}
}
$node_count++;
}
// Drop the modules without a partner if l2_network is true
// and the snmp interfaces token is false
if ($l2_network && ! $show_snmp_modules) {
foreach ($modules_node_ref as $id_module => $node_count) {
if (! modules_relation_exists($id_module, array_keys($modules_node_ref))) {
unset($nodes[$node_count]);
unset($parents[$node_count]);
}
}
}
// Create void statistics array
$stats = array();
@ -348,11 +372,11 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
switch ($node['type']) {
case 'agent':
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names, $relative)."\n\t\t";
$graph .= networkmap_create_agent_node ($node, $simple, $font_size, $cut_names, $relative)."\n\t\t";
$stats['agents'][] = $node['id_agente'];
break;
case 'module':
$graph .= networkmap_create_module_node ($node , $simple, $font_size)."\n\t\t";
$graph .= networkmap_create_module_node ($node, $simple, $font_size)."\n\t\t";
$stats['modules'][] = $node['id_agente_modulo'];
break;
}
@ -362,7 +386,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
foreach ($parents as $node => $parent_id) {
// Verify that the parent is in the graph
if (isset ($nodes[$parent_id])) {
$graph .= networkmap_create_edge ($parent_id, $node , $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
$graph .= networkmap_create_edge ($parent_id, $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
}
else {
$orphans[$node] = 1;
@ -378,6 +402,22 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
foreach (array_keys($orphans) as $node) {
$graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
}
// Define edges for the module interfaces relations
if ($l2_network) {
// Get the remote_snmp_proc relations
$relations = modules_get_relations(array('modules_type' => 'remote_snmp_proc'));
if ($relations === false)
$relations = array();
foreach ($relations as $key => $relation) {
$module_a = $relation['module_a'];
$module_b = $relation['module_b'];
if (isset($modules_node_ref[$module_a]) && isset($modules_node_ref[$module_b])) {
$graph .= networkmap_create_edge ($modules_node_ref[$module_a], $modules_node_ref[$module_b], $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
}
}
}
// Close graph
$graph .= networkmap_close_graph ();

View File

@ -22,27 +22,71 @@ if (is_ajax ()) {
if ($get_tag_tooltip) {
$id_agente_modulo = (int) get_parameter ('id_agente_modulo');
if ($id_agente_modulo === false)
if ($id_agente_modulo == false)
return;
$tags = tags_get_module_tags($id_agente_modulo);
if ($tags === false)
$tags = array();
echo '<h3> Tag\'s information </h3>';
echo '<h3>' . __("Tag's information") . '</h3>';
foreach ($tags as $tag) {
echo tags_get_name($tag).'<br>';
}
return;
}
$get_relations_tooltip = (bool) get_parameter ('get_relations_tooltip', 0);
if ($get_relations_tooltip) {
$id_agente_modulo = (int) get_parameter ('id_agente_modulo');
if ($id_agente_modulo == false)
return;
$id_agente = modules_get_agentmodule_agent($id_agente_modulo);
$params = array(
'id_agent' => $id_agente,
'id_module' => $id_agente_modulo
);
$relations = modules_get_relations($params);
if (empty($relations))
return;
$table_relations = new stdClass();
$table_relations->id = 'module_' . $id_agente_modulo . '_relations';
$table_relations->width = '98%';
$table_relations->class = 'databox';
$table_relations->style = array();
$table_relations->style[0] = 'font-weight: bold;';
$table_relations->style[2] = 'font-weight: bold;';
$table_relations->head = array();
$table_relations->head[0] = __("Relationship information");
$table_relations->head_colspan[0] = 4;
$table_relations->data = array();
foreach ($relations as $relation) {
$data = array();
$data[0] = __('Agent');
$data[1] = ui_print_agent_name ($id_agente, true);
$data[2] = __('Module');
$data[3] = "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente
&id_agente=$id_agente&tab=module&edit_module=1&id_agent_module=$id_agente_modulo'>" .
ui_print_truncate_text(modules_get_agentmodule_name($id_agente_modulo), 'module_medium', true, true, true, '[&hellip;]') . "</a>";
$table_relations->data[] = $data;
}
html_print_table($table_relations);
return;
}
return;
}
if (!isset ($id_agente)) {
//This page is included, $id_agente should be passed to it.
db_pandora_audit("HACK Attempt",
"Trying to get to monitor list without id_agent passed");
"Trying to get the monitor list without id_agent passed");
include ("general/noaccess.php");
exit;
}
@ -423,7 +467,12 @@ foreach ($modules as $module) {
html_print_image("images/tag_red.png", true, array("id" => 'tag-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> ';
}
//Adds relations context information
if (modules_relation_exists($module['id_agente_modulo'])) {
$data[3] .= ' <a class="relations_details" href="ajax.php?page=operation/agentes/estado_monitores&get_relations_tooltip=1&id_agente_modulo='.$module['id_agente_modulo'].'">' .
html_print_image("images/link2.png", true, array("id" => 'relations-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> ';
}
$data[4] = ui_print_string_substr ($module["descripcion"], 60, true, 8);
@ -634,11 +683,19 @@ ui_require_jquery_file ('cluetip');
/* <![CDATA[ */
$("a.tag_details").cluetip ({
arrows: true,
clickThrough: false,
attribute: 'href',
cluetipClass: 'default'
})
.click (function () {
return false;
});
$("a.relations_details").cluetip ({
width: 500,
arrows: true,
clickThrough: false,
attribute: 'href',
cluetipClass: 'default',
sticky: true,
mouseOutClose: 'both',
closeText: '<?php html_print_image("images/cancel.png") ?>'
});
/* ]]> */
</script>

View File

@ -113,6 +113,7 @@ if ($save_networkmap || $update_networkmap) {
$module_group = (int) get_parameter ('module_group', 0);
$center = (int) get_parameter ('center', 0);
$name = (string) get_parameter ('name', $activeTab);
$l2_network = (int) get_parameter ('l2_network', 0);
if ($save_networkmap) {
$result = networkmap_update_networkmap($id_networkmap,
@ -133,7 +134,8 @@ if ($save_networkmap || $update_networkmap) {
'text_filter' => $text_filter,
'dont_show_subgroups' => $dont_show_subgroups,
'center' => $center,
'show_snmp_modules' => (int)$show_snmp_modules));
'show_snmp_modules' => (int)$show_snmp_modules,
'l2_network' => (int)$l2_network));
$message = ui_print_result_message ($result,
__('Network map saved successfully'),
@ -177,6 +179,7 @@ if (!$update_networkmap && !$save_networkmap && $id_networkmap != 0) {
$center = $networkmap_data['center'];
$name = $networkmap_data['name'];
$activeTab = $networkmap_data['type'];
$l2_network = $networkmap_data['l2_network'];
}
if ($recenter_networkmap) {
@ -257,7 +260,8 @@ if (check_acl ($config['id_user'], 0, "AW")) {
'module_group=' . $module_group . '&amp;' .
'pure=' . $pure . '&amp;' .
'hidden_options=' . (int)$hidden_options . '&amp;' .
'show_snmp_modules=' . (int)$show_snmp_modules . '">' .
'show_snmp_modules=' . (int)$show_snmp_modules . '&amp;' .
'l2_network=' . (int)$l2_network . '">' .
html_print_image("images/save_mc.png", true, array ("title" => __('Save map'))) .'</a>');
}
}
@ -400,11 +404,6 @@ if ($pure == "1") {
}
if ($nooverlap == 1) {
$table->data[1][] = __('Distance between nodes') . '&nbsp;' .
html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true);
}
if ($activeTab != 'dinamic') {
$table->data[1][] = __('Font') . '&nbsp;' .
html_print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 2, 4, true);
@ -419,6 +418,16 @@ if ($activeTab == 'groups') {
html_print_checkbox ('dont_show_subgroups', '1', $dont_show_subgroups, true);
}
if ($activeTab == 'topology') {
$table->data[2][] = __('L2 network interfaces') . '&nbsp;' .
html_print_checkbox ('l2_network', '1', $l2_network, true);
}
if ($nooverlap == 1) {
$table->data[2][] = __('Distance between nodes') . '&nbsp;' .
html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true);
}
$options_form .= html_print_input_hidden('update_networkmap',1, true) .
html_print_input_hidden('hidden_options',0, true);
$options_form .= html_print_table ($table, true);

View File

@ -39,7 +39,7 @@ if (!isset($text_filter)) {
$graph = networkmap_generate_dot(__('Pandora FMS'), $group, $simple,
$font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen,
$pure, $id_networkmap, $show_snmp_modules, true, true,
$text_filter);
$text_filter, $l2_network);
if ($graph === false) {
ui_print_error_message (__('Map could not be generated'));

View File

@ -207,12 +207,11 @@ END;;
--
BEGIN
LOCK TABLE tlink IN EXCLUSIVE MODE;
INSERT INTO tlink VALUES (1,'Pandora FMS Manual','https://openideas.info/wiki/index.php?title=Pandora');
INSERT INTO tlink VALUES (2,'Pandora FMS','http://pandorafms.org');
INSERT INTO tlink VALUES (1,'Pandora FMS Manual','http://wiki.pandorafms.com/?title=Pandora');
INSERT INTO tlink VALUES (2,'Pandora FMS','http://pandorafms.com');
INSERT INTO tlink VALUES (3,'Report a bug','{https://sourceforge.net/tracker/?func=add&amp;group_id=155200&amp;atid=794852}');
INSERT INTO tlink VALUES (4,'Suggest new feature','http://sourceforge.net/tracker/?group_id=155200&amp;atid=794855');
INSERT INTO tlink VALUES (5,'Module library','http://pandorafms.org/?sec=community&amp;sec2=repository&amp;lng=es');
INSERT INTO tlink VALUES (6,'Commercial support','http://pandorafms.com');
INSERT INTO tlink VALUES (5,'Module library','http://pandorafms.com/pandora/repository/en');
COMMIT;
END;;

View File

@ -191,12 +191,11 @@ COMMIT WORK;
BEGIN WORK;
LOCK TABLE "tlink";
INSERT INTO "tlink" VALUES
(1,'Pandora FMS Manual','https://openideas.info/wiki/index.php?title=Pandora'),
(2,'Pandora FMS','http://pandorafms.org'),
(1,'Pandora FMS Manual','http://wiki.pandorafms.com/?title=Pandora'),
(2,'Pandora FMS','http://pandorafms.com'),
(3,'Report a bug','https://sourceforge.net/tracker/?func=add&amp;group_id=155200&amp;atid=794852'),
(4,'Suggest new feature','http://sourceforge.net/tracker/?group_id=155200&amp;atid=794855'),
(5,'Module library','http://pandorafms.org/?sec=community&amp;sec2=repository&amp;lng=es'),
(6,'Commercial support','http://pandorafms.com');
(5,'Module library','http://pandorafms.com/pandora/repository/en');
COMMIT WORK;
SELECT setval('tlink_id_link_seq', (SELECT (SELECT MAX(id_link) FROM tlink)));

View File

@ -1589,7 +1589,8 @@ CREATE TABLE tnetwork_map (
show_modules NUMBER(10, 0) default 0 NOT NULL,
id_agent NUMBER(10, 0) default 0 NOT NULL,
server_name VARCHAR(100) NOT NULL,
show_modulegroup NUMBER(10, 0) default 0 NOT NULL
show_modulegroup NUMBER(10, 0) default 0 NOT NULL,
l2_network NUMBER(1, 0) default 0 NOT NULL
);
CREATE SEQUENCE tnetwork_map_s INCREMENT BY 1 START WITH 1;

View File

@ -1407,7 +1407,8 @@ CREATE TABLE "tnetwork_map" (
"show_groups" INTEGER NOT NULL default 0,
"id_agent" INTEGER NOT NULL default 0,
"server_name" VARCHAR(100) NOT NULL,
"show_modulegroup" INTEGER NOT NULL default 0
"show_modulegroup" INTEGER NOT NULL default 0,
"l2_network" SMALLINT NOT NULL default 0
);
------------------------------------------------------------------------

View File

@ -1488,6 +1488,7 @@ CREATE TABLE IF NOT EXISTS `tnetwork_map` (
`id_agent` INT NOT NULL DEFAULT 0,
`server_name` VARCHAR(100) NOT NULL,
`show_modulegroup` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
`l2_network` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`id_networkmap`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -181,7 +181,7 @@ UNLOCK TABLES;
LOCK TABLES `tlink` WRITE;
INSERT INTO `tlink` VALUES
(1,'Pandora FMS Manual','https://openideas.info/wiki/index.php?title=Pandora'),
(1,'Pandora FMS Manual','http://wiki.pandorafms.com/?title=Pandora'),
(2,'Pandora FMS','http://pandorafms.com'),
(3,'Report a bug','https://sourceforge.net/tracker/?func=add&amp;group_id=155200&amp;atid=794852'),
(4,'Suggest new feature','http://sourceforge.net/tracker/?group_id=155200&amp;atid=794855'),