diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d95b1951cc..d8ea903252 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2011-04-19 Ramon Novoa + + * include/functions_db.php, pandoradb.sql, + pandoradb.postgreSQL.sql, pandoradb.oracle.sql, + extras/pandoradb_migrate_v3.2_to_v4.0.sql, + general/logon_ok.php, godmode/admin_access_logs.php: Several fixes to + make things work in MySQL, PostgreSQL and Oracle. + 2011-04-19 Javier Lanz * godmode/modules/manage_network_components_form.php: Enabled port field diff --git a/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql b/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql index b71b07383a..69f6b66bb2 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql @@ -79,3 +79,12 @@ ALTER TABLE `treport_content` ADD COLUMN `style` TEXT NOT NULL DEFAULT ''; -- Table `tperfil` -- ----------------------------------------------------- ALTER TABLE `tperfil` MODIFY `name` TEXT NOT NULL DEFAULT ''; + +-- ----------------------------------------------------- +-- Table `tsesion` +-- ----------------------------------------------------- + +ALTER TABLE `tsesion` CHANGE `ID_sesion` `id_sesion` bigint(20) unsigned NOT NULL auto_increment; +ALTER TABLE `tsesion` CHANGE `ID_usuario` `id_usuario` varchar(60) NOT NULL default '0'; +ALTER TABLE `tsesion` CHANGE `IP_origen` `ip_origen` varchar(100) NOT NULL default ''; + diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 68f65b95f8..cba4bf0ce3 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -171,16 +171,16 @@ switch ($config["dbtype"]) { AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10", $config["id_user"]); break; case "postgresql": - $sql = sprintf ("SELECT \"ID_usuario\", accion, fecha, \"IP_origen\", descripcion + $sql = sprintf ("SELECT \"id_usuario\", accion, fecha, \"ip_origen\", descripcion FROM tsesion WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - 604800) - AND \"ID_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 10", $config["id_user"]); + AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 10", $config["id_user"]); break; case "oracle": - $sql = sprintf ("SELECT ID_usuario, accion, fecha, IP_origen, descripcion + $sql = sprintf ("SELECT id_usuario, accion, fecha, ip_origen, descripcion FROM tsesion WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - 604800) - AND ID_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config["id_user"]); + AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config["id_user"]); break; } @@ -199,8 +199,8 @@ foreach ($sessions as $session) { $session_ip_origen = $session['ip_origen']; break; case "postgresql": - $session_id_usuario = $session['ID_usuario']; - $session_ip_origen = $session['IP_origen']; + $session_id_usuario = $session['id_usuario']; + $session_ip_origen = $session['ip_origen']; break; } diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index b75dede745..ebb09cd490 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -90,25 +90,25 @@ if ($tipo_log != 'all') { switch ($config['dbtype']) { case "mysql": if ($user_filter != 'all') { - $filter .= sprintf(' AND ID_usuario = "%s"', $user_filter); + $filter .= sprintf(' AND id_usuario = "%s"', $user_filter); } $filter .= ' AND (accion LIKE "%' . $filter_text . '%" OR descripcion LIKE "%' . $filter_text . '%")'; if ($filter_ip != '') { - $filter .= sprintf(' AND IP_origen LIKE "%s"', $filter_ip); + $filter .= sprintf(' AND ip_origen LIKE "%s"', $filter_ip); } break; case "postgresql": case "oracle": if ($user_filter != 'all') { - $filter .= sprintf(' AND ID_usuario = \'%s\'', $user_filter); + $filter .= sprintf(' AND id_usuario = \'%s\'', $user_filter); } $filter .= ' AND (accion LIKE \'%' . $filter_text . '%\' OR descripcion LIKE \'%' . $filter_text . '%\')'; if ($filter_ip != '') { - $filter .= sprintf(' AND IP_origen LIKE \'%s\'', $filter_ip); + $filter .= sprintf(' AND ip_origen LIKE \'%s\'', $filter_ip); } break; } @@ -224,7 +224,7 @@ foreach ($result as $row) { switch ($config['dbtype']) { case "mysql": case "postgresql": - $data[0] = $row["ID_usuario"]; + $data[0] = $row["id_usuario"]; break; case "oracle": $data[0] = $row["id_usuario"]; @@ -235,7 +235,7 @@ foreach ($result as $row) { switch ($config['dbtype']) { case "mysql": case "postgresql": - $data[3] = $row["IP_origen"]; + $data[3] = $row["ip_origen"]; break; case "oracle": $data[3] = $row["ip_origen"]; @@ -246,7 +246,7 @@ foreach ($result as $row) { switch ($config['dbtype']) { case "mysql": case "postgresql": - $data[5] = enterprise_hook('cell1EntepriseAudit', array($row['ID_sesion'])); + $data[5] = enterprise_hook('cell1EntepriseAudit', array($row['id_sesion'])); break; case "oracle": $data[5] = enterprise_hook('cell1EntepriseAudit', array($row['id_sesion'])); @@ -257,7 +257,7 @@ foreach ($result as $row) { switch ($config['dbtype']) { case "mysql": case "postgresql": - $data[6] = enterprise_hook('cell2EntepriseAudit', array($row['ID_sesion'])); + $data[6] = enterprise_hook('cell2EntepriseAudit', array($row['id_sesion'])); break; case "oracle": $data[6] = enterprise_hook('cell2EntepriseAudit', array($row['id_sesion'])); @@ -271,7 +271,7 @@ foreach ($result as $row) { switch ($config['dbtype']) { case "mysql": case "postgresql": - enterprise_hook('rowEnterpriseAudit', array($table, &$iterator, $row['ID_sesion'])); + enterprise_hook('rowEnterpriseAudit', array($table, &$iterator, $row['id_sesion'])); break; case "oracle": enterprise_hook('rowEnterpriseAudit', array($table, &$iterator, $row['id_sesion'])); diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index c56663c622..912a927eb1 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -378,9 +378,9 @@ function pandora_audit($accion, $descripcion, $user_id = false, $ip = false, $in $accion = safe_input($accion); $descripcion = safe_input($descripcion); - $values = array('ID_usuario' => $id, + $values = array('id_usuario' => $id, 'accion' => $accion, - 'IP_origen' => $ip, + 'ip_origen' => $ip, 'descripcion' => $descripcion, 'fecha' => date('Y-m-d H:i:s'), 'utimestamp' => time()); diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index c06ad2e2e1..c3c07f95e0 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -24,9 +24,12 @@ -- Pandora schema creation script -- Triggers must end with two semicolons because Pandora installer need it +CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP (oracletime IN DATE DEFAULT SYSDATE) RETURN INTEGER AS unixtime INTEGER; BEGIN unixtime := (oracletime - to_date('19700101','YYYYMMDD')) * 86400; RETURN unixtime; END;; +CREATE OR REPLACE FUNCTION NOW RETURN TIMESTAMP AS t_now TIMESTAMP; BEGIN SELECT LOCALTIMESTAMP INTO t_now FROM dual; RETURN t_now; END;; + CREATE TABLE taddress ( id_a NUMBER(10, 0) NOT NULL PRIMARY KEY, - ip VARCHAR(60) default '' NOT NULL, + ip VARCHAR(60) default '', ip_pack NUMBER(10, 0) default 0 NOT NULL ); CREATE INDEX taddress_ip_idx ON taddress(ip); @@ -48,7 +51,7 @@ CREATE OR REPLACE TRIGGER taddress_agent_inc BEFORE INSERT ON taddress_agent REF CREATE TABLE tagente ( id_agente NUMBER(10, 0) NOT NULL PRIMARY KEY, - nombre VARCHAR2(600) default '' NOT NULL, + nombre VARCHAR2(600) default '', direccion VARCHAR2(100) default NULL, comentarios VARCHAR2(255) default '', id_grupo NUMBER(10, 0) default 0 NOT NULL, @@ -124,7 +127,7 @@ CREATE OR REPLACE TRIGGER tagente_datos_log4x_inc BEFORE INSERT ON tagente_datos CREATE TABLE tagente_estado ( id_agente_estado NUMBER(10, 0) NOT NULL PRIMARY KEY, id_agente_modulo NUMBER(10, 0) default 0 NOT NULL, - datos CLOB default '' NOT NULL, + datos CLOB default '', timestamp TIMESTAMP default NULL, estado NUMBER(10, 0) default 0 NOT NULL, id_agente NUMBER(10, 0) default 0 NOT NULL, @@ -161,8 +164,8 @@ CREATE TABLE tagente_modulo ( id_agente_modulo NUMBER(10, 0) NOT NULL PRIMARY KEY, id_agente NUMBER(10, 0) default 0 NOT NULL, id_tipo_modulo NUMBER(10, 0) default 0 NOT NULL, - descripcion CLOB default '' NOT NULL, - nombre CLOB default '' NOT NULL, + descripcion CLOB default '', + nombre CLOB default '', id_policy_module NUMBER(10, 0) default 0 NOT NULL, max NUMBER(19, 0) default 0 NOT NULL, min NUMBER(19, 0) default 0 NOT NULL, @@ -221,14 +224,14 @@ CREATE INDEX tagent_access_utimestamp_idx ON tagent_access(utimestamp); CREATE TABLE talert_snmp ( id_as NUMBER(10, 0) NOT NULL PRIMARY KEY, id_alert NUMBER(10, 0) default 0 NOT NULL, - al_field1 CLOB default '' NOT NULL, - al_field2 CLOB default '' NOT NULL, - al_field3 CLOB default '' NOT NULL, + al_field1 CLOB default '', + al_field2 CLOB default '', + al_field3 CLOB default '', description VARCHAR2(255) default '', alert_type NUMBER(5, 0) default 0 NOT NULL, agent VARCHAR2(100) default '', custom_oid VARCHAR2(200) default '', - oid VARCHAR2(255) default '' NOT NULL, + oid VARCHAR2(255) default '', time_threshold NUMBER(10, 0) default 0 NOT NULL, times_fired NUMBER(5, 0) default 0 NOT NULL, last_fired TIMESTAMP default NULL, @@ -244,7 +247,7 @@ CREATE OR REPLACE TRIGGER talert_snmp_inc BEFORE INSERT ON talert_snmp REFERENCI CREATE TABLE talert_commands ( id NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(100) default '' NOT NULL, + name VARCHAR2(100) default '', command CLOB default '', description CLOB default '', internal NUMBER(10, 0) default 0 @@ -258,7 +261,7 @@ CREATE TABLE talert_actions ( id NUMBER(10, 0) NOT NULL PRIMARY KEY, name CLOB default '', id_alert_command NUMBER(10, 0) NOT NULL REFERENCES talert_commands(id) ON DELETE CASCADE, - field1 CLOB default '' NOT NULL, + field1 CLOB default '', field2 CLOB default '', field3 CLOB default '', id_group NUMBER(19, 0) default 0 NOT NULL, @@ -300,7 +303,7 @@ CREATE TABLE talert_templates ( saturday NUMBER(5, 0) default 1, sunday NUMBER(5, 0) default 1, recovery_notify NUMBER(5, 0) default 0, - field2_recovery CLOB default '' NOT NULL, + field2_recovery CLOB default '', field3_recovery CLOB NOT NULL, priority NUMBER(10, 0) default 0 NOT NULL, id_group NUMBER(10, 0) default 0 NOT NULL, @@ -379,7 +382,7 @@ CREATE TABLE talert_compound ( saturday NUMBER(5, 0) default 1, sunday NUMBER(5, 0) default 1, recovery_notify NUMBER(5, 0) default 0, - field2_recovery VARCHAR2(255) default '' NOT NULL, + field2_recovery VARCHAR2(255) default '', field3_recovery CLOB NOT NULL, internal_counter NUMBER(10, 0) default 0, last_fired NUMBER(19, 0) default 0 NOT NULL, @@ -437,8 +440,8 @@ CREATE OR REPLACE TRIGGER talert_compound_action_update1 AFTER UPDATE OF ID ON t CREATE TABLE tattachment ( id_attachment NUMBER(10, 0) NOT NULL PRIMARY KEY, id_incidencia NUMBER(10, 0) default 0 NOT NULL, - id_usuario VARCHAR2(60) default '' NOT NULL, - filename VARCHAR2(255) default '' NOT NULL, + id_usuario VARCHAR2(60) default '', + filename VARCHAR2(255) default '', description VARCHAR2(150) default '', "size" NUMBER(19, 0) default 0 NOT NULL ); @@ -449,8 +452,8 @@ CREATE OR REPLACE TRIGGER tattachment_inc BEFORE INSERT ON tattachment REFERENCI CREATE TABLE tconfig ( id_config NUMBER(10, 0) NOT NULL PRIMARY KEY, - token VARCHAR2(100) default '' NOT NULL, - value VARCHAR2(100) default '' NOT NULL + token VARCHAR2(100) default '', + value VARCHAR2(100) default '' ); CREATE SEQUENCE tconfig_s INCREMENT BY 1 START WITH 1; @@ -459,7 +462,7 @@ CREATE OR REPLACE TRIGGER tconfig_inc BEFORE INSERT ON tconfig REFERENCING NEW A CREATE TABLE tconfig_os ( id_os NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(100) default '' NOT NULL, + name VARCHAR2(100) default '', description VARCHAR2(250) default '', icon_name VARCHAR2(100) default '' ); @@ -472,13 +475,13 @@ CREATE TABLE tevento ( id_grupo NUMBER(10, 0) default 0 NOT NULL, estado NUMBER(10, 0) default 0 NOT NULL, timestamp TIMESTAMP default NULL, - evento CLOB default '' NOT NULL, + evento CLOB default '', utimestamp NUMBER(19, 0) default 0 NOT NULL, event_type VARCHAR2(50) default 'unknown', id_agentmodule NUMBER(10, 0) default 0 NOT NULL, id_alert_am NUMBER(10, 0) default 0 NOT NULL, criticity NUMBER(10, 0) default 0 NOT NULL, - user_comment CLOB NOT NULL, + user_comment CLOB, CONSTRAINT tevento_event_type_cons CHECK (event_type IN ('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')) ); CREATE INDEX tevento_id_1_idx ON tevento(id_agente, id_evento); @@ -496,7 +499,7 @@ CREATE OR REPLACE TRIGGER tevento_inc BEFORE INSERT ON tevento REFERENCING NEW A -- Criticity: 4 - Critical (red) (status 1) CREATE TABLE tgrupo ( id_grupo NUMBER(10, 0) NOT NULL PRIMARY KEY, - nombre CLOB default '' NOT NULL, + nombre CLOB default '', icon VARCHAR2(50) default 'world', parent NUMBER(10, 0) default 0 NOT NULL, propagate NUMBER(5, 0) default 0, @@ -512,10 +515,10 @@ CREATE TABLE tincidencia ( id_incidencia NUMBER(19, 0) NOT NULL PRIMARY KEY, inicio TIMESTAMP default NULL, cierre TIMESTAMP default NULL, - titulo CLOB default '' NOT NULL, + titulo CLOB default '', descripcion CLOB NOT NULL, - id_usuario VARCHAR2(60) default '' NOT NULL, - origen VARCHAR2(100) default '' NOT NULL, + id_usuario VARCHAR2(60) default '', + origen VARCHAR2(100) default '', estado NUMBER(10, 0) default 0 NOT NULL, prioridad NUMBER(10, 0) default 0 NOT NULL, id_grupo NUMBER(10, 0) default 0 NOT NULL, @@ -536,14 +539,14 @@ CREATE SEQUENCE tincidencia_s INCREMENT BY 1 START WITH 1; CREATE OR REPLACE TRIGGER tincidencia_inc BEFORE INSERT ON tincidencia REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tincidencia_s.nextval INTO :NEW.ID_INCIDENCIA FROM dual; END;; CREATE TABLE tlanguage ( - id_language VARCHAR2(6) default '' NOT NULL, - name VARCHAR2(100) default '' NOT NULL + id_language VARCHAR2(6) default '', + name VARCHAR2(100) default '' ); CREATE TABLE tlink ( id_link NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(100) default '' NOT NULL, - link VARCHAR2(255) default '' NOT NULL + name VARCHAR2(100) default '', + link VARCHAR2(255) default '' ); CREATE SEQUENCE tlink_s INCREMENT BY 1 START WITH 1; @@ -552,11 +555,11 @@ CREATE OR REPLACE TRIGGER tlink_inc BEFORE INSERT ON tlink REFERENCING NEW AS NE CREATE TABLE tmensajes ( id_mensaje NUMBER(10, 0) NOT NULL PRIMARY KEY, - id_usuario_origen VARCHAR2(60) default '' NOT NULL, - id_usuario_destino VARCHAR2(60) default '' NOT NULL, + id_usuario_origen VARCHAR2(60) default '', + id_usuario_destino VARCHAR2(60) default '', mensaje CLOB NOT NULL, timestamp NUMBER(19, 0) default 0 NOT NULL, - subject VARCHAR2(255) default '' NOT NULL, + subject VARCHAR2(255) default '', estado NUMBER(10, 0) default 0 NOT NULL ); @@ -566,7 +569,7 @@ CREATE OR REPLACE TRIGGER tmensajes_inc BEFORE INSERT ON tmensajes REFERENCING N CREATE TABLE tmodule_group ( id_mg NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(150) default '' NOT NULL + name VARCHAR2(150) default '' ); CREATE SEQUENCE tmodule_group_s INCREMENT BY 1 START WITH 1; @@ -614,14 +617,14 @@ CREATE OR REPLACE TRIGGER tnetwork_component_inc BEFORE INSERT ON tnetwork_compo CREATE TABLE tnetwork_component_group ( id_sg NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(200) default '' NOT NULL, + name VARCHAR2(200) default '', parent NUMBER(19, 0) default 0 NOT NULL ); CREATE TABLE tnetwork_profile ( id_np NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(100) default '' NOT NULL, + name VARCHAR2(100) default '', description VARCHAR2(250) default '' ); @@ -645,12 +648,12 @@ CREATE TABLE tnota ( CREATE INDEX tnota_id_incident_idx ON tnota(id_incident); CREATE TABLE torigen ( - origen VARCHAR2(100) default '' NOT NULL + origen VARCHAR2(100) default '' ); CREATE TABLE tperfil ( id_perfil NUMBER(10, 0) NOT NULL PRIMARY KEY, - name CLOB default '' NOT NULL, + name CLOB default '', incident_edit NUMBER(5, 0) default 0 NOT NULL, incident_view NUMBER(5, 0) default 0 NOT NULL, incident_management NUMBER(5, 0) default 0 NOT NULL, @@ -680,9 +683,9 @@ CREATE OR REPLACE TRIGGER trecon_script_inc BEFORE INSERT ON trecon_script REFER CREATE TABLE trecon_task ( id_rt NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(100) default '' NOT NULL, - description VARCHAR2(250) default '' NOT NULL, - subnet VARCHAR2(64) default '' NOT NULL, + name VARCHAR2(100) default '', + description VARCHAR2(250) default '', + subnet VARCHAR2(64) default '', id_network_profile NUMBER(10, 0) default 0 NOT NULL, create_incident NUMBER(10, 0) default 0 NOT NULL, id_group NUMBER(10, 0) default 1 NOT NULL, @@ -691,13 +694,13 @@ CREATE TABLE trecon_task ( interval_sweep NUMBER(10, 0) default 0 NOT NULL, id_recon_server NUMBER(10, 0) default 0 NOT NULL, id_os NUMBER(10, 0) default 0 NOT NULL, - recon_ports VARCHAR2(250) default '' NOT NULL, + recon_ports VARCHAR2(250) default '', snmp_community VARCHAR2(64) default 'public' NOT NULL, id_recon_script NUMBER(10, 0), - field1 VARCHAR2(250) default '' NOT NULL, - field2 VARCHAR2(250) default '' NOT NULL, - field3 VARCHAR2(250) default '' NOT NULL, - field4 VARCHAR2(250) default '' NOT NULL + field1 VARCHAR2(250) default '', + field2 VARCHAR2(250) default '', + field3 VARCHAR2(250) default '', + field4 VARCHAR2(250) default '' ); CREATE INDEX trecon_task_id_rec_serv_idx ON trecon_task(id_recon_server); @@ -707,8 +710,8 @@ CREATE OR REPLACE TRIGGER trecon_task_inc BEFORE INSERT ON trecon_task REFERENCI CREATE TABLE tserver ( id_server NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(100) default '' NOT NULL, - ip_address VARCHAR2(100) default '' NOT NULL, + name VARCHAR2(100) default '', + ip_address VARCHAR2(100) default '', status NUMBER(10, 0) default 0 NOT NULL, laststart TIMESTAMP default NULL, keepalive TIMESTAMP default NULL, @@ -719,7 +722,7 @@ CREATE TABLE tserver ( checksum NUMBER(10, 0) default 0 NOT NULL, description VARCHAR2(255) default NULL, recon_server NUMBER(10, 0) default 0 NOT NULL, - version VARCHAR2(20) default '' NOT NULL, + version VARCHAR2(20) default '', plugin_server NUMBER(10, 0) default 0 NOT NULL, prediction_server NUMBER(10, 0) default 0 NOT NULL, wmi_server NUMBER(10, 0) default 0 NOT NULL, @@ -755,16 +758,16 @@ CREATE OR REPLACE TRIGGER tserver_inc BEFORE INSERT ON tserver REFERENCING NEW A -- TODO: drop 2.x xxxx_server fields, unused since server_type exists. CREATE TABLE tsesion ( - ID_sesion NUMBER(19, 0) NOT NULL PRIMARY KEY, - ID_usuario VARCHAR2(60) default '0' NOT NULL, - IP_origen VARCHAR2(100) default '' NOT NULL, - accion VARCHAR2(100) default '' NOT NULL, - descripcion CLOB default '' NOT NULL, + id_sesion NUMBER(19, 0) NOT NULL PRIMARY KEY, + id_usuario VARCHAR2(60) default '0' NOT NULL, + ip_origen VARCHAR2(100) default '', + accion VARCHAR2(100) default '', + descripcion CLOB default '', fecha TIMESTAMP default NULL, utimestamp NUMBER(19, 0) default 0 NOT NULL ); CREATE INDEX tsesion_utimestamp_idx ON tsesion(utimestamp); -CREATE INDEX tsesion_ID_usuario_idx ON tsesion(ID_usuario); +CREATE INDEX tsesion_id_usuario_idx ON tsesion(id_usuario); CREATE SEQUENCE tsesion_s INCREMENT BY 1 START WITH 1; @@ -772,9 +775,9 @@ CREATE OR REPLACE TRIGGER tsesion_inc BEFORE INSERT ON tsesion REFERENCING NEW A CREATE TABLE ttipo_modulo ( id_tipo NUMBER(10, 0) NOT NULL PRIMARY KEY, - nombre VARCHAR2(100) default '' NOT NULL, + nombre VARCHAR2(100) default '', categoria NUMBER(10, 0) default 0 NOT NULL, - descripcion VARCHAR2(100) default '' NOT NULL, + descripcion VARCHAR2(100) default '', icon VARCHAR2(100) default NULL ); @@ -784,8 +787,8 @@ CREATE OR REPLACE TRIGGER ttipo_modulo_inc BEFORE INSERT ON ttipo_modulo REFEREN CREATE TABLE ttrap ( id_trap NUMBER(19, 0) NOT NULL PRIMARY KEY, - source VARCHAR2(50) default '' NOT NULL, - oid CLOB default '' NOT NULL, + source VARCHAR2(50) default '', + oid CLOB default '', oid_custom CLOB default '', type NUMBER(10, 0) default 0 NOT NULL, type_custom VARCHAR2(100) default '', @@ -807,7 +810,7 @@ CREATE TABLE tusuario ( fullname VARCHAR2(255) NOT NULL, firstname VARCHAR2(255) NOT NULL, lastname VARCHAR2(255) NOT NULL, - middlename VARCHAR2(255) default '' NOT NULL, + middlename VARCHAR2(255) default '', password VARCHAR2(45) default NULL, comments VARCHAR2(200) default NULL, last_connect NUMBER(19, 0) default 0 NOT NULL, @@ -823,10 +826,10 @@ CREATE TABLE tusuario ( CREATE TABLE tusuario_perfil ( id_up NUMBER(19, 0) NOT NULL PRIMARY KEY, - id_usuario VARCHAR2(100) default '' NOT NULL, + id_usuario VARCHAR2(100) default '', id_perfil NUMBER(10, 0) default 0 NOT NULL, id_grupo NUMBER(10, 0) default 0 NOT NULL, - assigned_by VARCHAR2(100) default '' NOT NULL + assigned_by VARCHAR2(100) default '' ); CREATE SEQUENCE tusuario_perfil_s INCREMENT BY 1 START WITH 1; @@ -835,8 +838,8 @@ CREATE OR REPLACE TRIGGER tusuario_perfil_inc BEFORE INSERT ON tusuario_perfil R CREATE TABLE tnews ( id_news NUMBER(10, 0) NOT NULL PRIMARY KEY, - author VARCHAR2(255) DEFAULT '' NOT NULL, - subject VARCHAR2(255) DEFAULT '' NOT NULL, + author VARCHAR2(255) DEFAULT '', + subject VARCHAR2(255) DEFAULT '', text CLOB NOT NULL, timestamp TIMESTAMP default NULL ); @@ -847,8 +850,8 @@ CREATE OR REPLACE TRIGGER tnews_inc BEFORE INSERT ON tnews REFERENCING NEW AS NE CREATE TABLE tgraph ( id_graph NUMBER(10, 0) NOT NULL PRIMARY KEY, - id_user VARCHAR2(100) default '' NOT NULL, - name VARCHAR2(150) default '' NOT NULL, + id_user VARCHAR2(100) default '', + name VARCHAR2(150) default '', description CLOB NOT NULL, period NUMBER(10, 0) default 0 NOT NULL, width NUMBER(10, 0) default 0 NOT NULL, @@ -876,8 +879,8 @@ CREATE OR REPLACE TRIGGER tgraph_source_inc BEFORE INSERT ON tgraph_source REFER CREATE TABLE treport ( id_report NUMBER(10, 0) NOT NULL PRIMARY KEY, - id_user VARCHAR2(100) default '' NOT NULL, - name VARCHAR2(150) default '' NOT NULL, + id_user VARCHAR2(100) default '', + name VARCHAR2(150) default '', description CLOB NOT NULL, private NUMBER(5, 0) default 0 NOT NULL, id_group NUMBER(19, 0) default 0 NOT NULL, @@ -931,7 +934,7 @@ CREATE TABLE treport_content ( order_uptodown NUMBER(10, 0) default 0 NOT NULL, show_graph NUMBER(10, 0) default 0 NOT NULL, group_by_agent NUMBER(10, 0) default 0 NOT NULL, - style CLOB default '' NOT NULL, + style CLOB default '', id_group NUMBER(10, 0) default 0 NOT NULL, id_module_group NUMBER(10, 0) default 0 NOT NULL ); @@ -975,7 +978,7 @@ CREATE OR REPLACE TRIGGER treport_content_item_inc BEFORE INSERT ON treport_cont CREATE TABLE treport_custom_sql ( id NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(150) default '' NOT NULL, + name VARCHAR2(150) default '', sql CLOB default NULL ); @@ -1039,7 +1042,7 @@ CREATE OR REPLACE TRIGGER tplugin_inc BEFORE INSERT ON tplugin REFERENCING NEW A CREATE TABLE tmodule ( id_module NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(100) default '' NOT NULL + name VARCHAR2(100) default '' ); CREATE SEQUENCE tmodule_s INCREMENT BY 1 START WITH 1; @@ -1048,17 +1051,17 @@ CREATE OR REPLACE TRIGGER tmodule_inc BEFORE INSERT ON tmodule REFERENCING NEW A CREATE TABLE tserver_export ( id NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(100) default '' NOT NULL, - preffix VARCHAR2(100) default '' NOT NULL, + name VARCHAR2(100) default '', + preffix VARCHAR2(100) default '', interval NUMBER(10, 0) default 300 NOT NULL, - ip_server VARCHAR2(100) default '' NOT NULL, + ip_server VARCHAR2(100) default '', connect_mode VARCHAR2(20) default 'local', id_export_server NUMBER(10, 0) default NULL , - "user" VARCHAR2(100) default '' NOT NULL, - pass VARCHAR2(100) default '' NOT NULL, + "user" VARCHAR2(100) default '', + pass VARCHAR2(100) default '', port NUMBER(10, 0) default 0 NOT NULL, - directory VARCHAR2(100) default '' NOT NULL, - options VARCHAR2(100) default '' NOT NULL, + directory VARCHAR2(100) default '', + options VARCHAR2(100) default '', --Number of hours of diference with the server timezone timezone_offset NUMBER(5, 0) default 0 NOT NULL, CONSTRAINT tserver_export_conn_mode_cons CHECK (connect_mode IN ('tentacle', 'ssh', 'local')) @@ -1073,9 +1076,9 @@ CREATE OR REPLACE TRIGGER tserver_export_inc BEFORE INSERT ON tserver_export REF CREATE TABLE tserver_export_data ( id NUMBER(10, 0) NOT NULL PRIMARY KEY, id_export_server NUMBER(10, 0) default 0 NOT NULL, - agent_name VARCHAR2(100) default '' NOT NULL, - module_name VARCHAR2(100) default '' NOT NULL, - module_type VARCHAR2(100) default '' NOT NULL, + agent_name VARCHAR2(100) default '', + module_name VARCHAR2(100) default '', + module_type VARCHAR2(100) default '', data VARCHAR2(255) default NULL, timestamp TIMESTAMP default NULL ); @@ -1370,7 +1373,7 @@ CREATE OR REPLACE TRIGGER tsnmp_filter_inc BEFORE INSERT ON tsnmp_filter REFEREN -- ----------------------------------------------------- CREATE TABLE tagent_custom_fields ( id_field NUMBER(10, 0) NOT NULL PRIMARY KEY, - name VARCHAR2(45) default '' NOT NULL, + name VARCHAR2(45) default '', display_on_front NUMBER(5, 0) default 0 NOT NULL ); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 2f5eaaa55f..9a1cb85109 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -610,16 +610,16 @@ CREATE INDEX "tserver_status_idx" ON "tserver"("status"); -- TODO: drop 2.x xxxx_server fields, unused since server_type exists. CREATE TABLE "tsesion" ( - "ID_sesion" BIGSERIAL NOT NULL PRIMARY KEY, - "ID_usuario" varchar(60) NOT NULL default '0', - "IP_origen" varchar(100) NOT NULL default '', + "id_sesion" BIGSERIAL NOT NULL PRIMARY KEY, + "id_usuario" varchar(60) NOT NULL default '0', + "ip_origen" varchar(100) NOT NULL default '', "accion" varchar(100) NOT NULL default '', "descripcion" text NOT NULL default '', "fecha" TIMESTAMP without time zone default NULL, "utimestamp" BIGINT NOT NULL default 0 ); CREATE INDEX "tsesion_utimestamp_idx" ON "tsesion"("utimestamp"); -CREATE INDEX "tsesion_ID_usuario_idx" ON "tsesion"("ID_usuario"); +CREATE INDEX "tsesion_id_usuario_idx" ON "tsesion"("id_usuario"); CREATE TABLE "ttipo_modulo" ( "id_tipo" SERIAL NOT NULL PRIMARY KEY, diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8168e95a73..df39323ce8 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -668,17 +668,20 @@ CREATE TABLE IF NOT EXISTS `tserver` ( -- 9 web -- TODO: drop 2.x xxxx_server fields, unused since server_type exists. +alter table spacetime change `id_sesion` bigint(20) unsigned NOT NULL auto_increment, + `id_usuario` varchar(60) NOT NULL default '0', + `ip_origen` varchar(100) NOT NULL default '', CREATE TABLE IF NOT EXISTS `tsesion` ( - `ID_sesion` bigint(20) unsigned NOT NULL auto_increment, - `ID_usuario` varchar(60) NOT NULL default '0', - `IP_origen` varchar(100) NOT NULL default '', + `id_sesion` bigint(20) unsigned NOT NULL auto_increment, + `id_usuario` varchar(60) NOT NULL default '0', + `ip_origen` varchar(100) NOT NULL default '', `accion` varchar(100) NOT NULL default '', `descripcion` text NOT NULL default '', `fecha` datetime NOT NULL default '0000-00-00 00:00:00', `utimestamp` bigint(20) unsigned NOT NULL default '0', - PRIMARY KEY (`ID_sesion`), + PRIMARY KEY (`id_sesion`), KEY `idx_utimestamp` (`utimestamp`), - KEY `idx_user` (`ID_usuario`) + KEY `idx_user` (`id_usuario`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;