diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 85faca3820..0399940aea 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,30 @@ +2012-10-09 Miguel de Dios + + * extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, + extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, pandoradb.sql, + pandoradb.postgreSQL.sql, pandoradb.oracle.sql: added flag field + "pandoras_children" into the table "tnetwork_map". + + * extras/check_other_languages.sh, include/functions_agents.php, + operation/agentes/networkmap_list.php: cleaned source code style. + + * include/functions_networkmap.php: a lot of fixes for the + metaconsole, and other changes now generate a graphviz code more + clean and human readble (good for maintenaince). + + * include/ajax/networkmap.ajax.php: into the ajax call + "get_networkmap_summary" started to adapt to call from the + metaconsole (WIP). + + * include/functions_ui.php: fixes for metaconsole links to images in + the functions "ui_print_message", "ui_print_group_icon" and + "ui_toggle". And added the parameter $return in the function + "ui_toggle" for to return the html code as string. + + * operation/agentes/ver_agente.php: into the ajax call + "get_agent_status_tooltip" adapt to call from the metaconsole. + 2012-10-09 Hirofumi Kosaka * pandoradb.sql: cleaned code style, to be acceptable by diff --git a/pandora_console/extras/check_other_languages.sh b/pandora_console/extras/check_other_languages.sh index 7f912d8e56..e9936c987c 100755 --- a/pandora_console/extras/check_other_languages.sh +++ b/pandora_console/extras/check_other_languages.sh @@ -19,7 +19,7 @@ mkdir "/tmp/$1" >> /dev/null 2> /dev/null for a in `ls include/help/en` do ESTA=`find include/help/$1/$a 2> /dev/null | wc -l` - if [ $ESTA == 0 ] + if [ $ESTA == 0 ] then echo "Missing $a, and copying to /tmp/$1" cp include/help/en/$a "/tmp/$1" diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index 0fdc3a78dd..e7b6d4bd2f 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -74,9 +74,9 @@ CREATE TABLE IF NOT EXISTS `talert_special_days` ( -- --------------------------------------------------------------------- ALTER TABLE `talert_templates` ADD COLUMN `special_day` tinyint(1) DEFAULT '0'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tplanned_downtime` ADD COLUMN `monday` tinyint(1) default 0; ALTER TABLE `tplanned_downtime` ADD COLUMN `tuesday` tinyint(1) default 0; ALTER TABLE `tplanned_downtime` ADD COLUMN `wednesday` tinyint(1) default 0; @@ -92,9 +92,9 @@ ALTER TABLE `tplanned_downtime` ADD COLUMN `type_downtime` varchar(100) NOT NULL ALTER TABLE `tplanned_downtime` ADD COLUMN `type_execution` varchar(100) NOT NULL default 'once'; ALTER TABLE `tplanned_downtime` ADD COLUMN `type_periodicity` varchar(100) NOT NULL default 'weekly'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime_agents` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ DELETE FROM tplanned_downtime_agents WHERE id_downtime NOT IN (SELECT id FROM tplanned_downtime); ALTER TABLE tplanned_downtime_agents MODIFY `id_downtime` mediumint(8) NOT NULL; @@ -103,9 +103,9 @@ ALTER TABLE tplanned_downtime_agents ON DELETE CASCADE; ALTER TABLE `tplanned_downtime_agents` ADD COLUMN `all_modules` tinyint(1) default 1; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplanned_downtime_modules` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` ( `id` int(20) unsigned NOT NULL auto_increment, `id_agent` mediumint(8) unsigned NOT NULL default '0', @@ -116,9 +116,9 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` ( ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tevento` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tevento` ADD COLUMN (`source` tinytext NOT NULL, `id_extra` tinytext NOT NULL); ALTER TABLE `tevento` MODIFY COLUMN `event_type` ENUM('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal','configuration_change') CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'unknown'; ALTER TABLE `tevento` ADD COLUMN `critical_instructions` TEXT NOT NULL DEFAULT ''; @@ -127,21 +127,21 @@ ALTER TABLE `tevento` ADD COLUMN `unknown_instructions` TEXT NOT NULL DEFAULT '' ALTER TABLE `tevento` ADD COLUMN `owner_user` VARCHAR(100) NOT NULL DEFAULT ''; ALTER TABLE `tevento` ADD COLUMN `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tgrupo` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tgrupo` ADD COLUMN `description` text; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `talert_snmp` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `talert_snmp` ADD COLUMN (`_snmp_f1_` text, `_snmp_f2_` text, `_snmp_f3_` text, `_snmp_f4_` text, `_snmp_f5_` text, `_snmp_f6_` text, `trap_type` int(11) NOT NULL default '-1', `single_value` varchar(255) DEFAULT ''); --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tagente_modulo` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tagente_modulo` ADD COLUMN `module_ff_interval` int(4) unsigned DEFAULT '0'; ALTER TABLE `tagente_modulo` CHANGE COLUMN `post_process` `post_process` double(18,5) DEFAULT NULL; ALTER TABLE `tagente_modulo` ADD COLUMN `wizard_level` enum('basic','advanced','custom','nowizard') DEFAULT 'nowizard'; @@ -153,9 +153,9 @@ ALTER TABLE `tagente_modulo` ADD COLUMN `unknown_instructions` TEXT NOT NULL DEF ALTER TABLE `tagente_modulo` ADD COLUMN `critical_inverse` tinyint(1) unsigned default '0'; ALTER TABLE `tagente_modulo` ADD COLUMN `warning_inverse` tinyint(1) unsigned default '0'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tnetwork_component` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tnetwork_component` CHANGE COLUMN `post_process` `post_process` double(18,5) default NULL; ALTER TABLE `tnetwork_component` ADD COLUMN `unit` TEXT NOT NULL AFTER `post_process`; ALTER TABLE tnetwork_component ADD `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard'; @@ -167,14 +167,14 @@ ALTER TABLE tnetwork_component ADD `unknown_instructions` TEXT NOT NULL default ALTER TABLE `tnetwork_component` ADD COLUMN `critical_inverse` tinyint(1) unsigned default '0'; ALTER TABLE `tnetwork_component` ADD COLUMN `warning_inverse` tinyint(1) unsigned default '0'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tgraph_source` Alter table to allow negative values in weight --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tgraph_source MODIFY weight FLOAT(5,3) NOT NULL DEFAULT '0.000'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tevent_filter` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tevent_filter` ( `id_filter` int(10) unsigned NOT NULL auto_increment, `id_group_filter` int(10) NOT NULL default 0, @@ -194,9 +194,9 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` ( PRIMARY KEY (`id_filter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tconfig` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tconfig MODIFY value TEXT NOT NULL; -- Join the all ips of "list_ACL_IPs_for_API_%" in one row (now We have a field "value" with hudge size) INSERT INTO tconfig (token, `value`) SELECT 'list_ACL_IPs_for_API', GROUP_CONCAT(`value` SEPARATOR ';') AS `value` FROM tconfig WHERE token LIKE "list_ACL_IPs_for_API%"; @@ -218,29 +218,29 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('enable_refr', 0); UPDATE tconfig SET `value`='comparation' WHERE `token`= 'prominent_time'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `treport_content_item` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE treport_content_item ADD FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE `treport_content_item` ADD COLUMN `operation` TEXT; ALTER TABLE treport ADD COLUMN `id_template` INTEGER UNSIGNED DEFAULT 0; ALTER TABLE treport ADD COLUMN `id_group_edit` mediumint(8) unsigned NULL DEFAULT 0; ALTER TABLE treport ADD COLUMN `metaconsole` tinyint(1) DEFAULT 0; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tgraph` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tgraph` ADD COLUMN `id_graph_template` int(11) NOT NULL DEFAULT 0; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `ttipo_modulo` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ UPDATE ttipo_modulo SET descripcion='Generic data' WHERE id_tipo=1; UPDATE ttipo_modulo SET descripcion='Generic data incremental' WHERE id_tipo=4; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tusuario` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tusuario` ADD COLUMN `section` TEXT NOT NULL; INSERT INTO `tusuario` (`section`) VALUES ('Default'); ALTER TABLE `tusuario` ADD COLUMN `data_section` TEXT NOT NULL; @@ -255,24 +255,24 @@ ALTER TABLE `tusuario` ADD COLUMN `failed_attempt` int(4) NOT NULL DEFAULT 0; ALTER TABLE `tusuario` ADD COLUMN `login_blocked` tinyint(1) DEFAULT 0; ALTER TABLE `tusuario` ADD COLUMN `metaconsole_access` enum('basic','advanced','custom','all','only_console') DEFAULT 'only_console'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tmensajes` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `tmensajes` MODIFY COLUMN `mensaje` TEXT NOT NULL; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `talert_compound` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE `talert_compound` ADD COLUMN `special_day` tinyint(1) DEFAULT '0'; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `talert_commands` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`) VALUES ('Validate Event','Internal type','This alert validate the events matched with a module given the agent name (_field1_) and module name (_field2_)', 1); --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tpassword_history` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ CREATE TABLE IF NOT EXISTS `tpassword_history` ( `id_pass` int(10) unsigned NOT NULL auto_increment, `id_user` varchar(60) NOT NULL, @@ -282,34 +282,35 @@ CREATE TABLE IF NOT EXISTS `tpassword_history` ( PRIMARY KEY (`id_pass`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tplugin` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tplugin ADD `macros` text; ALTER TABLE tplugin ADD `parameters` text; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `trecon_script` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ UPDATE trecon_script SET `description`='This script is used to automatically detect SNMP Interfaces on devices, used as Recon Custom Script in the recon task. Parameters used are: * custom_field1 = network. i.e.: 192.168.100.0/24 * custom_field2 = several communities separated by comma. For example: snmp_community,public,private * custom_field3 = optative parameter to force process downed interfaces (use: '-a'). Only up interfaces are processed by default See documentation for more information.' WHERE id_recon_script = 1; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `trecon_task --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE trecon_task MODIFY subnet TEXT NOT NULL DEFAULT ''; ALTER TABLE trecon_task MODIFY field1 TEXT NOT NULL DEFAULT ''; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tlayout_data --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tlayout_data ADD COLUMN `enable_link` tinyint(1) UNSIGNED NOT NULL default 1; --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ -- Table `tnetwork_map` --- ---------------------------------------------------------------------- +------------------------------------------------------------------------ ALTER TABLE tnetwork_map ADD `text_filter` VARCHAR(100) NOT NULL DEFAULT ""; ALTER TABLE tnetwork_map ADD `dont_show_subgroups` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; +ALTER TABLE tnetwork_map ADD `pandoras_children` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; -- ---------------------------------------------------------------------- -- Table `tagente_estado` diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql index cca13730b2..a5db72fb18 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql @@ -18,9 +18,9 @@ ALTER TABLE tusuario ADD COLUMN (metaconsole_access VARCHAR2(100) DEFAULT 'only_ ALTER TABLE tusuario ADD CONSTRAINT t_usuario_metaconsole_access_cons CHECK (metaconsole_access IN ('basic','advanced','custom','all','only_console')); ALTER TABLE tusuario ADD COLUMN (not_login NUMBER(5,0) default 0 NOT NULL); --- ----------------------------------------------------- +-- --------------------------------------------------------------------- -- Table "tnetflow_filter" --- ----------------------------------------------------- +-- --------------------------------------------------------------------- CREATE TABLE tnetflow_filter ( id_sg NUMBER(10, 0) NOT NULL PRIMARY KEY, id_name VARCHAR2(600) NOT NULL, @@ -341,6 +341,7 @@ evento ------------------------------------------------------------------------ ALTER TABLE tnetwork_map ADD (text_filter VARCHAR(100) DEFAULT ''); ALTER TABLE tnetwork_map ADD (dont_show_subgroups NUMBER(10, 0) default 0 NOT NULL); +ALTER TABLE tnetwork_map ADD (pandoras_children NUMBER(10, 0) default 0 NOT NULL); ------------------------------------------------------------------------ -- Table `tagente_estado` diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql index 3030b3023b..2f841b66b9 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql @@ -332,6 +332,7 @@ ALTER TABLE "tnetwork_component" ADD COLUMN "warning_inverse" SMALLINT NOT NULL ------------------------------------------------------------------------ ALTER TABLE "tnetwork_map" ADD COLUMN "text_filter" VARCHAR(100) DEFAULT ''; ALTER TABLE "tnetwork_map" ADD COLUMN "dont_show_subgroups" INTEGER NOT NULL DEFAULT 0; +ALTER TABLE "tnetwork_map" ADD COLUMN "pandoras_children" INTEGER NOT NULL DEFAULT 0; ------------------------------------------------------------------------ -- Table `tagente_estado` diff --git a/pandora_console/include/ajax/networkmap.ajax.php b/pandora_console/include/ajax/networkmap.ajax.php index 0105eaa786..8213bbed5b 100644 --- a/pandora_console/include/ajax/networkmap.ajax.php +++ b/pandora_console/include/ajax/networkmap.ajax.php @@ -32,20 +32,32 @@ switch($action) { case 'get_networkmap_summary': $stats = get_parameter('stats', array()); $stats = json_decode(base64_decode($stats),true); + $metaconsole = (bool)get_parameter('metaconsole', false); + + $hack_metaconsole = ''; + if ($metaconsole) { + $hack_metaconsole = '../../'; + } $summary = '
'; - if(isset($stats['policies'])) { - $summary .= count($stats['policies'])." x ".html_print_image('images/policies.png',true).' '.__('Policies')."
"; + if (isset($stats['policies'])) { + $summary .= count($stats['policies']) . " x " . + html_print_image($hack_metaconsole . 'images/policies.png',true) . ' '. + __('Policies') . "
"; } - if(isset($stats['groups'])) { + if (isset($stats['groups'])) { // TODO: GET STATUS OF THE GROUPS AND ADD IT TO SUMMARY - $summary .= count($stats['groups'])." x ".html_print_image('images/group.png',true).' '.__('Groups')."
"; + $summary .= count($stats['groups']) . " x " . + html_print_image($hack_metaconsole . 'images/group.png',true) . ' ' . + __('Groups') . "
"; } - if(isset($stats['agents'])) { - $summary .= count($stats['agents'])." x ".html_print_image('images/bricks.png',true).' '.__('Agents')."
"; + if (isset($stats['agents'])) { + $summary .= count($stats['agents']) . + " x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) . + ' ' . __('Agents') . "
"; // TODO: GET STATUS OF THE AGENTS AND ADD IT TO SUMMARY //~ $status_agents = array(); //~ foreach($stats['agents'] as $id_agent) { @@ -57,7 +69,7 @@ switch($action) { //~ } } - if(isset($stats['modules'])) { + if (isset($stats['modules'])) { // TODO: GET STATUS OF THE MODULES AND ADD IT TO SUMMARY $summary .= count($stats['modules'])." x ".html_print_image('images/brick.png',true).' '.__('Modules')."
"; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 9bb211a993..f4552aea8d 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -368,14 +368,14 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 2 AND tagente_estado.utimestamp != 0'; - + $critical_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND tagente_estado.utimestamp != 0'; - + $unknown_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente @@ -423,7 +423,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o break; } unset($filter['status']); - } + } unset($filter['order']); @@ -526,19 +526,19 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o $limit_sql = " OFFSET $offset LIMIT $limit "; } $sql = sprintf("%s %s", $sql, $limit_sql); - + if ($return) return $sql; else $agents = db_get_all_rows_sql($sql); break; - case "oracle": + case "oracle": $set = array(); if (isset($offset) && isset($limit)) { $set['limit'] = $limit; $set['offset'] = $offset; } - + if ($return) return $sql; else diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 17a5974d3e..4596fa81d1 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -26,7 +26,10 @@ require_once ('functions_agents.php'); require_once($config['homedir'] . "/include/functions_modules.php"); require_once($config['homedir'] . "/include/functions_groups.php"); ui_require_css_file ('cluetip'); -ui_require_jquery_file ('cluetip'); +$hack_metaconsole = ''; +if (defined('METACONSOLE')) + $hack_metaconsole = '../../'; +ui_require_jquery_file ('cluetip', $hack_metaconsole . 'include/javascript/'); // Check if a node descends from a given node function networkmap_is_descendant ($node, $ascendant, $parents) { @@ -393,14 +396,21 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, // Returns an edge definition function networkmap_create_edge ($head, $tail, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, $sec2 = 'operation/agentes/networkmap', $tab = 'topology', $id_networkmap = 0) { - - // edgeURL allows node navigation - $edge = $head.' -- '.$tail.'[color="#BDBDBD", headclip=false, tailclip=false, - edgeURL="index.php?sec=estado&sec2='.$sec2.'&tab='.$tab.'&recenter_networkmap=1¢er='.$head. + + if (defined("METACONSOLE")) { + $url = ''; + } + else { + $url = 'index.php?sec=estado&sec2='.$sec2.'&tab='.$tab.'&recenter_networkmap=1¢er='.$head. '&layout='.$layout.'&nooverlap=' .$nooverlap.'&pure='.$pure. '&zoom='.$zoom.'&ranksep='.$ranksep.'&simple='.$simple.'®en=1'. - '&font_size='.$font_size.'&group='.$group.'&id_networkmap='.$id_networkmap.'"];'; - + '&font_size='.$font_size.'&group='.$group.'&id_networkmap='.$id_networkmap; + } + + // edgeURL allows node navigation + $edge = "\n" . $head.' -- '.$tail.'[color="#BDBDBD", headclip=false, tailclip=false, + edgeURL=""];' . "\n"; + return $edge; } @@ -429,7 +439,7 @@ function networkmap_create_group_node ($group, $simple = 0, $font_size = 10) { $icon = groups_get_icon($group['id_grupo']); - if ($simple == 0){ + if ($simple == 0) { // Set node icon if (file_exists (html_print_image("images/groups_small/" . $icon . ".png", true, false, true, true))) { $img_node = html_print_image("images/groups_small/" . $icon . ".png", true, false, false, true); @@ -445,13 +455,13 @@ function networkmap_create_group_node ($group, $simple = 0, $font_size = 10) { $name = groups_get_name($group['id_grupo']); } - $node = $group['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.30, height=0.30, label=< + $node = "\n" . $group['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.30, height=0.30, label=<
'.$img_node.'
'.$img_node.'
'.io_safe_output($name).'
>, shape="invtrapezium", URL="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$group['id_grupo'].'", - tooltip="ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'].'"];'; + tooltip="ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'].'"];' . "\n"; } else { - $node = $group['id_node'] . ' [ color="'.$status_color.'", fontsize='.$font_size.', shape="invtrapezium", URL="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$group['id_grupo'].'", style="filled", fixedsize=true, width=0.20, height=0.20, label="", tooltip="ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'].'"];'; + $node = "\n" . $group['id_node'] . ' [ color="'.$status_color.'", fontsize='.$font_size.', shape="invtrapezium", URL="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$group['id_grupo'].'", style="filled", fixedsize=true, width=0.20, height=0.20, label="", tooltip="ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'].'"];' . "\n"; } return $node; } @@ -463,21 +473,21 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu $status = agents_get_status($agent['id_agente']); // Set node status - switch($status) { + switch ($status) { case 0: - $status_color = '#8DFF1D'; // Normal monitor + $status_color = '#8DFF1D'; // Normal monitor break; case 1: - $status_color = '#FF1D1D'; // Critical monitor + $status_color = '#FF1D1D'; // Critical monitor break; case 2: - $status_color = '#FFE308'; // Warning monitor + $status_color = '#FFE308'; // Warning monitor break; case 4: - $status_color = '#FFA300'; // Alert fired + $status_color = '#FFA300'; // Alert fired break; default: - $status_color = '#BBBBBB'; // Unknown monitor + $status_color = '#BBBBBB'; // Unknown monitor break; } @@ -487,11 +497,15 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu $name = substr ($name, 0, 16) . '...'; } - if ($simple == 0){ + if ($simple == 0) { // Set node icon $img_node = ui_print_os_icon ($agent['id_os'], false, true, true, true, true, $relative); $img_node = str_replace($config['homeurl'] . '/', '', $img_node); + if (defined('METACONSOLE')) { + $img_node = '../../' . $img_node; + } + if ($relative) { $img_node = html_print_image($img_node, true, false, false, true); } @@ -499,13 +513,27 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu $img_node = html_print_image($img_node, true, false, false, false); } - $node = $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=< + if (defined("METACONSOLE")) { + $url = 'TODO'; //TODO + $url_tooltip = '../../ajax.php?' . + 'page=operation/agentes/ver_agente&' . + 'get_agent_status_tooltip=1&' . + 'id_agent='.$agent['id_agente'] . '&' . + 'metaconsole=1&' . + 'id_server=' . $agent['id_server']; + } + else { + $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente']; + $url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente']; + } + + $node = "\n" . $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<
' . $img_node . '
' . $img_node . '
'.io_safe_output($name).'
>, - shape="doublecircle", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'", - tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'].'"];'; + shape="doublecircle", URL="'.$url.'", + tooltip="' . $url_tooltip . '"];' . "\n"; } else { - $node = $agent['id_node'] . ' [ color="' . $status_color . '", fontsize='.$font_size.', shape="doublecircle", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'",style="filled", fixedsize=true, width=0.20, height=0.20, label="", tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'].'"];'; + $node = $agent['id_node'] . ' [ color="' . $status_color . '", fontsize='.$font_size.', shape="doublecircle", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'",style="filled", fixedsize=true, width=0.20, height=0.20, label="", tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'].'"];' . "\n"; } return $node; @@ -549,17 +577,36 @@ function networkmap_create_module_node ($module, $simple = 0, $font_size = 10) { // Returns the definition of the central module function networkmap_create_pandora_node ($name, $font_size = 10, $simple = 0, $stats = array()) { - $img = '' . html_print_image("images/networkmap/pandora_node.png", true, false, false, true) . ''; - $name = ''.$name.''; - $label = ''.$img.$name.'
'; - if ($simple == 1){ - $label = ''; - } $stats_json = base64_encode(json_encode($stats)); + $img_src = "images/networkmap/pandora_node.png"; + if (defined('METACONSOLE')) { + $img_src = '../../' . $img_src; + + $url_tooltip = '../../ajax.php?' . + 'page=include/ajax/networkmap.ajax&' . + 'action=get_networkmap_summary&' . + 'stats='.$stats_json . '&' . + 'metaconsole=1'; + $url = 'index.php?sec=monitoring&sec2=monitoring/tree_view'; + } + else { + $url_tooltip = 'ajax.php?page=include/ajax/networkmap.ajax&action=get_networkmap_summary&stats='.$stats_json.'", URL="index.php?sec=estado&sec2=operation/agentes/group_view'; + $url = 'index.php?sec=estado&sec2=operation/agentes/group_view'; + } + + $img_tag = html_print_image($img_src, true, false, false, true); + + $img = '' . $img_tag . ''; + $name = ''.$name.''; + $label = ''.$img.$name.'
'; + if ($simple == 1) { + $label = ''; + } + $node = '0 [ color="#364D1F", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.8, height=0.6, label=<'.$label.'>, - shape="ellipse", tooltip="ajax.php?page=include/ajax/networkmap.ajax&action=get_networkmap_summary&stats='.$stats_json.'", URL="index.php?sec=estado&sec2=operation/agentes/group_view" ];'; + shape="ellipse", tooltip="' . $url_tooltip . '", URL="' . $url . '" ];'; return $node; } @@ -833,18 +880,18 @@ function networkmap_update_networkmap ($id_networkmap, $values) { */ function networkmap_get_types () { $networkmap_types = array(); - + $is_enterprise = enterprise_include_once('include/functions_policies.php'); - + $networkmap_types['topology'] = __('Create a new topology map'); $networkmap_types['groups'] = __('Create a new group map'); - + if ($is_enterprise !== ENTERPRISE_NOT_HOOK) { $enterprise_types = enterprise_hook('policies_get_networkmap_types'); - + $networkmap_types = array_merge($networkmap_types, $enterprise_types); } - + return $networkmap_types; } @@ -855,18 +902,18 @@ function networkmap_get_types () { */ function networkmap_get_filter_types () { $networkmap_types = array(); - + $is_enterprise = enterprise_include_once('include/functions_policies.php'); - + $networkmap_types['topology'] = __('Topology'); $networkmap_types['groups'] = __('Group'); - + if ($is_enterprise !== ENTERPRISE_NOT_HOOK) { $enterprise_types = enterprise_hook('policies_get_networkmap_filter_types'); - + $networkmap_types = array_merge($networkmap_types, $enterprise_types); } - + return $networkmap_types; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index f232fc10ee..8a83c70d62 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -181,6 +181,10 @@ function printSmallFont ($string, $return = true) { * @return string HTML code if return parameter is true. */ function ui_print_message ($message, $class = '', $attributes = '', $return = false, $tag = 'h3') { + $hack_metaconsole = ''; + if (defined('METACONSOLE')) + $hack_metaconsole = '../../'; + static $first_execution = true; $text_title = ''; @@ -232,6 +236,8 @@ function ui_print_message ($message, $class = '', $attributes = '', $return = fa $icon_image = 'images/suc.png'; break; } + + $icon_image = $hack_metaconsole . $icon_image; } $id = 'info_box_' . uniqid(); @@ -244,7 +250,7 @@ function ui_print_message ($message, $class = '', $attributes = '', $return = fa '; if (!$no_close_bool) { $output .= '' . - html_print_image('images/cross.disabled.png', true) . ''; + html_print_image($hack_metaconsole . 'images/cross.disabled.png', true) . ''; } $output .= ' @@ -482,8 +488,14 @@ function ui_print_group_icon ($id_group, $return = false, $path = "groups_small" if (empty ($icon)) $output .= ' - '; - else - $output .= html_print_image("images/" . $path . "/" . $icon . ".png", true, array("style" => $style, "class" => "bot", "alt" => groups_get_name($id_group, true), "title" => groups_get_name ($id_group, true))); + else { + $hack_metaconsole = ''; + if (defined('METACONSOLE')) + $hack_metaconsole = '../../'; + + $output .= html_print_image($hack_metaconsole . "images/" . $path . "/" . $icon . ".png", + true, array("style" => $style, "class" => "bot", "alt" => groups_get_name($id_group, true), "title" => groups_get_name ($id_group, true))); + } if ($link) $output .= ''; @@ -550,7 +562,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = $os_name = get_os_name ($id_os); if (empty ($icon)) { if ($only_src) { - $output = html_print_image("images/".$subfolter."/unknown.png", false, false, true, $relative); + $output = html_print_image("images/" . $subfolter . "/unknown.png", false, false, true, $relative); } else { return "-"; @@ -559,18 +571,18 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = if ($apply_skin) { if ($only_src) { - $output = html_print_image("images/".$subfolter."/".$icon, true, false, true, $relative); + $output = html_print_image("images/" . $subfolter . "/" . $icon, true, false, true, $relative); } else { - $output = html_print_image("images/".$subfolter."/".$icon, true, array("alt" => $os_name, "title" => $os_name), false, $relative); + $output = html_print_image("images/" . $subfolter . "/" . $icon, true, array("alt" => $os_name, "title" => $os_name), false, $relative); } } else //$output = "" . $os_name . ""; - $output = "images/".$subfolter."/" . $icon; + $output = "images/" . $subfolter . "/" . $icon; if ($name === true) { - $output .= ' - '.$os_name; + $output .= ' - ' . $os_name; } if (!$return) @@ -1712,10 +1724,15 @@ function ui_print_status_image ($type, $title = "", $return = false, $options = * @param string name of the link * @param string title of the link * @param bool if the div will be hidden by default (default: true) + * @param bool Whether to return an output string or echo now (default: true) * */ -function ui_toggle($code, $name, $title = '', $hidde_default = true) { +function ui_toggle($code, $name, $title = '', $hidde_default = true, $return = false) { + $hack_metaconsole = ''; + if (defined('METACONSOLE')) + $hack_metaconsole = '../../'; + // Generate unique Id $uniqid = uniqid(''); @@ -1724,41 +1741,49 @@ function ui_toggle($code, $name, $title = '', $hidde_default = true) { $style = 'display:none'; $toggle_a = "$('#tgl_div_".$uniqid."').show();"; $toggle_b = "$('#tgl_div_".$uniqid."').hide();"; - $image_a = html_print_image("images/go.png", true, false, true); - $image_b = html_print_image("images/down.png", true, false, true); - $original = "images/down.png"; + $image_a = html_print_image($hack_metaconsole . "images/go.png", true, false, true); + $image_b = html_print_image($hack_metaconsole . "images/down.png", true, false, true); + $original = $hack_metaconsole . "images/down.png"; } else { $style = ''; $toggle_a = "$('#tgl_div_".$uniqid."').hide();"; $toggle_b = "$('#tgl_div_".$uniqid."').show();"; - $image_a = html_print_image("images/down.png", true, false, true); - $image_b = html_print_image("images/go.png", true, false, true); - $original = "images/go.png"; + $image_a = html_print_image($hack_metaconsole . "images/down.png", true, false, true); + $image_b = html_print_image($hack_metaconsole . "images/go.png", true, false, true); + $original = $hack_metaconsole . "images/go.png"; } // Link to toggle - echo ''.$name.' '.html_print_image ($original, true, array ("title" => $title, "id" => "image_".$uniqid)).'

'; + $output = ''; + $output .= ''.$name.' '.html_print_image ($original, true, array ("title" => $title, "id" => "image_".$uniqid)).'

'; // Code into a div - echo "
\n"; - echo $code; - echo "
"; + $output .= "
\n"; + $output .= $code; + $output .= "
"; // JQuery Toggle - echo ''; + $output .= ''; + + if (!$return) { + echo $output; + } + else { + return $output; + } } /** diff --git a/pandora_console/operation/agentes/networkmap_list.php b/pandora_console/operation/agentes/networkmap_list.php index 6cb4086b27..21f84ccdef 100644 --- a/pandora_console/operation/agentes/networkmap_list.php +++ b/pandora_console/operation/agentes/networkmap_list.php @@ -26,7 +26,7 @@ if (! check_acl ($config['id_user'], 0, "AR")) { exit; } -require_once ('include/functions_networkmap.php'); +require_once('include/functions_networkmap.php'); ui_print_page_header(__('Network map'), "images/bricks.png", false, "network_map", false); @@ -49,22 +49,39 @@ if ($delete_networkmap) { $group_search = get_parameter('group_search', '0'); $type_search = get_parameter('type_filter', '0'); -echo '
'; -echo ""; -echo ""; -echo "
"; -echo __('Group'); -echo ""; -html_print_select_groups($config['id_user'], 'AR', true, 'group_search', $group_search); -echo ""; -echo __('Type'); -echo ""; -$networkmap_filter_types = networkmap_get_filter_types(); -html_print_select($networkmap_filter_types, 'type_filter', $type_search, '', __('All'), 0, false); -echo ""; -html_print_submit_button (__('Filter'), 'crt', false, 'class="sub search"'); -echo "
"; -echo "
"; +?> +
+ + + + + + + + +
+ + + + + + + + + +
+
+"; -echo ""; -echo '
'; -html_print_input_hidden('add_networkmap', 1); -html_print_select($networkmap_types, 'tab', 'topology', ''); -echo ""; -html_print_submit_button (__('Create networkmap'), 'crt', false, 'class="sub next"'); -echo "
"; -echo ""; - ?> +
+ + + + + +
+ + + +
+
\ No newline at end of file diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 4083a17e86..4592280891 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -357,16 +357,43 @@ if (is_ajax ()) { if ($get_agent_status_tooltip) { $id_agent = (int) get_parameter ('id_agent'); - $agent = db_get_row ('tagente', 'id_agente', $id_agent); + $metaconsole = (bool)get_parameter('metaconsole', false); + $id_server = (int)get_parameter('id_server', 0); //Metaconsole + + $server = null; + if ($metaconsole) { + $server = db_get_row('tmetaconsole_setup', 'id', $id_server); + + if (metaconsole_connect($server) != NOERR) { + return; + } + + $agent = db_get_row ('tagente', 'id_agente', $id_agent); + + metaconsole_restore_db(); + } + else { + $agent = db_get_row ('tagente', 'id_agente', $id_agent); + } + + + + echo '

'.$agent['nombre'].'

'; echo ''.__('Main IP').': '.$agent['direccion'].'
'; echo ''.__('Group').': '; - echo html_print_image('images/groups_small/'.groups_get_icon ($agent['id_grupo']).'.png', true); + + $hack_metaconsole = ''; + if ($metaconsole) { + $hack_metaconsole = '../../'; + } + echo html_print_image($hack_metaconsole . 'images/groups_small/'.groups_get_icon ($agent['id_grupo']).'.png', true); echo groups_get_name ($agent['id_grupo']).'
'; echo ''.__('Last contact').': '.human_time_comparation($agent['ultimo_contacto']).'
'; echo ''.__('Last remote contact').': '.human_time_comparation($agent['ultimo_contacto_remoto']).'
'; + $sql = sprintf ('SELECT tagente_modulo.descripcion, tagente_modulo.nombre FROM tagente_estado, tagente_modulo @@ -374,12 +401,35 @@ if (is_ajax ()) { AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.estado = 1', $id_agent); - $bad_modules = db_get_all_rows_sql ($sql); + if ($metaconsole) { + if (metaconsole_connect($server) != NOERR) { + return; + } + + $bad_modules = db_get_all_rows_sql ($sql); + + metaconsole_restore_db(); + } + else { + $bad_modules = db_get_all_rows_sql ($sql); + } + $sql = sprintf ('SELECT COUNT(*) FROM tagente_modulo WHERE id_agente = %d AND disabled = 0', $id_agent); - $total_modules = db_get_sql ($sql); + if ($metaconsole) { + if (metaconsole_connect($server) != NOERR) { + return; + } + + $total_modules = db_get_sql ($sql); + + metaconsole_restore_db(); + } + else { + $total_modules = db_get_sql ($sql); + } if ($bad_modules === false) $size_bad_modules = 0; @@ -408,7 +458,19 @@ if (is_ajax ()) { AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module AND talert_template_modules.times_fired > 0 ', $id_agent); - $alert_modules = db_get_sql ($sql); + if ($metaconsole) { + if (metaconsole_connect($server) != NOERR) { + return; + } + + $alert_modules = db_get_sql ($sql); + + metaconsole_restore_db(); + } + else { + $alert_modules = db_get_sql ($sql); + } + if ($alert_modules > 0) { $sql = sprintf ('SELECT tagente_modulo.nombre, talert_template_modules.last_fired FROM talert_template_modules, tagente_modulo, tagente @@ -419,7 +481,18 @@ if (is_ajax ()) { AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module AND talert_template_modules.times_fired > 0 ', $id_agent); - $alerts = db_get_all_rows_sql ($sql); + if ($metaconsole) { + if (metaconsole_connect($server) != NOERR) { + return; + } + + $alerts = db_get_all_rows_sql ($sql); + + metaconsole_restore_db(); + } + else { + $alerts = db_get_all_rows_sql ($sql); + } echo ''.__('Alerts fired').':'; echo "