2011-04-11 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* include/functions_events.php
	include/functions_messages.php
	include/db/oracle.php
	include/functions_modules.php
	include/functions_reporting.php
	include/functions_groups.php
	include/functions_gis.php
	include/auth/mysql.php
	include/functions_networkmap.php
	include/functions_servers.php
	include/functions_network_components.php
	include/ajax/reporting.ajax.php
	include/ajax/agent.php
	include/functions_config.php
	include/functions_api.php
	include/help/en/help_timesource.php
	include/help/es/help_timesource.php
	include/help/ja/help_timesource.php
	include/fgraph.php
	include/functions.php
	include/functions_agents.php
	include/functions_db.php
	include/functions_fsgraph.php
	include/functions_alerts.php
	include/functions_reports.php
	pandoradb.oracle.sql
	install.php
	extensions/system_info.php
	extensions/update_manager.php
	extensions/dbmanager.php
	extensions/users_connected.php
	extensions/module_groups.php
	extensions/update_manager/sql/update_manager.oracle.sql
	extensions/update_manager/load_updatemanager.php
	extensions/update_manager/lib/libupdate_manager_client.php
	extensions/update_manager/lib/libupdate_manager.php
	extensions/update_manager/lib/libupdate_manager_components.php
	extensions/update_manager/lib/libupdate_manager_updates.php
	operation/search_modules.php
	operation/agentes/status_monitor.php
	operation/agentes/alerts_status.php
	operation/agentes/datos_agente.php
	operation/agentes/estado_ultimopaquete.php
	operation/agentes/exportdata.php
	operation/agentes/gis_view.php
	operation/agentes/estado_monitores.php
	operation/agentes/ver_agente.php
	operation/snmpconsole/snmp_view.php
	operation/users/user_edit.php
	operation/gis_maps/render_view.php
	operation/gis_maps/ajax.php
	operation/events/events_rss.php
	operation/events/events_list.php
	operation/events/events_marquee.php
	operation/search_alerts.php
	operation/reporting/reporting_xml.php
	operation/reporting/reporting_viewer.php
	pandoradb.data.oracle.sql
	extras/pandora_diag.php
	mobile/operation/agents/monitor_status.php
	mobile/operation/agents/view_agents.php
	mobile/operation/events/events.php
	general/logon_ok.php
	godmode/groups/group_list.php
	godmode/admin_access_logs.php
	godmode/db/db_main.php
	godmode/agentes/agent_template.php
	godmode/agentes/module_manager.php
	godmode/agentes/modificar_agente.php
	godmode/agentes/configurar_agente.php
	godmode/agentes/module_manager_editor.php
	godmode/agentes/planned_downtime.php
	godmode/alerts/alert_list.list.php
	godmode/alerts/alert_compounds.php
	godmode/alerts/alert_list.php
	godmode/setup/setup.php
	godmode/modules/manage_network_templates.php
	godmode/modules/manage_network_templates_form.php
	godmode/reporting/reporting_builder.list_items.php
	godmode/reporting/reporting_builder.preview.php
	godmode/reporting/reporting_builder.php
	godmode/reporting/reporting_builder.item_editor.php: Support for Oracle DBMS
	over Console code.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4187 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2011-04-11 17:05:20 +00:00
parent fbe9ae0090
commit f27b28d4a3
83 changed files with 1882 additions and 287 deletions

View File

@ -1,3 +1,89 @@
2011-04-11 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_events.php
include/functions_messages.php
include/db/oracle.php
include/functions_modules.php
include/functions_reporting.php
include/functions_groups.php
include/functions_gis.php
include/auth/mysql.php
include/functions_networkmap.php
include/functions_servers.php
include/functions_network_components.php
include/ajax/reporting.ajax.php
include/ajax/agent.php
include/functions_config.php
include/functions_api.php
include/help/en/help_timesource.php
include/help/es/help_timesource.php
include/help/ja/help_timesource.php
include/fgraph.php
include/functions.php
include/functions_agents.php
include/functions_db.php
include/functions_fsgraph.php
include/functions_alerts.php
include/functions_reports.php
pandoradb.oracle.sql
install.php
extensions/system_info.php
extensions/update_manager.php
extensions/dbmanager.php
extensions/users_connected.php
extensions/module_groups.php
extensions/update_manager/sql/update_manager.oracle.sql
extensions/update_manager/load_updatemanager.php
extensions/update_manager/lib/libupdate_manager_client.php
extensions/update_manager/lib/libupdate_manager.php
extensions/update_manager/lib/libupdate_manager_components.php
extensions/update_manager/lib/libupdate_manager_updates.php
operation/search_modules.php
operation/agentes/status_monitor.php
operation/agentes/alerts_status.php
operation/agentes/datos_agente.php
operation/agentes/estado_ultimopaquete.php
operation/agentes/exportdata.php
operation/agentes/gis_view.php
operation/agentes/estado_monitores.php
operation/agentes/ver_agente.php
operation/snmpconsole/snmp_view.php
operation/users/user_edit.php
operation/gis_maps/render_view.php
operation/gis_maps/ajax.php
operation/events/events_rss.php
operation/events/events_list.php
operation/events/events_marquee.php
operation/search_alerts.php
operation/reporting/reporting_xml.php
operation/reporting/reporting_viewer.php
pandoradb.data.oracle.sql
extras/pandora_diag.php
mobile/operation/agents/monitor_status.php
mobile/operation/agents/view_agents.php
mobile/operation/events/events.php
general/logon_ok.php
godmode/groups/group_list.php
godmode/admin_access_logs.php
godmode/db/db_main.php
godmode/agentes/agent_template.php
godmode/agentes/module_manager.php
godmode/agentes/modificar_agente.php
godmode/agentes/configurar_agente.php
godmode/agentes/module_manager_editor.php
godmode/agentes/planned_downtime.php
godmode/alerts/alert_list.list.php
godmode/alerts/alert_compounds.php
godmode/alerts/alert_list.php
godmode/setup/setup.php
godmode/modules/manage_network_templates.php
godmode/modules/manage_network_templates_form.php
godmode/reporting/reporting_builder.list_items.php
godmode/reporting/reporting_builder.preview.php
godmode/reporting/reporting_builder.php
godmode/reporting/reporting_builder.item_editor.php: Support for Oracle DBMS
over Console code.
2011-04-11 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/graph_builder.main.php: changed to use constants.

View File

@ -49,6 +49,7 @@ function dbmanager_query ($sql, &$error) {
return "Empty";
break;
case "postgresql":
case "oracle":
$retval = array();
if ($sql == '')

View File

@ -90,15 +90,31 @@ function mainModuleGroups() {
require_once ('include/functions_reporting.php');
//The big query
$sql = "SELECT COUNT(id_agente) AS count, estado
FROM tagente_estado
WHERE utimestamp != 0 AND id_agente IN
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled IS FALSE)
AND id_agente_modulo IN
(SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_module_group = %d AND disabled IS FALSE AND delete_pending IS FALSE)
GROUP BY estado";
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = "SELECT COUNT(id_agente) AS count, estado
FROM tagente_estado
WHERE utimestamp != 0 AND id_agente IN
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled IS FALSE)
AND id_agente_modulo IN
(SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_module_group = %d AND disabled IS FALSE AND delete_pending IS FALSE)
GROUP BY estado";
break;
case "oracle":
$sql = "SELECT COUNT(id_agente) AS count, estado
FROM tagente_estado
WHERE utimestamp != 0 AND id_agente IN
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND (disabled IS NOT NULL AND disabled <> 0))
AND id_agente_modulo IN
(SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_module_group = %d AND (disabled IS NOT NULL AND disabled <> 0) AND (delete_pending IS NOT NULL AND delete_pending <> 0))
GROUP BY estado";
break;
}
print_page_header (__("Combined table of agent group and module group"));
@ -134,9 +150,10 @@ function mainModuleGroups() {
$row = array();
array_push($row, printTruncateText($name, 20));
foreach ($modelGroups as $idModelGroup => $modelGroup) {
$query = sprintf($sql,$idAgentGroup, $idModelGroup);
$rowsDB = get_db_all_rows_sql ($query);

View File

@ -65,6 +65,16 @@ function getPandoraDiagnostic(&$systemInfo) {
$systemInfo['keygen_path'] = get_db_sql("SELECT value FROM tupdate_settings WHERE \"key\" = 'keygen_path'");
$systemInfo['current_update'] = get_db_sql("SELECT value FROM tupdate_settings WHERE \"key\" = 'current_update'");
break;
case "oracle":
$systemInfo['db_scheme_version'] = get_db_sql("SELECT value FROM tconfig WHERE token = 'db_scheme_version'");
$systemInfo['db_scheme_build'] = get_db_sql("SELECT value FROM tconfig WHERE token = 'db_scheme_build'");
$systemInfo['enterprise_installed'] = get_db_sql("SELECT value FROM tconfig WHERE token = 'enterprise_installed'");
$systemInfo['db_maintance'] = get_db_sql ("SELECT value FROM tconfig WHERE token = 'db_maintance'");
$systemInfo['customer_key'] = get_db_sql("SELECT value FROM tupdate_settings WHERE key = 'customer_key';");
$systemInfo['updating_code_path'] = get_db_sql("SELECT value FROM tupdate_settings WHERE key = 'updating_code_path'");
$systemInfo['keygen_path'] = get_db_sql("SELECT value FROM tupdate_settings WHERE key = 'keygen_path'");
$systemInfo['current_update'] = get_db_sql("SELECT value FROM tupdate_settings WHERE key = 'current_update'");
break;
}
}

View File

@ -47,6 +47,9 @@ function pandora_update_manager_install () {
case 'postgresql':
$sentences = file (EXTENSIONS_DIR.'/update_manager/sql/update_manager.postgreSQL.sql');
break;
case 'oracle':
$sentences = file (EXTENSIONS_DIR.'/update_manager/sql/update_manager.oracle.sql');
break;
}
foreach ($sentences as $sentence) {
$success = process_sql ($sentence);
@ -82,6 +85,13 @@ function pandora_update_manager_uninstall () {
process_sql ('DROP TABLE "tupdate"');
process_sql ('DROP TABLE "tupdate_package"');
break;
case "oracle":
process_sql ('DELETE FROM tconfig WHERE token = \'update_manager_installed\'');
process_sql ('DROP TABLE tupdate_settings');
process_sql ('DROP TABLE tupdate_journal');
process_sql ('DROP TABLE tupdate');
process_sql ('DROP TABLE tupdate_package');
break;
}
}

View File

@ -48,6 +48,9 @@ function um_db_update_setting ($key, $value = '') {
case "postgresql":
$result = get_db_value('COUNT(*)', DB_PREFIX.'tupdate_settings', '"key"', $key);
break;
case "oracle":
$result = get_db_value('COUNT(*)', DB_PREFIX.'tupdate_settings', 'key', $key);
break;
}
if ($result === false) {
@ -63,6 +66,9 @@ function um_db_update_setting ($key, $value = '') {
case "postgresql":
$result = process_sql_update(DB_PREFIX.'tupdate_settings', array('value' => $value), array('"key"' => $key));
break;
case "oracle":
$result = process_sql_update(DB_PREFIX.'tupdate_settings', array('value' => $value), array('key' => $key));
break;
}
if ($result === false) {
@ -78,6 +84,9 @@ function um_db_update_setting ($key, $value = '') {
case "postgresql":
$result = process_sql_insert(DB_PREFIX.'tupdate_settings', array('"key"' => $key, '"value"' => $value));
break;
case "oracle":
$result = process_sql_insert(DB_PREFIX.'tupdate_settings', array('key' => $key, 'value' => $value));
break;
}
if ($result === false) {
@ -277,6 +286,14 @@ function um_db_get_all_package_logs ($ip = '', $order_by = 'timestamp', $limit =
FROM '.DB_PREFIX.'tupdate_package_log
WHERE ip_address LIKE \'%'.$ip.'%\' ORDER BY '.$order_by.' DESC LIMIT '.$limit.' OFFSET '.$offset);
break;
case "oracle":
$set = array ();
$set['ip_address'] = '%' . $ip . '%';
$set['order'] = $order_by . ' DESC';
$set['limit'] = $limit;
$set['offset'] = $offset;
$result = get_db_num_rows(oracle_recode_query ('SELECT * FROM '.DB_PREFIX.'tupdate_package_log WHERE', $set, 'AND', true));
break;
}
@ -294,6 +311,13 @@ function um_db_get_all_package_logs ($ip = '', $order_by = 'timestamp', $limit =
FROM '.DB_PREFIX.'tupdate_package_log
WHERE ip_address LIKE \'%'.$ip.'%\' ORDER BY '.$order_by.' DESC LIMIT '.$limit.' OFFSET '.$offset);
break;
case "oracle":
$result = oracle_recode_query ('SELECT * FROM '.DB_PREFIX.'tupdate_package_log WHERE', $set, 'AND', false);
// Delete rnum row generated by oracle_recode_query() function
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
break;
}
$cont = 0;
@ -373,6 +397,9 @@ function um_db_get_component ($name) {
case "postgresql":
$result = process_sql('SELECT COUNT(*) FROM '.DB_PREFIX.'tupdate_component WHERE name = \''.$name.'\' LIMIT 1');
break;
case "oracle":
$result = process_sql('SELECT COUNT(*) FROM '.DB_PREFIX.'tupdate_component WHERE name = \''.$name.'\' AND rownum < 2');
break;
}
if ($result === false) {
@ -387,6 +414,9 @@ function um_db_get_component ($name) {
case "postgresql":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_component WHERE name = \''.$name.'\' LIMIT 1');
break;
case "oracle":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_component WHERE name = \''.$name.'\' AND rownum < 2');
break;
}
$component = um_std_from_result($result);
@ -496,6 +526,9 @@ function um_db_get_component_db ($id_component_db) {
case "postgresql":
$result = process_sql('SELECT COUNT(*) FROM '.DB_PREFIX.'tupdate_component_db WHERE id = \''.$id_component_db.'\' LIMIT 1');
break;
case "oracle":
$result = process_sql('SELECT COUNT(*) FROM '.DB_PREFIX.'tupdate_component_db WHERE id = \''.$id_component_db.'\' AND rownum < 2');
break;
}
if ($result === false) {
@ -510,6 +543,9 @@ function um_db_get_component_db ($id_component_db) {
case "postgresql":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_component_db WHERE id = \''.$id_component_db.'\' LIMIT 1');
break;
case "oracle":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_component_db WHERE id = \''.$id_component_db.'\' AND rownum < 2');
break;
}
$component = um_std_from_result($result);
@ -525,6 +561,7 @@ function um_db_get_database_components ($component_name) {
$result = process_sql('SELECT COUNT(*) FROM '.DB_PREFIX.'tupdate_component_db WHERE component = "'. $component_name.'" ORDER BY `order` ASC');
break;
case "postgresql":
case "oracle":
$result = process_sql('SELECT COUNT(*) FROM '.DB_PREFIX.'tupdate_component_db WHERE component = \''. $component_name.'\' ORDER BY "order" ASC');
break;
}
@ -539,6 +576,7 @@ function um_db_get_database_components ($component_name) {
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_component_db WHERE component = "'. $component_name.'" ORDER BY `order` ASC');
break;
case "postgresql":
case "oracle":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_component_db WHERE component = \''. $component_name.'\' ORDER BY "order" ASC');
break;
}
@ -619,6 +657,9 @@ function um_db_get_auth ($id_auth) {
case "postgresql":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_auth WHERE id = \''.$id_auth.'\' LIMIT 1');
break;
case "oracle":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_auth WHERE id = \''.$id_auth.'\' AND rownum < 2');
break;
}
if ($result === false) {
@ -665,6 +706,9 @@ function um_db_check_auth ($client_key, $subscription_limit) {
case "postgresql":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_auth WHERE client_key = \''.$client_key.'\' LIMIT 1');
break;
case "oracle":
$result = process_sql('SELECT * FROM '.DB_PREFIX.'tupdate_auth WHERE client_key = \''.$client_key.'\' AND rownum < 2');
break;
}
if ($result === false) {

View File

@ -399,6 +399,10 @@ function um_client_update_from_paths ($file_paths, $tmpDir, $num_package, $type)
$sql_schema_file = '01_package_'.$num_package.'_schema.postgreSQL.sql';
$sql_data_file = '02_package_'.$num_package.'_data.postgreSQL.sql';
break;
case "oracle":
$sql_schema_file = '01_package_'.$num_package.'_schema.oracle.sql';
$sql_data_file = '02_package_'.$num_package.'_data.oracle.sql';
break;
}
foreach($file_paths as $file_name => $paths) {

View File

@ -67,6 +67,9 @@ function um_component_database_get_all_tables () {
case "postgresql":
$result = process_sql('SELECT table_name FROM information_schema.tables WHERE table_schema = \'public\';');
break;
case "oracle":
$result = process_sql('SELECT table_name FROM user_tables');
break;
}
if ($result === false) {
@ -77,7 +80,12 @@ function um_component_database_get_all_tables () {
$cont = 0;
$tables = array();
foreach($result as $table) {
if ($config["dbtype"] == 'oracle') {
$tables[] = $table['table_name'];
}
else {
$tables[] = $table[0];
}
}
return $tables;
@ -108,8 +116,21 @@ function um_component_database_get_table_fields ($table_name) {
$result = process_sql('SHOW COLUMNS FROM '.$table_name.' WHERE `Key` != "PRI"');
break;
case "postgresql":
//TODO: verificar que se extraen todos los campos menos clave primaria
$result = process_sql("SELECT * FROM pg_indexes WHERE tablename = '" . $table_name . "'");
break;
case "oracle":
$result = process_sql("SELECT cols1.column_name as Fields, cols1.data_type as Type,
CASE WHEN (cols1.nullable = 'Y') THEN 'YES' ELSE 'NO' END as \"Null\",
cols1.data_default as \"Default\", '' as Extra
FROM user_tab_columns cols1
WHERE cols1.table_name ='".$table_name."'
AND cols1.column_name NOT IN (select distinct usr.column_name
from user_cons_columns usr, user_constraints co
where usr.constraint_name = co.constraint_name and
constraint_type = 'P' and co.table_name = '" . $table_name . "')
order by cols1.column_id");
break;
}
if ($result === false) {
@ -179,6 +200,7 @@ function um_component_get_all_blacklisted ($component) {
$result = process_sql('SELECT COUNT(name) FROM '.DB_PREFIX.'tupdate_component_blacklist WHERE component = "'.$component->name.'"');
break;
case "postgresql":
case "oracle":
$result = process_sql('SELECT COUNT(name)
FROM '.DB_PREFIX.'tupdate_component_blacklist
WHERE component = \''.$component->name.'\'');
@ -195,6 +217,7 @@ function um_component_get_all_blacklisted ($component) {
$result = process_sql('SELECT name FROM '.DB_PREFIX.'tupdate_component_blacklist WHERE component = "'.$component->name.'"');
break;
case "postgresql":
case "oracle":
$result = process_sql('SELECT name
FROM '.DB_PREFIX.'tupdate_component_blacklist
WHERE component = \''.$component->name.'\'');
@ -223,6 +246,7 @@ function um_component_is_blacklisted ($component, $name) {
$result = process_sql('SELECT COUNT(*) AS blacklisted FROM '.DB_PREFIX.'tupdate_component_blacklist WHERE component = "'.$component->name.'" AND name = "'.$name.'"');
break;
case "postgresql":
case "oracle":
$result = process_sql('SELECT COUNT(*) AS blacklisted
FROM '.DB_PREFIX.'tupdate_component_blacklist
WHERE component = \''.$component->name.'\' AND name = \''.$name.'\'');

View File

@ -29,6 +29,9 @@ function um_update_get_last_from_filename ($component_name, $filename) {
case "postgresql":
$result = process_sql('SELECT COUNT(*) FROM '.DB_PREFIX.'tupdate WHERE component = \''.$component_name.'\' AND filename = \''.$component->relative_path.$filename.'\' ORDER BY id DESC LIMIT 1');
break;
case "oracle":
$result = process_sql('SELECT COUNT(*) FROM '.DB_PREFIX.'tupdate WHERE (component = \''.$component_name.'\' AND filename = \''.$component->relative_path.$filename.'\') AND rownum < 2 ORDER BY id DESC');
break;
}
if ($result === false) {
@ -46,6 +49,12 @@ function um_update_get_last_from_filename ($component_name, $filename) {
WHERE component = \''.$component_name.'\'
AND filename = \''.$component->relative_path.$filename.'\' ORDER BY id DESC LIMIT 1');
break;
case "oracle":
$result = process_sql('SELECT *
FROM '.DB_PREFIX.'tupdate
WHERE (component = \''.$component_name.'\'
AND filename = \''.$component->relative_path.$filename.'\') AND rownum < 2 ORDER BY id DESC');
break;
}
$update = um_std_from_result($result);
@ -171,6 +180,9 @@ function um_db_create_update ($type, $component_name, $id_package, $update, $db_
case "postgresql":
$values['data'] = um_data_encode('INSERT INTO "'.$component_db->table_name.'" ("'.implode('", "', array_keys (get_object_vars ($db_data))).'") VALUES (\''.implode('\',\'', get_object_vars ($db_data)).'\')');
break;
case "oracle":
$values['data'] = um_data_encode('INSERT INTO '.$component_db->table_name.' ('.implode(', ', array_keys (get_object_vars ($db_data))).') VALUES (\''.implode('\',\'', get_object_vars ($db_data)).'\')');
break;
}
break;
case 'db_schema':

View File

@ -72,6 +72,11 @@ function get_user_key ($settings) {
$m = (int) get_db_value ('COUNT("id_agente_modulo")', 'tagente_modulo',
'disabled', 0);
break;
case 'oracle':
$n = (int) get_db_value ('COUNT(id_agente)', 'tagente', 'disabled', 0);
$m = (int) get_db_value ('COUNT(id_agente_modulo)', 'tagente_modulo',
'disabled', 0);
break;
}
$user_key = array ('A' => $n, 'M' => $m, 'B' => $build_version, 'P' => $pandora_version);

View File

@ -0,0 +1,28 @@
CREATE TABLE tupdate_settings ( key VARCHAR2(255) default '' PRIMARY KEY, value VARCHAR2(255) default '')
/INSERT INTO tupdate_settings VALUES ('current_update', '0')
/INSERT INTO tupdate_settings VALUES ('customer_key', 'PANDORA-FREE')
/INSERT INTO tupdate_settings VALUES ('keygen_path', '/usr/share/pandora/util/keygen')
/INSERT INTO tupdate_settings VALUES ('update_server_host', 'www.artica.es')
/INSERT INTO tupdate_settings VALUES ('update_server_port', '80')
/INSERT INTO tupdate_settings VALUES ('update_server_path', '/pandoraupdate321/server.php')
/INSERT INTO tupdate_settings VALUES ('updating_binary_path', 'Path where the updated binary files will be stored')
/INSERT INTO tupdate_settings VALUES ('updating_code_path', 'Path where the updated code is stored')
/INSERT INTO tupdate_settings VALUES ('dbname', '')
/INSERT INTO tupdate_settings VALUES ('dbhost', '')
/INSERT INTO tupdate_settings VALUES ('dbpass', '')
/INSERT INTO tupdate_settings VALUES ('dbuser', '')
/INSERT INTO tupdate_settings VALUES ('proxy', '')
/INSERT INTO tupdate_settings VALUES ('proxy_port', '')
/INSERT INTO tupdate_settings VALUES ('proxy_user', '')
/INSERT INTO tupdate_settings VALUES ('proxy_pass', '')
CREATE TABLE tupdate_package( id NUMBER(10, 0) NOT NULL PRIMARY KEY, timestamp TIMESTAMP default NULL, description VARCHAR2(255) default '')
CREATE SEQUENCE tupdate_package_s INCREMENT BY 1 START WITH 1
CREATE OR REPLACE TRIGGER tupdate_package_inc BEFORE INSERT ON tupdate_package REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tupdate_package_s.nextval INTO :NEW.ID FROM dual; END;
CREATE TABLE tupdate ( id NUMBER(10, 0) NOT NULL PRIMARY KEY, type VARCHAR2(15), id_update_package NUMBER(10, 0) default 0 REFERENCES tupdate_package(id) ON DELETE CASCADE, filename VARCHAR2(250) default '', checksum VARCHAR2(250) default '', previous_checksum VARCHAR2(250) default '', svn_version NUMBER(10, 0) default 0, data CLOB default '', data_rollback CLOB default '', description CLOB default '', db_table_name VARCHAR2(140) default '', db_field_name VARCHAR2(140) default '', db_field_value VARCHAR2(1024) default '', CONSTRAINT tupdate_type_cons CHECK (type IN ('code', 'db_data', 'db_schema', 'binary')))
CREATE OR REPLACE TRIGGER tupdate_update AFTER UPDATE OF ID ON tupdate_package FOR EACH ROW BEGIN UPDATE tupdate SET ID_UPDATE_PACKAGE = :NEW.ID WHERE ID_UPDATE_PACKAGE = :OLD.ID; END;
CREATE SEQUENCE tupdate_s INCREMENT BY 1 START WITH 1
CREATE OR REPLACE TRIGGER tupdate_inc BEFORE INSERT ON tupdate REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tupdate_s.nextval INTO :NEW.ID FROM dual; END;
CREATE TABLE tupdate_journal ( id NUMBER(10, 0) NOT NULL PRIMARY KEY, id_update NUMBER(10, 0) default 0 REFERENCES tupdate(id) ON DELETE CASCADE)
CREATE SEQUENCE tupdate_journal_s INCREMENT BY 1 START WITH 1
CREATE OR REPLACE TRIGGER tupdate_journal_inc BEFORE INSERT ON tupdate_journal REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tupdate_journal_s.nextval INTO :NEW.ID FROM dual; END;
CREATE OR REPLACE TRIGGER tupdate_journal_update AFTER UPDATE OF ID ON tupdate FOR EACH ROW BEGIN UPDATE tupdate_journal SET ID = :NEW.ID WHERE ID = :OLD.ID; END;

View File

@ -39,6 +39,10 @@ function users_extension_main_god ($god = true) {
$sql = "SELECT id_usuario, ip_origen, fecha, accion
FROM tsesion
WHERE descripcion = 'Logged in' AND utimestamp > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - 3600) GROUP BY id_usuario, ip_origen, accion";
case "oracle":
$sql = "SELECT id_usuario, ip_origen, fecha, accion
FROM tsesion
WHERE to_char(descripcion) = 'Logged in' AND utimestamp > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - 3600) GROUP BY id_usuario, ip_origen,fecha, accion";
break;
}

View File

@ -142,6 +142,17 @@ switch ($config["dbtype"]) {
render_info_data ("SELECT value FROM tupdate_settings WHERE \"key\" = 'keygen_path'", "Keygen path");
render_info_data ("SELECT value FROM tupdate_settings WHERE \"key\" = 'current_update'", "Current Update #");
break;
case "oracle":
render_info_data ("SELECT value FROM tconfig WHERE token = 'db_scheme_version'", "DB Schema Version");
render_info_data ("SELECT value FROM tconfig WHERE token = 'db_scheme_build'", "DB Schema Build");
render_info_data ("SELECT value FROM tconfig WHERE token = 'enterprise_installed'", "Enterprise installed");
render_row (get_db_sql ("SELECT value FROM tconfig WHERE token = 'db_maintance'"), "PandoraDB Last run");
render_info_data ("SELECT value FROM tupdate_settings WHERE key = 'customer_key'", "Update Key");
render_info_data ("SELECT value FROM tupdate_settings WHERE key = 'updating_code_path'", "Updating code path");
render_info_data ("SELECT value FROM tupdate_settings WHERE key = 'keygen_path'", "Keygen path");
render_info_data ("SELECT value FROM tupdate_settings WHERE key = 'current_update'", "Current Update #");
break;
}
if ($console_mode == 0) {

View File

@ -35,7 +35,16 @@ print_page_header (__('Welcome to Pandora FMS Web Console'));
echo '<div style="width:350px; float:left; padding-right: 30px;" id="leftcolumn">';
echo '<h2>' . __('Site news') . '</h2>';
$sql = "SELECT subject,timestamp,text,author FROM tnews ORDER by timestamp DESC LIMIT 3";
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = "SELECT subject,timestamp,text,author FROM tnews ORDER by timestamp DESC LIMIT 3";
break;
case "oracle":
$sql = "SELECT subject,timestamp,text,author FROM tnews where rownum <= 3 ORDER by timestamp DESC";
break;
}
$news = get_db_all_rows_sql ($sql);
if ($news !== false) {
echo '<table cellpadding="4" cellspacing="4" class="databox">';
@ -167,6 +176,12 @@ switch ($config["dbtype"]) {
WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - 604800)
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
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"]);
break;
}
$sessions = get_db_all_rows_sql ($sql);
@ -179,6 +194,7 @@ foreach ($sessions as $session) {
switch ($config["dbtype"]) {
case "mysql":
case "oracle":
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;

View File

@ -92,15 +92,30 @@ $filter = 'WHERE 1 = 1';
if ($tipo_log != 'all') {
$filter .= sprintf (" AND accion = '%s'", $tipo_log);
}
switch ($config['dbtype']) {
case "mysql":
if ($user_filter != 'all') {
$filter .= sprintf(' AND ID_usuario = "%s"', $user_filter);
}
if ($user_filter != 'all') {
$filter .= sprintf(' AND ID_usuario = "%s"', $user_filter);
}
$filter .= ' AND (accion LIKE "%' . $filter_text . '%" OR descripcion LIKE "%' . $filter_text . '%")';
$filter .= ' AND (accion LIKE "%' . $filter_text . '%" OR descripcion LIKE "%' . $filter_text . '%")';
if ($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);
}
if ($filter_ip != '') {
$filter .= sprintf(' AND IP_origen LIKE "%s"', $filter_ip);
$filter .= ' AND (accion LIKE \'%' . $filter_text . '%\' OR descripcion LIKE \'%' . $filter_text . '%\')';
if ($filter_ip != '') {
$filter .= sprintf(' AND IP_origen LIKE \'%s\'', $filter_ip);
}
break;
}
if ($filter_hours_old != 0) {
@ -111,6 +126,9 @@ if ($filter_hours_old != 0) {
case "postgresql":
$filter .= ' AND fecha >= DATE_ADD(NOW(), INTERVAL - \'' . $filter_hours_old . ' HOUR \')';
break;
case "oracle":
$filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \'' . $filter_hours_old . '\' HOUR)';
break;
}
}
@ -127,9 +145,24 @@ switch ($config["dbtype"]) {
case "postgresql":
$sql = sprintf ("SELECT * FROM tsesion %s ORDER BY fecha DESC LIMIT %d OFFSET %d", $filter, $config["block_size"], $offset);
break;
case "oracle":
$set = array();
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$sql = sprintf ("SELECT * FROM tsesion %s ORDER BY fecha DESC", $filter);
$result = oracle_recode_query ($sql, $set);
break;
}
$result = get_db_all_rows_sql ($sql);
// Delete rnum row generated by oracle_recode_query() function
if (($config["dbtype"] == 'oracle') && ($result !== false)){
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
}
if (empty ($result)) {
$result = array ();
}
@ -193,22 +226,62 @@ foreach ($result as $row) {
$iterator++;
$data = array ();
$data[0] = $row["ID_usuario"];
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$data[0] = $row["ID_usuario"];
break;
case "oracle":
$data[0] = $row["id_usuario"];
break;
}
$data[1] = $row["accion"];
$data[2] = $row["fecha"];
$data[3] = $row["IP_origen"];
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$data[3] = $row["IP_origen"];
break;
case "oracle":
$data[3] = $row["ip_origen"];
break;
}
$data[4] = $row["descripcion"];
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$data[5] = enterprise_hook('cell1EntepriseAudit', array($row['ID_sesion']));
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$data[5] = enterprise_hook('cell1EntepriseAudit', array($row['ID_sesion']));
break;
case "oracle":
$data[5] = enterprise_hook('cell1EntepriseAudit', array($row['id_sesion']));
break;
}
}
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$data[6] = enterprise_hook('cell2EntepriseAudit', array($row['ID_sesion']));
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$data[6] = enterprise_hook('cell2EntepriseAudit', array($row['ID_sesion']));
break;
case "oracle":
$data[6] = enterprise_hook('cell2EntepriseAudit', array($row['id_sesion']));
break;
}
}
array_push ($table->data, $data);
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
enterprise_hook('rowEnterpriseAudit', array($table, &$iterator, $row['ID_sesion']));
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
enterprise_hook('rowEnterpriseAudit', array($table, &$iterator, $row['ID_sesion']));
break;
case "oracle":
enterprise_hook('rowEnterpriseAudit', array($table, &$iterator, $row['id_sesion']));
break;
}
}
}

View File

@ -13,6 +13,8 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
// Load global vars
if (!isset ($id_agente)) {
die ("Not Authorized");
@ -135,7 +137,15 @@ echo '</div></form>';
// ==========================
echo "<h3>".__('Assigned modules')."</h3>";
$sql = sprintf ("SELECT * FROM tagente_modulo WHERE id_agente = %d AND delete_pending = false ORDER BY id_module_group, nombre", $id_agente);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ("SELECT * FROM tagente_modulo WHERE id_agente = %d AND delete_pending = false ORDER BY id_module_group, nombre", $id_agente);
break;
case "oracle":
$sql = sprintf ("SELECT * FROM tagente_modulo WHERE id_agente = %d AND (delete_pending <> 1 AND delete_pending IS NOT NULL) ORDER BY id_module_group, dbms_lob.substr(nombre,4000,1)", $id_agente);
break;
}
$result = get_db_all_rows_sql ($sql);
if ($result === false) {
$result = array ();

View File

@ -690,6 +690,14 @@ if ($create_module) {
$id_module = (int) get_parameter ('id_module');
switch ($config["dbtype"]) {
case "oracle":
if (empty($description) || !isset($description)) {
$description=' ';
}
break;
}
$values = array ('id_tipo_modulo' => $id_module_type,
'descripcion' => $description,
'max' => $max,

View File

@ -199,6 +199,18 @@ if ($ag_group > 0) {
ORDER BY %s %s LIMIT %d OFFSET %d',
$ag_group, $search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
break;
case "oracle":
$set = array ();
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo = %d
%s
ORDER BY %s %s',
$ag_group, $search_sql, $order['field'], $order['order']);
$sql = oracle_recode_query ($sql, $set);
break;
}
}
else {
@ -218,6 +230,15 @@ else {
FROM tagente WHERE 1=1 %s
ORDER BY %s %s LIMIT %d OFFSET %d', $search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
break;
case "oracle":
$set = array ();
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$sql = sprintf ('SELECT *
FROM tagente WHERE 1=1 %s
ORDER BY %s %s', $search_sql, $order['field'], $order['order']);
$sql = oracle_recode_query ($sql, $set);
break;
}
}
else {
@ -249,12 +270,32 @@ else {
implode (',', array_keys (get_user_groups ())),
$search_sql, $order['field'], $order['order'], $config["block_size"], $offset);
break;
case "oracle":
$set = array ();
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s %s',
implode (',', array_keys (get_user_groups ())),
$search_sql, $order['field'], $order['order']);
$sql = oracle_recode_query ($sql, $set);
break;
}
}
}
$agents = get_db_all_rows_sql ($sql);
// Delete rnum row generated by oracle_recode_query() function
if (($config['dbtype'] == 'oracle') && ($agents !== false)) {
for ($i=0; $i < count($agents); $i++) {
unset($agents[$i]['rnum']);
}
}
// Prepare pagination
pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset);
echo "<div style='height: 20px'> </div>";

View File

@ -30,10 +30,10 @@ echo "<tr><td class='datos'>";
// Check if there is at least one server of each type available to assign that
// kind of modules. If not, do not show server type in combo
$network_available = get_db_sql ("SELECT count(*) from tserver where server_type = 1"); //POSTGRESQL COMPATIBLE
$wmi_available = get_db_sql ("SELECT count(*) from tserver where server_type = 6"); //POSTGRESQL COMPATIBLE
$plugin_available = get_db_sql ("SELECT count(*) from tserver where server_type = 4"); //POSTGRESQL COMPATIBLE
$prediction_available = get_db_sql ("SELECT count(*) from tserver where server_type = 5"); //POSTGRESQL COMPATIBLE
$network_available = get_db_sql ("SELECT count(*) from tserver where server_type = 1"); //POSTGRESQL AND ORACLE COMPATIBLE
$wmi_available = get_db_sql ("SELECT count(*) from tserver where server_type = 6"); //POSTGRESQL AND ORACLE COMPATIBLE
$plugin_available = get_db_sql ("SELECT count(*) from tserver where server_type = 4"); //POSTGRESQL AND ORACLE COMPATIBLE
$prediction_available = get_db_sql ("SELECT count(*) from tserver where server_type = 5"); //POSTGRESQL AND ORACLE COMPATIBLE
// Development mode to use all servers
if ($develop_bypass) {
@ -107,20 +107,32 @@ if ($multiple_delete) {
// First delete from tagente_modulo -> if not successful, increment
// error. NOTICE that we don't delete all data here, just marking for deletion
// and delete some simple data.
$status = '';
if (process_sql("UPDATE tagente_modulo
SET nombre = 'pendingdelete', disabled = 1, delete_pending = 1 WHERE id_agente_modulo = ".$id_agent_module_del) === false)
SET nombre = 'pendingdelete', disabled = 1, delete_pending = 1 WHERE id_agente_modulo = ".$id_agent_module_del, "affected_rows", '', true, $status, false) === false)
$error++;
$result = process_sql_delete('tagente_estado', array('id_agente_modulo' => $id_agent_module_del));
if ($result === false)
$error++;
$result = process_sql_delete('tagente_datos_inc', array('id_agente_modulo' => $id_agent_module_del));
if ($result === false)
$error++;
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$result = process_sql_delete('tagente_estado', array('id_agente_modulo' => $id_agent_module_del));
if ($result === false)
$error++;
$result = process_sql_delete('tagente_datos_inc', array('id_agente_modulo' => $id_agent_module_del));
if ($result === false)
$error++;
break;
case "oracle":
$result = temp_sql_delete('tagente_estado', 'id_agente_modulo', $id_agent_module_del);
if ($result === false)
$error++;
$result = temp_sql_delete('tagente_datos_inc', 'id_agente_modulo', $id_agent_module_del);
if ($result === false)
$error++;
break;
}
//Check for errors
if ($error != 0) {
process_sql_rollback ();
@ -160,11 +172,27 @@ switch ($sortField) {
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
case "oracle":
$order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'ASC');
break;
}
break;
case 'down':
$selectNameDown = $selected;
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'DESC');
break;
case "oracle":
$order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'DESC');
break;
}
break;
}
break;
@ -213,7 +241,15 @@ switch ($sortField) {
$selectTypeDown = '';
$selectIntervalUp = '';
$selectIntervalDown = '';
$order[] = array('field' => 'nombre', 'order' => 'ASC');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$order[] = array('field' => 'dbms_lob.substr(nombre,4000,1)', 'order' => 'ASC');
break;
case "oracle":
$order[] = array('field' => 'dbms_lob.substr(nombre,4000,1)', 'order' => 'ASC');
break;
}
break;
}

View File

@ -72,6 +72,7 @@ if (is_ajax ()) {
$component['type'] = get_db_value_sql('SELECT id_tipo FROM ttipo_modulo WHERE nombre LIKE "' . $typeName . '"');
break;
case "postgresql":
case "oracle":
$component['type'] = get_db_value_sql('SELECT id_tipo FROM ttipo_modulo WHERE nombre LIKE \'' . $typeName . '\'');
break;
}
@ -253,7 +254,6 @@ switch ($moduletype) {
case "networkserver":
case 2:
$moduletype = 2;
$categories = array (3, 4, 5);
require ('module_manager_editor_common.php');
require ('module_manager_editor_network.php');

View File

@ -144,6 +144,11 @@ if ($create_downtime || $update_downtime) {
FROM \"tplanned_downtime\" WHERE \"id\" = %d",
$id_downtime);
break;
case "oracle":
$sql = sprintf ("SELECT id, name, description, date_from, date_to, id_group
FROM tplanned_downtime WHERE id = %d",
$id_downtime);
break;
}
$result = get_db_row_sql ($sql);

View File

@ -134,9 +134,19 @@ echo '</form>';
unset ($table);
$where = '';
if ($search != '')
$where = sprintf (' AND (description LIKE "%%%s%%" OR name LIKE "%%%s%%")',
$search, $search);
if ($search != '') {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$where = sprintf (' AND (description LIKE "%%%s%%" OR name LIKE "%%%s%%")',
$search, $search);
break;
case "oracle":
$where = sprintf (' AND (description LIKE \'%%%s%%\' OR name LIKE \'%%%s%%\')',
$search, $search);
break;
}
}
if ($id_agent)
$agents = array ($id_agent => $id_agent);
@ -168,11 +178,31 @@ $table->head[3] = __('Delete');
$id_alerts = false;
if (count($agents)) {
$sql = sprintf ('SELECT id FROM talert_compound
WHERE id_agent in (%s)%s LIMIT %d OFFSET %d',
implode (',', array_keys ($agents)), $where,
$config['block_size'], get_parameter ('offset'));
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT id FROM talert_compound
WHERE id_agent in (%s)%s LIMIT %d OFFSET %d',
implode (',', array_keys ($agents)), $where,
$config['block_size'], get_parameter ('offset'));
break;
case "oracle":
$set = array();
$set['offset'] = get_parameter ('offset');
$set['limit'] = $config['block_size'];
$sql = sprintf ('SELECT id FROM talert_compound
WHERE id_agent in (%s)%s',
implode (',', array_keys ($agents)), $where);
$sql = oracle_recode_query($sql, $set);
break;
}
$id_alerts = get_db_all_rows_sql ($sql);
if (($config["dbtype"] == 'oracle') && ($id_alerts !== false)) {
for ($i=0; $i < count($id_alerts); $i++) {
unset($id_alerts[$i]['rnum']);
}
}
}
if ($id_alerts === false)

View File

@ -65,7 +65,16 @@ $form_filter .= "</td>\n";
$form_filter .= "</tr>\n";
$form_filter .= "<tr>\n";
$temp = get_db_all_rows_sql("SELECT id, name FROM talert_actions;");
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$temp = get_db_all_rows_sql("SELECT id, name FROM talert_actions;");
break;
case "oracle":
$temp = get_db_all_rows_sql("SELECT id, name FROM talert_actions");
break;
}
$arrayActions = array();
if (is_array($temp)) {
foreach ($temp as $actionElement) {
@ -126,10 +135,22 @@ if ($searchFlag) {
$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE '%" . trim($moduleName) . "%')";
//if ($agentID != -1)
//$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = " . $agentID . ")";
if (strlen(trim($agentName)) > 0)
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente AS t1 INNER JOIN tagente_modulo AS t2 ON t1.id_agente = t2.id_agente
WHERE t1.nombre LIKE '" . trim($agentName) . "')";
if (strlen(trim($agentName)) > 0) {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente AS t1 INNER JOIN tagente_modulo AS t2 ON t1.id_agente = t2.id_agente
WHERE t1.nombre LIKE '" . trim($agentName) . "')";
break;
case "oracle":
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente
WHERE t1.nombre LIKE '" . trim($agentName) . "')";
break;
}
}
if ($actionID != -1)
$where .= " AND talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = " . $actionID . ")";
if ($enabledisable != -1)

View File

@ -265,7 +265,7 @@ else {
}
echo $messageAction;
switch ($tab) {
case 'list':
if ($group == 0) {

View File

@ -49,8 +49,21 @@ switch ($config["dbtype"]) {
FROM tagente
WHERE ceil(date_part('epoch', ultimo_contacto)) < ceil(date_part('epoch', NOW())) - (intervalo * 2)");
break;
case "oracle":
$stat_uknown = get_db_sql ("SELECT COUNT(*)
FROM tagente
WHERE CAST(ultimo_contacto AS DATE) < SYSDATE - (intervalo * 2)");
break;
}
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$stat_noninit = get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE utimestamp = 0;");
break;
case "oracle":
$stat_noninit = get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE utimestamp = 0");
break;
}
$stat_noninit = get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE utimestamp = 0;");
// Todo: Recalculate this data dinamically using the capacity and total agents

View File

@ -136,10 +136,21 @@ if ($update_group) {
/*Check if name field is empty*/
if( $name != "") {
$sql = sprintf ('UPDATE tgrupo SET nombre = "%s",
icon = "%s", disabled = %d, parent = %d, custom_id = "%s", propagate = %d, id_skin = %d
WHERE id_grupo = %d',
$name, substr ($icon, 0, -4), !$alerts_enabled, $id_parent, $custom_id, $propagate, $skin, $id_group);
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ('UPDATE tgrupo SET nombre = "%s",
icon = "%s", disabled = %d, parent = %d, custom_id = "%s", propagate = %d, id_skin = %d
WHERE id_grupo = %d',
$name, substr ($icon, 0, -4), !$alerts_enabled, $id_parent, $custom_id, $propagate, $skin, $id_group);
break;
case "postgresql":
case "oracle":
$sql = sprintf ('UPDATE tgrupo SET nombre = \'%s\',
icon = \'%s\', disabled = %d, parent = %d, custom_id = \'%s\', propagate = %d, id_skin = %d
WHERE id_grupo = %d',
$name, substr ($icon, 0, -4), !$alerts_enabled, $id_parent, $custom_id, $propagate, $skin, $id_group);
break;
}
$result = process_sql ($sql);
} else {
$result = false;

View File

@ -79,6 +79,18 @@ if ($export_profile) {
AND components.id_group = comp_group.id_sg
AND tpc.id_np = %d", $id);
break;
case "oracle":
$sql = sprintf ("
SELECT components.name, components.description, components.type, components.max, components.min, components.module_interval,
components.tcp_port, components.tcp_send, components.tcp_rcv, components.snmp_community, components.snmp_oid,
components.id_module_group, components.id_modulo, components.plugin_user, components.plugin_pass, components.plugin_parameter,
components.max_timeout, components.history_data, components.min_warning, components.max_warning, components.min_critical,
components.max_critical, components.min_ff_event, comp_group.name AS group_name
FROM tnetwork_component AS components, tnetwork_profile_component AS tpc, tnetwork_component_group AS comp_group
WHERE tpc.id_nc = components.id_nc
AND components.id_group = comp_group.id_sg
AND tpc.id_np = %d", $id);
break;
}
$components = get_db_all_rows_sql ($sql);

View File

@ -151,6 +151,11 @@ if ($id_np > 0) {
FROM tnetwork_profile_component AS npc, tnetwork_component AS nc
WHERE npc.id_nc = nc.id_nc AND npc.id_np = %d", $id_np);
break;
case "oracle":
$sql = sprintf ("SELECT npc.id_nc AS component_id, nc.name, nc.type, nc.description, nc.id_group AS \"group\"
FROM tnetwork_profile_component npc, tnetwork_component nc
WHERE npc.id_nc = nc.id_nc AND npc.id_np = %d", $id_np);
break;
}
$result = get_db_all_rows_sql ($sql);

View File

@ -386,6 +386,7 @@ print_input_hidden('id_item', $idItem);
$query_sql = 'SELECT id_graph, name FROM tgraph WHERE private = 0 OR (private = 1 AND id_user = "'.$config["id_user"].'")';
break;
case "postgresql":
case "oracle":
$query_sql = 'SELECT id_graph, name FROM tgraph WHERE private = 0 OR (private = 1 AND id_user = \''.$config["id_user"].'\')';
break;
}

View File

@ -135,6 +135,16 @@ switch ($config["dbtype"]) {
ORDER BY "order"
LIMIT ' . $config["block_size"] . ' OFFSET ' . $offset);
break;
case "oracle":
$set = array();
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$items = oracle_recode_query ('SELECT * FROM treport_content WHERE ' . $where . ' AND id_report = ' . $idReport . ' ORDER BY "order"', $set, 'AND', false);
// Delete rnum row generated by oracle_recode_query() function
for ($i=0; $i < count($items); $i++) {
unset($items[$i]['rnum']);
}
break;
}
$countItems = get_db_sql('SELECT COUNT(id_rc) FROM treport_content WHERE ' . $where . ' AND id_report = ' . $idReport);
$table = null;

View File

@ -290,6 +290,7 @@ switch ($action) {
FROM treport_content WHERE id_report = ' . $idReport . ';');
break;
case "postgresql":
case "oracle":
$max = get_db_all_rows_sql('SELECT max("order") AS max
FROM treport_content WHERE id_report = ' . $idReport . ';');
break;
@ -305,6 +306,7 @@ switch ($action) {
process_sql_update('treport_content', array('`order`' => $max + 1), array('id_rc' => $idItem));
break;
case "postgresql":
case "oracle":
process_sql_update('treport_content', array('"order"' => $max + 1), array('id_rc' => $idItem));
break;
}
@ -420,6 +422,7 @@ switch ($action) {
$oldOrder = get_db_value_sql('SELECT `order` FROM treport_content WHERE id_rc = ' . $idItem);
break;
case "postgresql":
case "oracle":
$oldOrder = get_db_value_sql('SELECT "order" FROM treport_content WHERE id_rc = ' . $idItem);
break;
}
@ -445,6 +448,10 @@ switch ($action) {
$resultOperationDB = process_sql_update('treport_content',
array('"order"' => $oldOrder), array('"order"' => $newOrder, 'id_report' => $idReport));
break;
case "oracle":
$resultOperationDB = process_sql_update('treport_content',
array('"order"' => $oldOrder), array('"order"' => $newOrder, 'id_report' => $idReport), 'AND', false);
break;
}
if ($resultOperationDB !== false) {
switch ($config["dbtype"]) {
@ -454,6 +461,9 @@ switch ($action) {
case "postgresql":
$resultOperationDB = process_sql_update('treport_content', array('"order"' => $newOrder), array('id_rc' => $idItem));
break;
case "oracle":
$resultOperationDB = process_sql_update('treport_content', array('"order"' => $newOrder), array('id_rc' => $idItem), 'AND', false);
break;
}
if ($resultOperationDB !== false) {
process_sql_commit();

View File

@ -128,6 +128,7 @@ switch ($config["dbtype"]) {
$contents = get_db_all_rows_field_filter ("treport_content", "id_report", $id_report, "`order`");
break;
case "postgresql":
case "oracle":
$contents = get_db_all_rows_field_filter ("treport_content", "id_report", $id_report, '"order"');
break;
}

View File

@ -64,6 +64,9 @@ switch ($config["dbtype"]) {
case "postgresql":
$current_system_lang = get_db_sql ('SELECT "value" FROM tconfig WHERE "token" = \'language\'');
break;
case "oracle":
$current_system_lang = get_db_sql ('SELECT value FROM tconfig WHERE token = \'language\'');
break;
}
if ($current_system_lang == ""){

View File

@ -40,7 +40,16 @@ if ($search_agents) {
}
$filter = array ();
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")';
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")';
break;
case "oracle":
$filter[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\') OR UPPER(direccion) LIKE UPPER(\'%'.$string.'%\') OR UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$filter['id_grupo'] = $id_group;
$agents = get_agents ($filter, array ('id_agente','nombre', 'direccion'));

View File

@ -77,6 +77,9 @@ if ($get_custom_sql) {
case "postgresql":
$sql = get_db_value_filter('"sql"', 'treport_custom_sql', array('id' => $id));
break;
case "oracle":
$sql = get_db_value_filter('sql', 'treport_custom_sql', array('id' => $id));
break;
}
if ($sql === false) {

View File

@ -76,7 +76,6 @@ function process_user_login ($login, $pass) {
// Always authenticate admins against the local database
if (strtolower ($config["auth"]) == 'mysql' || is_user_admin ($login)) {
// Connect to Database
switch ($config["dbtype"]) {
case "mysql":
@ -85,6 +84,9 @@ function process_user_login ($login, $pass) {
case "postgresql":
$sql = sprintf ('SELECT "id_user", "password" FROM "tusuario" WHERE "id_user" = \'%s\'', $login);
break;
case "oracle":
$sql = sprintf ('SELECT id_user, password FROM tusuario WHERE id_user = \'%s\'', $login);
break;
}
$row = get_db_row_sql ($sql);

View File

@ -36,9 +36,9 @@ function oracle_connect_db($host = null, $db = null, $user = null, $pass = null)
}
// Set date and timestamp formats for this session
$datetime_tz_format = oci_parse($config['dbconnection'] , 'alter session set NLS_TIMESTAMP_TZ_FORMAT =\'DD/MM/YYYY HH24:MI:SS\'');
$datetime_format = oci_parse($config['dbconnection'] , 'alter session set NLS_TIMESTAMP_FORMAT =\'DD/MM/YYYY HH24:MI:SS\'');
$date_format = oci_parse($config['dbconnection'] , 'alter session set NLS_DATE_FORMAT =\'DD/MM/YYYY HH24:MI:SS\'');
$datetime_tz_format = oci_parse($config['dbconnection'] , 'alter session set NLS_TIMESTAMP_TZ_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$datetime_format = oci_parse($config['dbconnection'] , 'alter session set NLS_TIMESTAMP_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$date_format = oci_parse($config['dbconnection'] , 'alter session set NLS_DATE_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
oci_execute($datetime_tz_format);
oci_execute($datetime_format);
@ -200,7 +200,7 @@ function oracle_process_sql($sql, $rettype = "affected_rows", $dbconnection = ''
global $sql_cache;
$retval = array();
if ($sql == '')
return false;
@ -220,6 +220,10 @@ function oracle_process_sql($sql, $rettype = "affected_rows", $dbconnection = ''
if ($type[0] == 'INSERT'){
$query = oci_parse($dbconnection, 'begin insert_id(:table_name, :sql, :out); end;');
}
// Prevent execution of insert_id stored procedure
else if ($type[0] == '/INSERT'){
$query = oci_parse($dbconnection, substr($sql,1));
}
else{
$query = oci_parse($dbconnection, $sql);
}
@ -228,14 +232,20 @@ function oracle_process_sql($sql, $rettype = "affected_rows", $dbconnection = ''
if ($type[0] == 'INSERT'){
$query = oci_parse($config['dbconnection'], 'begin insert_id(:table_name, :sql, :out); end;');
}
// Prevent execution of insert_id stored procedure
else if ($type[0] == '/INSERT'){
$query = oci_parse($dbconnection, substr($sql,1));
}
else{
$query = oci_parse($config['dbconnection'], $sql);
}
}
//If query is an insert retrieve Id field
oci_bind_by_name($query,":table_name", $table_name ,32);
oci_bind_by_name($query,":sql", $sql, 1000);
oci_bind_by_name($query,":out", $id, 32);
if ($type[0] == 'INSERT'){
oci_bind_by_name($query,":table_name", $table_name ,32);
oci_bind_by_name($query,":sql", $sql, 1000);
oci_bind_by_name($query,":out", $id, 32);
}
if (!$autocommit){
$result = oci_execute($query, OCI_NO_AUTO_COMMIT);
@ -244,7 +254,7 @@ function oracle_process_sql($sql, $rettype = "affected_rows", $dbconnection = ''
$result = oci_execute($query);
}
$time = microtime (true) - $start;
if ($result === false) {
$backtrace = debug_backtrace ();
$e = oci_error($query);
@ -280,7 +290,29 @@ function oracle_process_sql($sql, $rettype = "affected_rows", $dbconnection = ''
else { //The query IS a select.
add_database_debug_trace ($sql, 0, $rows, array ('time' => $time));
while ($row = oci_fetch_assoc($query)) {
array_push($retval, $row);
$i = 1;
$result_temp = array();
foreach ($row as $key => $value) {
$column_type = oci_field_type($query, $key);
// Support for Clob fields larger than 4000bytes
//if ($sql == 'SELECT * FROM tgrupo ORDER BY dbms_lob.substr(nombre,4000,1) ASC') echo $i .' '.$column_type.' '.$key.'<br>';
if ($column_type == 'CLOB') {
$column_name = oci_field_name($query, $i);
// Protect against a NULL CLOB
if (is_object($row[$column_name])) {
$clob_data = $row[$column_name]->load();
$row[$column_name]->free();
$value = $clob_data;
}
else {
$value = '';
}
}
$result_temp[strtolower($key)] = $value;
$i++;
}
array_push($retval, $result_temp);
//array_push($retval, $row);
}
if ($cache === true)
@ -309,7 +341,15 @@ function oracle_process_sql($sql, $rettype = "affected_rows", $dbconnection = ''
*/
function oracle_get_db_all_rows_in_table($table, $order_field = "", $order = 'ASC') {
if ($order_field != "") {
return get_db_all_rows_sql ('SELECT * FROM ' . $table . ' ORDER BY ' . $order_field . ' ' . $order);
// Clob fields are not allowed in ORDER BY statements, they need cast to varchar2 datatype
$type = get_db_value_filter ('data_type', 'user_tab_columns', array ('table_name' => strtoupper($table), 'column_name' => strtoupper($order_field)), 'AND');
if ($type == 'CLOB') {
return get_db_all_rows_sql ('SELECT * FROM ' . $table . ' ORDER BY dbms_lob.substr(' . $order_field . ',4000,1) ' . $order);
}
else {
return get_db_all_rows_sql ('SELECT * FROM ' . $table . ' ORDER BY ' . $order_field . ' ' . $order);
}
}
else {
return get_db_all_rows_sql ('SELECT * FROM ' . $table);
@ -365,7 +405,7 @@ function oracle_process_sql_insert($table, $values) {
$query .= '(' . implode(', ', $fields) . ')';
$query .= ' VALUES (' . $values_str . ')';
return process_sql($query, 'insert_id');
}
@ -426,7 +466,7 @@ function oracle_get_db_value_filter ($field, $table, $filter, $where_join = 'AND
if ($result === false)
return false;
$fieldClean = strtoupper(str_replace('`', '', $field));
$fieldClean = str_replace('`', '', $field);
return $result[0][$fieldClean];
}
@ -534,6 +574,9 @@ function oracle_format_array_to_where_clause_sql ($values, $join = 'AND', $prefi
if ($i < $max) {
$query .= ' '.$join.' ';
}
if ($i == $max) {
$query .= ' ) ';
}
$i++;
continue;
}
@ -756,7 +799,6 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) {
}
$result = $pre_query.$sql.$query.$limit.$group.$order.$post_query;
if ($return){
return $result;
}
@ -796,7 +838,7 @@ function oracle_get_db_value_sql($sql) {
* @return mixed The first row of the result or false
*/
function oracle_get_db_row_sql ($sql, $search_history_db = false) {
$sql .= "SELECT * FROM (" . $sql . ") WHERE rownum < 2";
$sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2";
$result = get_db_all_rows_sql($sql, $search_history_db);
if($result === false)
@ -924,7 +966,7 @@ function oracle_get_db_num_rows ($sql) {
oci_execute($query);
if ($type[0] == 'SELECT'){
$row = oci_fetch_assoc($query);
$rows = $row[NUM];
$rows = $row['NUM'];
}
else{
$rows = oci_num_rows($query);
@ -1065,7 +1107,7 @@ function oracle_format_array_to_update_sql ($values) {
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function oracle_process_sql_update($table, $values, $where = false, $where_join = 'AND') {
function oracle_process_sql_update($table, $values, $where = false, $where_join = 'AND', $autocommit = true) {
$query = sprintf ("UPDATE %s SET %s",
$table,
format_array_to_update_sql ($values));
@ -1079,8 +1121,8 @@ function oracle_process_sql_update($table, $values, $where = false, $where_join
$query .= format_array_to_where_clause_sql ($where, $where_join, ' WHERE ');
}
}
return process_sql ($query);
$status = '';
return process_sql ($query, "affected_rows", '', true, $status, $autocommit);
}
/**
@ -1174,11 +1216,34 @@ function oracle_get_db_all_row_by_steps_sql($new = true, &$result, $sql = null)
}
$row = oci_fetch_assoc($result);
$result_temp = array();
if ($row) {
foreach ($row as $key => $value){
$column_type = oci_field_type($result, $key);
// Support for Clob field larger than 4000bytes
if ($column_type == 'CLOB') {
$column_name = oci_field_name($result, $key);
$column_name = oci_field_name($result, $key);
// protect against a NULL CLOB
if (is_object($row[$column_name])) {
$clob_data = $row[$column_name]->load();
$row[$column_name]->free();
$value = $clob_data;
}
else {
$value = '';
}
}
$result_temp[strtolower($key)] = $value;
}
}
if (!$row){
oci_free_statement($result);
}
return $row;
// return $row;
return $result_temp;
}
/**
@ -1272,7 +1337,7 @@ function oracle_get_db_type_field_table($table, $field) {
$query = oci_parse($config['dbconnection'], "SELECT * FROM " . $table . " WHERE rownum < 2");
oci_execute($query);
$type = oci_field_type($query, $field);
$type = oci_field_type($query, $field+1);
oci_free_statement($query);
return $type;

View File

@ -135,7 +135,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$title, $unit_name, $show_events = 0, $show_alerts = 0, $pure = 0, $stacked = 0, $date = 0) {
global $config;
global $graphic_type;
// Set variables
if ($date == 0) $date = get_system_time();
$datelimit = $date - $period;
@ -405,7 +405,7 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
$periodtime = floor ($period / $interval);
$time = array ();
$data = array ();
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
if (! $graphic_type) {
@ -415,11 +415,23 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
}
$top = $datelimit + ($periodtime * ($i + 1));
$data[$name] = (int) get_db_value_filter ('COUNT(*)',
'tagent_access',
array ('id_agent' => $id_agent,
'utimestamp > '.$bottom,
'utimestamp < '.$top));
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$data[$name] = (int) get_db_value_filter ('COUNT(*)',
'tagent_access',
array ('id_agent' => $id_agent,
'utimestamp > '.$bottom,
'utimestamp < '.$top));
break;
case "oracle":
$data[$name] = (int) get_db_value_filter ('count(*)',
'tagent_access',
array ('id_agent' => $id_agent,
'utimestamp > '.$bottom,
'utimestamp < '.$top));
break;
}
}
if (! $graphic_type) {
@ -653,10 +665,22 @@ function graphic_user_activity ($width = 350, $height = 230) {
$data = array ();
$max_items = 5;
$sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario
FROM tsesion
GROUP BY id_usuario
ORDER BY 1 DESC LIMIT %d', $max_items);
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario
FROM tsesion
GROUP BY id_usuario
ORDER BY 1 DESC LIMIT %d', $max_items);
break;
case "oracle":
$sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario
FROM tsesion
WHERE rownum <= %d
GROUP BY id_usuario
ORDER BY 1 DESC', $max_items);
break;
}
$logins = get_db_all_rows_sql ($sql);
if($logins == false) {
@ -697,6 +721,11 @@ function graphic_incident_source ($width = 320, $height = 200) {
FROM tincidencia GROUP BY "origen"
ORDER BY 1 DESC LIMIT %d', $max_items);
break;
case "oracle":
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incident, origen
FROM tincidencia WHERE rownum <= %d GROUP BY origen
ORDER BY 1 DESC', $max_items);
break;
}
$origins = get_db_all_rows_sql ($sql);
@ -726,16 +755,36 @@ function graph_db_agentes_modulos ($width, $height) {
$data = array ();
$modules = get_db_all_rows_sql ('SELECT COUNT(id_agente_modulo), id_agente
FROM tagente_modulo
GROUP BY id_agente
ORDER BY 1 DESC LIMIT 10');
switch ($config['dbtype']){
case "mysql":
case "postgresql":
$modules = get_db_all_rows_sql ('SELECT COUNT(id_agente_modulo), id_agente
FROM tagente_modulo
GROUP BY id_agente
ORDER BY 1 DESC LIMIT 10');
break;
case "oracle":
$modules = get_db_all_rows_sql ('SELECT COUNT(id_agente_modulo), id_agente
FROM tagente_modulo
WHERE rownum <= 10
GROUP BY id_agente
ORDER BY 1 DESC');
break;
}
if ($modules === false)
$modules = array ();
foreach ($modules as $module) {
$agent_name = get_agent_name ($module['id_agente'], "none");
$data[$agent_name] = $module['COUNT(id_agente_modulo)'];
switch ($config['dbtype']){
case "mysql":
case "postgresql":
$data[$agent_name] = $module['COUNT(id_agente_modulo)'];
break;
case "oracle":
$data[$agent_name] = $module['count(id_agente_modulo)'];
break;
}
}
if (! $graphic_type) {
@ -757,12 +806,27 @@ function grafico_eventos_usuario ($width, $height) {
$data = array ();
$max_items = 5;
$sql = sprintf ('SELECT COUNT(id_evento) events, id_usuario
FROM tevento
GROUP BY id_usuario
ORDER BY 1 DESC LIMIT %d', $max_items);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT COUNT(id_evento) events, id_usuario
FROM tevento
GROUP BY id_usuario
ORDER BY 1 DESC LIMIT %d', $max_items);
break;
case "oracle":
$sql = sprintf ('SELECT * FROM (SELECT COUNT(id_evento) events, id_usuario
FROM tevento
GROUP BY id_usuario
ORDER BY 1 DESC) WHERE rownum <= %d', $max_items);
break;
}
$events = get_db_all_rows_sql ($sql);
if ($events === false) {
$events = array();
}
foreach ($events as $event) {
$data['id_usuario'] = $event['events'];
}
@ -825,11 +889,24 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
$data = array ();
$max_items = 6;
$sql = sprintf ('SELECT COUNT(id_evento) as count_number, nombre
FROM tevento, tagente_modulo
WHERE id_agentmodule = id_agente_modulo
AND disabled = 0 AND tevento.id_agente = %d
GROUP BY id_agentmodule LIMIT %d', $id_agent, $max_items);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT COUNT(id_evento) as count_number, nombre
FROM tevento, tagente_modulo
WHERE id_agentmodule = id_agente_modulo
AND disabled = 0 AND tevento.id_agente = %d
GROUP BY id_agentmodule LIMIT %d', $id_agent, $max_items);
break;
case "oracle":
$sql = sprintf ('SELECT count_number, nombre FROM (SELECT COUNT(id_evento) as count_number, dbms_lob.substr(nombre,4000,1) as nombre, id_agentmodule
FROM tevento, tagente_modulo
WHERE (id_agentmodule = id_agente_modulo
AND disabled = 0 AND tevento.id_agente = %d) AND rownum <= %d
GROUP BY dbms_lob.substr(nombre,4000,1),id_agentmodule)', $id_agent, $max_items);
break;
}
$events = get_db_all_rows_sql ($sql);
if ($events === false) {
if (! $graphic_type) {
@ -889,9 +966,19 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") {
//This will give the distinct id_agente, give the id_grupo that goes
//with it and then the number of times it occured. GROUP BY statement
//is required if both DISTINCT() and COUNT() are in the statement
$sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente, id_grupo, COUNT(id_agente) AS count
FROM tevento WHERE 1=1 %s
GROUP BY id_agente ORDER BY count DESC', $url);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente, id_grupo, COUNT(id_agente) AS count
FROM tevento WHERE 1=1 %s
GROUP BY id_agente ORDER BY count DESC', $url);
break;
case "oracle":
$sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente, id_grupo, COUNT(id_agente) AS count
FROM tevento WHERE 1=1 %s
GROUP BY id_agente, id_grupo ORDER BY count DESC', $url);
break;
}
$result = get_db_all_rows_sql ($sql);
if ($result === false) {

View File

@ -322,6 +322,9 @@ function get_system_time () {
case "postgresql":
return postgresql_get_system_time();
break;
case "oracle":
return oracle_get_system_time();
break;
}
}
@ -1007,6 +1010,9 @@ function safe_sql_string($string) {
case "postgresql":
return postgresql_safe_sql_string($string);
break;
case "oracle":
return oracle_safe_sql_string($string);
break;
}
}

View File

@ -111,7 +111,8 @@ function create_agent ($name, $id_group, $interval, $ip_address, $values = false
*/
function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '',
$allModules = false, $orderby = false, $idGroup = false, $count = false) {
global $config;
if (is_array($filter)) {
$disabled = $filter['disabled'];
if (isset($filter['standby'])) {
@ -187,18 +188,32 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa
if ($count !== false) {
$selectText = 'COUNT(talert_template_modules.id) AS count';
}
$sql = sprintf ("SELECT %s
FROM talert_template_modules
INNER JOIN tagente_modulo AS t2
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente AS t3
ON t2.id_agente = t3.id_agente
INNER JOIN talert_templates AS t4
ON talert_template_modules.id_alert_template = t4.id
WHERE id_agent_module in (%s) %s %s %s",
$selectText, $subQuery, $where, $filter, $orderbyText);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ("SELECT %s
FROM talert_template_modules
INNER JOIN tagente_modulo AS t2
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente AS t3
ON t2.id_agente = t3.id_agente
INNER JOIN talert_templates AS t4
ON talert_template_modules.id_alert_template = t4.id
WHERE id_agent_module in (%s) %s %s %s",
$selectText, $subQuery, $where, $filter, $orderbyText);
case "oracle":
$sql = sprintf ("SELECT %s
FROM talert_template_modules
INNER JOIN tagente_modulo t2
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente t3
ON t2.id_agente = t3.id_agente
INNER JOIN talert_templates t4
ON talert_template_modules.id_alert_template = t4.id
WHERE id_agent_module in (%s) %s %s %s",
$selectText, $subQuery, $where, $filter, $orderbyText);
}
$alerts = get_db_all_rows_sql ($sql);
if ($alerts === false)

View File

@ -975,6 +975,7 @@ function get_agents_with_alert_template ($id_alert_template, $id_group, $filter
$filter['`tagente`.id_agente'] = array_keys (get_group_agents ($id_group, false, "none"));
break;
case "postgresql":
case "oracle":
$filter['tagente.id_agente'] = array_keys (get_group_agents ($id_group, false, "none"));
break;
}
@ -985,6 +986,7 @@ function get_agents_with_alert_template ($id_alert_template, $id_group, $filter
$filter['`tagente`.id_agente'] = $id_agents;
break;
case "postgresql":
case "oracle":
$filter['tagente.id_agente'] = $id_agents;
break;
}

View File

@ -158,6 +158,7 @@ function get_agent_module_name_last_value($agentName, $moduleName, $other = ';',
WHERE id_agente = %d AND nombre LIKE "%s"', $idAgent, $moduleName);
break;
case "postgresql":
case "oracle":
$sql = sprintf('SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \'%s\'', $idAgent, $moduleName);
@ -639,6 +640,7 @@ function set_new_agent($thrash1, $thrash2, $other, $thrash3) {
$sql1 = 'SELECT name FROM tserver WHERE name LIKE "' . $nameServer . '"';
break;
case "postgresql":
case "oracle":
$sql1 = 'SELECT name FROM tserver WHERE name LIKE \'' . $nameServer . '\'';
break;
}

View File

@ -53,6 +53,7 @@ function update_config_value ($token, $value) {
WHERE token LIKE "%list_ACL_IPs_for_API_%"');
break;
case "postgresql":
case "oracle":
$rows = get_db_all_rows_sql("SELECT id_config
FROM tconfig
WHERE token LIKE '%list_ACL_IPs_for_API_%'");

View File

@ -606,7 +606,7 @@ function get_group_agents ($id_group = 0, $search = false, $case = "lower", $noA
$search_sql .= ' AND (nombre COLLATE utf8_general_ci LIKE \'%'.$string.'%\' OR direccion LIKE \'%'.$string.'%\')';
break;
case "oracle":
$search_sql .= ' AND (nombre LIKE UPPER(\'%'.$string.'%\') OR direccion LIKE upper(\'%'.$string.'%\'))';
$search_sql .= ' AND (UPPER(nombre) LIKE UPPER(\'%'.$string.'%\') OR direccion LIKE upper(\'%'.$string.'%\'))';
break;
}
@ -638,8 +638,15 @@ function get_group_agents ($id_group = 0, $search = false, $case = "lower", $noA
$search_sql .= ' AND disabled = 0';
}
$sql = sprintf ("SELECT id_agente, nombre FROM tagente %s ORDER BY nombre", $search_sql);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ("SELECT id_agente, nombre FROM tagente %s ORDER BY nombre", $search_sql);
break;
case "oracle":
$sql = sprintf ("SELECT id_agente, nombre FROM tagente %s ORDER BY dbms_lob.substr(nombre,4000,1)", $search_sql);
break;
}
$result = get_db_all_rows_sql ($sql);
@ -802,7 +809,18 @@ function get_agent_modules ($id_agent = null, $details = false, $filter = false,
array_push ($fields, $field.' LIKE "'.$value.'"');
}
else {
array_push ($fields, $field.' = "'.$value.'"');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
array_push ($fields, $field.' = "'.$value.'"');
break;
case "oracle":
if (is_int ($value) ||is_float ($value)||is_double ($value))
array_push ($fields, $field.' = '.$value.'');
else
array_push ($fields, $field.' = "'.$value.'"');
break;
}
}
}
$where .= implode (' AND ', $fields);
@ -819,13 +837,27 @@ function get_agent_modules ($id_agent = null, $details = false, $filter = false,
$details = safe_input ($details);
}
$sql = sprintf ('SELECT %s%s
FROM tagente_modulo
%s
ORDER BY nombre',
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
safe_output(implode (",", (array) $details)),
$where);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT %s%s
FROM tagente_modulo
%s
ORDER BY nombre',
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
safe_output(implode (",", (array) $details)),
$where);
break;
case "oracle":
$sql = sprintf ('SELECT %s%s
FROM tagente_modulo
%s
ORDER BY dbms_lob.substr(nombre, 4000, 1)',
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
safe_output(implode (",", (array) $details)),
$where);
break;
}
$result = get_db_all_rows_sql ($sql);
@ -1731,6 +1763,8 @@ function give_agentmodule_flag ($id_agent_module) {
* Get all groups in array with index as id_group
*/
function get_all_groups($groupWithAgents = false) {
global $config;
$sql = 'SELECT id_grupo, nombre FROM tgrupo';
global $config;
@ -1738,7 +1772,15 @@ function get_all_groups($groupWithAgents = false) {
if ($groupWithAgents)
$sql .= ' WHERE id_grupo IN (SELECT id_grupo FROM tagente GROUP BY id_grupo)';
$sql .= ' ORDER BY nombre DESC';
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$sql .= ' ORDER BY nombre DESC';
break;
case "oracle":
$sql .= ' ORDER BY dbms_lob.substr(nombre,4000,1) DESC';
break;
}
$rows = get_db_all_rows_sql ($sql);
@ -3244,6 +3286,7 @@ function server_status ($id_server) {
*/
function temp_sql_delete ($table, $row, $value) {
global $error; //Globalize the errors variable
global $config;
switch ($config["dbtype"]) {
case "mysql":
@ -3251,7 +3294,12 @@ function temp_sql_delete ($table, $row, $value) {
$result = process_sql_delete ($table, $row.' = '.$value);
break;
case "oracle":
$result = oracle_process_sql_delete_temp ($table, $row.' = '.$value);
if (is_int ($value) || is_bool ($value) || is_float ($value) || is_double ($value)) {
$result = oracle_process_sql_delete_temp ($table, $row . ' = ' . $value);
}
else {
$result = oracle_process_sql_delete_temp ($table, $row . " = '" . $value . "'");
}
break;
}
@ -3529,10 +3577,11 @@ function process_sql_insert($table, $values) {
* @param string When a $where parameter is given, this will work as the glue
* between the fields. "AND" operator will be use by default. Other values might
* be "OR", "AND NOT", "XOR"
* @param bool Transaction automatically commited or not
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function process_sql_update($table, $values, $where = false, $where_join = 'AND') {
function process_sql_update($table, $values, $where = false, $where_join = 'AND', $autocommit = true) {
global $config;
switch ($config["dbtype"]) {
@ -3543,7 +3592,7 @@ function process_sql_update($table, $values, $where = false, $where_join = 'AND'
return postgresql_process_sql_update($table, $values, $where, $where_join);
break;
case "oracle":
return oracle_process_sql_update($table, $values, $where, $where_join);
return oracle_process_sql_update($table, $values, $where, $where_join, $autocommit);
break;
}
}

View File

@ -197,7 +197,8 @@ function validate_event ($id_event, $similars = true, $comment = '', $new_status
'estado' => $new_status,
'id_usuario' => $config['id_user'],
'user_comment' => $comment);
$ret = process_sql_update('tevento', $values, array('id_evento' => $event));
$ret = process_sql_update('tevento', $values, array('id_evento' => $event), 'AND', false);
if (check_acl ($config["id_user"], get_event_group ($event), "IW") == 0) {
//Check ACL
@ -282,6 +283,14 @@ function create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "",
$id_agent, $id_group, $event, $status, $id_user, $event_type,
$priority, $id_agent_module, $id_aam);
break;
case "oracle":
$sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp,
estado, utimestamp, id_usuario, event_type, criticity,
id_agentmodule, id_alert_am)
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)), "%s", "%s", %d, %d, %d)',
$id_agent, $id_group, $event, $status, $id_user, $event_type,
$priority, $id_agent_module, $id_aam);
break;
}
return (int) process_sql ($sql, "insert_id");
@ -300,7 +309,20 @@ function create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "",
function print_events_table ($filter = "", $limit = 10, $width = 440, $return = false) {
global $config;
$sql = sprintf ("SELECT * FROM tevento %s ORDER BY timestamp DESC LIMIT %d", $filter, $limit);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ("SELECT * FROM tevento %s ORDER BY timestamp DESC LIMIT %d", $filter, $limit);
break;
case "oracle":
if ($filter == "") {
$sql = sprintf ("SELECT * FROM tevento WHERE rownum <= %d ORDER BY timestamp DESC", $limit);
}
else {
$sql = sprintf ("SELECT * FROM tevento %s AND rownum <= %d ORDER BY timestamp DESC", $filter, $limit);
}
break;
}
$result = get_db_all_rows_sql ($sql);
if ($result === false) {

View File

@ -263,7 +263,7 @@ function fs_combined_chart ($data, $categories, $sets, $width, $height, $type =
if (sizeof ($data) == 0) {
return fs_error_image ();
}
// Generate the XML
switch ($type) {
case 0: $chart_type = 'MSArea2D';

View File

@ -523,6 +523,9 @@ function addPath($layerName, $idAgent, $lastPosition = null, $history_time = nul
case "postgresql":
$where = 'start_timestamp >= to_timestamp(ceil(date_part("epoch", CURRENT_TIMESTAMP)) - ' . $history_time . ')';
break;
case "oracle":
$where = 'start_timestamp >= to_timestamp(\'01-01-1970 00:00:00\', \'DD-MM-YYYY HH24:MI:SS\') + NUMTODSINTERVAL((ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)) - ' . $history_time . '),\'SECOND\')';
break;
}
}
@ -1053,6 +1056,7 @@ function getMapData($idMap) {
WHERE t1.tgis_map_id_tgis_map = '. $map['id_tgis_map']);
break;
case "postgresql":
case "oracle":
$connections = get_db_all_rows_sql('SELECT t1.tgis_map_connection_id_tmap_connection AS id_conection,
t1.default_map_connection AS "default", (
SELECT t2.num_zoom_levels

View File

@ -23,83 +23,190 @@
* @return bool Return false if the group is unused in the Pandora, else true.
*/
function checkUsedGroup($idGroup) {
global $config;
$return = array();
$return['return'] = false;
$return['tables'] = array();
$numRows = get_db_num_rows('SELECT * FROM tagente WHERE id_grupo = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tagente WHERE id_grupo = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tagente WHERE id_grupo = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Agents');
}
$numRows = get_db_num_rows('SELECT * FROM talert_actions WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM talert_actions WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM talert_actions WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Alert Actions');
}
$numRows = get_db_num_rows('SELECT * FROM talert_templates WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM talert_templates WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM talert_templates WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Alert Templates');
}
$numRows = get_db_num_rows('SELECT * FROM trecon_task WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM trecon_task WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM trecon_task WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Recon task');
}
$numRows = get_db_num_rows('SELECT * FROM tgraph WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tgraph WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tgraph WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Graphs');
}
$numRows = get_db_num_rows('SELECT * FROM treport WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM treport WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM treport WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Reports');
}
$numRows = get_db_num_rows('SELECT * FROM tlayout WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tlayout WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tlayout WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Layout visual console');
}
$numRows = get_db_num_rows('SELECT * FROM tplanned_downtime WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tplanned_downtime WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tplanned_downtime WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Plannet down time');
}
$numRows = get_db_num_rows('SELECT * FROM tgraph WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tgraph WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tgraph WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Graphs');
}
$numRows = get_db_num_rows('SELECT * FROM tgis_map WHERE group_id = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tgis_map WHERE group_id = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tgis_map WHERE group_id = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('GIS maps');
}
$numRows = get_db_num_rows('SELECT * FROM tgis_map_connection WHERE group_id = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tgis_map_connection WHERE group_id = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tgis_map_connection WHERE group_id = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('GIS connections');
}
$numRows = get_db_num_rows('SELECT * FROM tgis_map_layer WHERE tgrupo_id_grupo = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tgis_map_layer WHERE tgrupo_id_grupo = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tgis_map_layer WHERE tgrupo_id_grupo = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('GIS map layers');
}
$numRows = get_db_num_rows('SELECT * FROM tnetwork_map WHERE id_group = ' . $idGroup . ';');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$numRows = get_db_num_rows('SELECT * FROM tnetwork_map WHERE id_group = ' . $idGroup . ';');
break;
case "oracle":
$numRows = get_db_num_rows('SELECT * FROM tnetwork_map WHERE id_group = ' . $idGroup);
break;
}
if ($numRows > 0) {
$return['return'] = true;
$return['tables'][] = __('Network maps');

View File

@ -107,7 +107,7 @@ function delete_message ($id_message) {
$where = array(
'id_usuario_destino' => $config["id_user"],
'id_mensaje' => $id_message);
return (bool)process_sql_delete($tmensajes, $where);
return (bool)process_sql_delete('tmensajes', $where);
}
/**

View File

@ -179,6 +179,7 @@ function update_agent_module ($id, $values, $onlyNoDeletePending = false) {
* @return New module id if the module was created. False if not.
*/
function create_agent_module ($id_agent, $name, $values = false, $disableACL = false) {
global $config;
if (!$disableACL) {
if (empty ($id_agent) || ! user_access_to_agent ($id_agent, 'AW'))
@ -191,22 +192,39 @@ function create_agent_module ($id_agent, $name, $values = false, $disableACL = f
$values = array ();
$values['nombre'] = $name;
$values['id_agente'] = (int) $id_agent;
$id_agent_module = process_sql_insert ('tagente_modulo', $values);
if ($id_agent_module === false)
return false;
$result = process_sql_insert ('tagente_estado',
array ('id_agente_modulo' => $id_agent_module,
'datos' => 0,
'timestamp' => '0000-00-00 00:00:00',
'estado' => 0,
'id_agente' => (int) $id_agent,
'utimestamp' => 0,
'status_changes' => 0,
'last_status' => 0
));
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$result = process_sql_insert ('tagente_estado',
array ('id_agente_modulo' => $id_agent_module,
'datos' => 0,
'timestamp' => '0000-00-00 00:00:00',
'estado' => 0,
'id_agente' => (int) $id_agent,
'utimestamp' => 0,
'status_changes' => 0,
'last_status' => 0
));
break;
case "oracle":
$result = process_sql_insert ('tagente_estado',
array ('id_agente_modulo' => $id_agent_module,
'datos' => 0,
'timestamp' => 'to_date(0000-00-00 00:00:00, \'YYYY-MM-DD HH24:MI:SS\')',
'estado' => 0,
'id_agente' => (int) $id_agent,
'utimestamp' => 0,
'status_changes' => 0,
'last_status' => 0
));
break;
}
if ($result === false) {
process_sql_delete ('tagente_modulo',

View File

@ -40,13 +40,38 @@ $components = get_network_components ($id_module, 'id_module_group = 10'));
* if none matches.
*/
function get_network_components ($id_module, $filter = false, $fields = false) {
global $config;
if (! is_array ($filter))
$filter = array ();
if (! empty ($id_module))
$filter['id_modulo'] = (int) $id_module;
$components = get_db_all_rows_filter ('tnetwork_component',
$filter, $fields);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$components = get_db_all_rows_filter ('tnetwork_component',
$filter, $fields);
break;
case "oracle":
if (count ($fields) > 1) {
$fields = implode(',',$fields);
}
if (isset($filter['offset'])) {
$components = oracle_recode_query ('SELECT ' . $fields . ' FROM tnetwork_component', $filter, 'AND', false);
if ($components != false) {
for ($i=0; $i < count($components); $i++) {
unset($components[$i]['rnum']);
}
}
}
else {
$components = get_db_all_rows_filter ('tnetwork_component',
$filter, $fields);
}
break;
}
if ($components === false)
return array ();
return $components;
@ -188,6 +213,15 @@ function get_network_component ($id_network_component, $filter = false, $fields
* @return int New component id. False on error.
*/
function create_network_component ($name, $type, $id_group, $values = false) {
global $config;
switch ($config['dbtype']) {
case "oracle":
if (empty($values['tcp_rcv']))
$values['tcp_rcv'] = " ";
return;
}
if (empty ($name))
return false;
if (empty ($type))

View File

@ -48,7 +48,7 @@ function generate_dot ($pandora_name, $group = 0, $simple = 0, $font_size = 12,
$filter['disabled'] = 0;
if ($group >= 1)
$filter['id_grupo'] = $group;
// Get agent data
$agents = get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente'));
@ -587,7 +587,7 @@ function get_networkmap ($id_networkmap, $filter = false, $fields = false) {
$filter['id_networkmap'] = $id_networkmap;
$filter['id_user'] = $config['id_user'];
$networkmap = get_db_row_filter ('tnetwork_map', $filter, $fields);
return $networkmap;
@ -611,10 +611,26 @@ function get_networkmaps ($id_user = '', $type = '', $optgrouped = true) {
$type_cond = '';
if($type != '') {
$type_cond = ' AND type = "'.$type.'"';
switch ($config["dbtype"]) {
case "mysql":
$type_cond = ' AND type = "'.$type.'"';
break;
case "postgresql":
case "oracle":
$type_cond = ' AND type = \''.$type.'\'';
break;
}
}
$networkmaps_raw = get_db_all_rows_filter ('tnetwork_map', 'id_user = "'.$id_user.'"'.$type_cond.' ORDER BY type DESC, name ASC', array('id_networkmap','name', 'type'));
switch ($config["dbtype"]) {
case "mysql":
$networkmaps_raw = get_db_all_rows_filter ('tnetwork_map', 'id_user = "'.$id_user.'"'.$type_cond.' ORDER BY type DESC, name ASC', array('id_networkmap','name', 'type'));
break;
case "postgresql":
case "oracle":
$networkmaps_raw = get_db_all_rows_filter ('tnetwork_map', 'id_user = \''.$id_user.'\' '.$type_cond.' ORDER BY type DESC, name ASC', array('id_networkmap','name', 'type'));
break;
}
if($networkmaps_raw === false){
return false;

View File

@ -655,6 +655,11 @@ function get_group_stats ($id_group = 0) {
FROM tagente
WHERE id_grupo = $group AND disabled = 0 AND ceil(date_part('epoch', ultimo_contacto)) < ceil(date_part('epoch', NOW())) - (intervalo * 2)");
break;
case "oracle":
$data["agents_unknown"] += get_db_sql ("SELECT COUNT(*)
FROM tagente
WHERE id_grupo = $group AND disabled = 0 AND ultimo_contacto < CURRENT_TIMESTAMP - (intervalo * 2)");
break;
}
$data["total_agents"] += get_db_sql ("SELECT COUNT(*)
@ -697,6 +702,17 @@ function get_group_stats ($id_group = 0) {
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100)))
AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24)))");
break;
case "oracle":
$data["monitor_ok"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.id_grupo = $group AND 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 = 0
AND ((ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100)))
AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24)))");
break;
}
switch ($config["dbtype"]) {
@ -716,6 +732,13 @@ function get_group_stats ($id_group = 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 ((ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
break;
case "oracle":
$data["monitor_critical"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.id_grupo = $group AND 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 ((ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
break;
}
switch ($config["dbtype"]) {
@ -735,6 +758,14 @@ function get_group_stats ($id_group = 0) {
AND estado = 2 AND ((ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
break;
case "oracle":
$data["monitor_warning"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.id_grupo = $group AND 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 ((ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0");
break;
}
switch ($config["dbtype"]) {
@ -754,6 +785,14 @@ function get_group_stats ($id_group = 0) {
AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100)
AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)");
break;
case "oracle":
$data["monitor_unknown"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.id_grupo = $group AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0
AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100)
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)");
break;
}
$data["monitor_not_init"] += get_db_sql ("SELECT COUNT(tagente_estado.id_agente_estado)
@ -1974,7 +2013,6 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$sla_value = get_agentmodule_sla ($sla['id_agent_module'], $content['period'],
$sla['sla_min'], $sla['sla_max'], $report["datetime"], $content, $content['time_from'],
$content['time_to']);
//Fill the array data_graph for the pie graph
if ($sla_value === false) {
$data_graph[__('Unknown')]++;
@ -2281,6 +2319,9 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
case "postgresql":
$sql = safe_output_html (get_db_value_filter('"sql"', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id'])));
break;
case "oracle":
$sql = safe_output_html (get_db_value_filter('sql', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id'])));
break;
}
}
else {

View File

@ -204,6 +204,7 @@ function create_report_content ($id_report, $values) {
$values['`order`'] = $order + 1;
break;
case "postgresql":
case "oracle":
unset ($values['"order"']);
$order = (int) get_db_value ('MAX("order")', 'treport_content', 'id_report', $id_report);
@ -273,6 +274,7 @@ function move_report_content_up ($id_report_content) {
array ('id_rc' => $id_report_content))) !== false;
break;
case "postgresql":
case "oracle":
$order = get_db_value ('"order"', 'treport_content', 'id_rc', $id_report_content);
/* Set the previous element order to the current of the content we want to change */
process_sql_update ('treport_content',
@ -317,6 +319,7 @@ function move_report_content_down ($id_report_content) {
array ('id_rc' => $id_report_content))) !== false;
break;
case "postgresql":
case "oracle":
$order = get_db_value ('"order"', 'treport_content', 'id_rc', $id_report_content);
/* Set the previous element order to the current of the content we want to change */
process_sql_update ('treport_content',
@ -354,6 +357,7 @@ function delete_report_content ($id_report_content) {
'`order` > '.$order));
break;
case "postgresql":
case "oracle":
$order = get_db_value ('"order"', 'treport_content', 'id_rc', $id_report_content);
process_sql_update ('treport_content',
array ('"order" = "order" - 1'),

View File

@ -259,6 +259,16 @@ function get_server_info ($id_server = -1) {
AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) < ( current_interval * 10)
AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > current_interval");
break;
case "oracle":
$result = get_db_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo
WHERE utimestamp > 0
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND current_interval > 0
AND running_by = ".$server["id_server"]."
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp) < ( current_interval * 10)
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) - utimestamp) * (86400)) > current_interval");
break;
}
}
else {
@ -286,6 +296,17 @@ function get_server_info ($id_server = -1) {
AND running_by = ".$server["id_server"]."
AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > (current_interval * 1.1)");
break;
case "oracle":
$result = get_db_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo
WHERE utimestamp > 0
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_tipo_modulo < 5
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND current_interval > 0
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp) < ( current_interval * 10)
AND running_by = ".$server["id_server"]."
AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp) > (current_interval * 1.1)");
break;
}
}
@ -326,6 +347,11 @@ function get_server_info ($id_server = -1) {
case "postgresql":
$server["lag"] = get_db_sql ("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]);
$server["module_lag"] = get_db_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]);
break;
case "oracle":
$server["lag"] = get_db_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]);
$server["module_lag"] = get_db_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]);
break;
}

View File

@ -45,6 +45,9 @@ switch ($config["dbtype"]) {
case "postgresql":
$timestamp = get_db_value_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP));");
break;
case "oracle":
$timestamp = get_db_value_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) as dt FROM dual");
break;
}
print_timestamp ($timestamp, false, $option);
?>

View File

@ -45,6 +45,9 @@ switch ($config["dbtype"]) {
case "postgresql":
$timestamp = get_db_value_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP));");
break;
case "oracle":
$timestamp = get_db_value_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) as dt FROM dual");
break;
}
print_timestamp ($timestamp, false, $option);
?>

View File

@ -40,6 +40,9 @@ switch ($config["dbtype"]) {
case "postgresql":
$timestamp = get_db_value_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP));");
break;
case "oracle":
$timestamp = get_db_value_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) as dt FROM dual");
break;
}
print_timestamp ($timestamp, false, $option);
?>

View File

@ -31,6 +31,37 @@
<link rel="stylesheet" href="include/styles/pandora_minimal.css" type="text/css">
<link rel="stylesheet" href="include/styles/install.css" type="text/css">
</head>
<script type="text/javascript">
options_text = new Array('An existing Database','A new Database');
options_values = new Array('db_exist','db_new');
function ChangeDBDrop(causer) {
if (causer.value == 'db_exist') {
window.document.step2_form.drop.checked=0;
window.document.step2_form.drop.disabled=1;
}
else {
window.document.step2_form.drop.disabled=0;
}
}
function ChangeDBAction(causer) {
var i = 0;
if (causer.value == 'oracle') {
window.document.step2_form.db_action.length=1;
}
else {
window.document.step2_form.db_action.length=2;
}
while (i < window.document.step2_form.db_action.length){
window.document.step2_form.db_action.options[i].value =options_values[i];
window.document.step2_form.db_action.options[i].text =options_text[i];
i++;
}
window.document.step2_form.db_action.options[window.document.step2_form.db_action.length-1].selected=1;
ChangeDBDrop(window.document.step2_form.db_action);
}
</script>
<body bgcolor="#555555">
<?php
@ -221,6 +252,70 @@ function parse_postgresql_dump($connection, $url, $debug = false) {
}
}
function parse_oracle_dump($connection, $url, $debug = false) {
if (file_exists($url)) {
$file_content = file($url);
$query = "";
$plsql_block = false;
foreach($file_content as $sql_line){
$clean_line = trim($sql_line);
$comment = preg_match("/^(\s|\t)*--.*$/", $clean_line);
if ($comment) {
continue;
}
if (empty($clean_line)) {
continue;
}
//Support for PL/SQL blocks
if (preg_match("/^BEGIN$/", $clean_line)){
$query .= $clean_line . ' ';
$plsql_block = true;
}
else{
$query .= $clean_line;
}
//Check query's end with a back slash and any returns in the end of line or if it's a PL/SQL block 'END;;' string
if ((preg_match("/;[\040]*\$/", $clean_line) && !$plsql_block) ||
(preg_match("/^END;;[\040]*\$/", $clean_line) && $plsql_block)) {
$plsql_block = false;
//Execute and clean buffer
//Delete the last semicolon from current query
$query = substr($query, 0, strlen($query) - 1);
$sql = oci_parse($connection, $query);
$result = oci_execute($sql);
if ($debug) {
var_dump($query);
}
if (!$result) {
$e = oci_error($sql);
echo "<tr><td><div class='warn'>Errors creating schema:</div><div style=\"overflow:auto; height:50px;\" >";
echo htmlentities($e['message'], ENT_QUOTES);
echo "<i><br>$query<br></i>";
echo "</div></td></tr>";
return 0;
}
$query = "";
oci_free_statement($sql);
}
}
return 1;
}
else {
return 0;
}
}
function random_name ($size){
$temp = "";
for ($a=0;$a< $size;$a++)
@ -369,6 +464,7 @@ function install_step2() {
echo "</td></tr>";
check_extension("mysql", "PHP MySQL extension");
check_extension("pgsql", "PHP PostgreSQL extension");
check_extension("oci8", "PHP Oracle extension");
echo "</table>";
echo "</div>";
print_logo_status (3,5);
@ -406,16 +502,19 @@ function install_step3() {
if (extension_loaded("pgsql")) {
$options .= "<option value='pgsql'>PostgreSQL</option>";
}
if (extension_loaded("oci8")) {
$options .= "<option value='oracle'>Oracle</option>";
}
$error = false;
if (empty($options)) {
$error = true;
}
echo "
<div id='install_container'>
<h1>Pandora FMS console installation wizard. Step #4 of 5 </h1>
<div id='wizard' style='height: 640px;'>
<div id='wizard' style='height: 750px;'>
<div id='install_box'>
<h2>Environment and database setup</h2>
<p>
@ -424,7 +523,11 @@ function install_step3() {
</p>
<p>
You need a privileged user to create database schema, this is usually <b>root</b> user.
Information about <b>root</b> user will not be used or stored anymore.
Information about <b>root</b> user will not be used or stored anymore.
</p>
<p>
You can also deploy the scheme into an existing Database.
In this case you need a privileged Database user and password of that instance.
</p>
<p>
Now, please, complete all details to configure your database and environment setup.
@ -435,8 +538,12 @@ function install_step3() {
please <b>be sure that you have no valuable Pandora FMS data in your Database.</b>
<br><br>
</div>";
if (extension_loaded("oci8")) {
echo " <div class='warn'>For Oracle installation an existing Database with a privileged user is needed.</div>";
}
if (!$error) {
echo "<form method='post' action='install.php?step=4'>";
echo "<form method='post' name='step2_form' action='install.php?step=4'>";
}
echo "<div>DB ENGINE</div>";
@ -448,9 +555,15 @@ function install_step3() {
</div>";
}
else {
echo "<select name='engine'>";
echo "<select name='engine' onChange=\"ChangeDBAction(this)\">";
echo $options;
echo "</select>";
echo "<div style=\"height:40px;\">Instalation in <br>";
echo "<select name='db_action' onChange=\"ChangeDBDrop(this)\">";
echo "<option value='db_new'>A new Database</option>";
echo "<option value='db_exist'>An existing Database</option>";
echo "</select>";
echo "</div>";
}
echo " <div>DB User with privileges on DB</div>
<input class='login' type='text' name='user' value='root'>
@ -505,18 +618,20 @@ function install_step4() {
$pandora_config = "include/config.php";
if ( (! isset($_POST["user"])) || (! isset($_POST["dbname"])) || (! isset($_POST["host"])) ||
(! isset($_POST["pass"])) || (!isset($_POST['engine'])) ) {
(! isset($_POST["pass"])) || (!isset($_POST['engine'])) || (! isset($_POST["db_action"])) ) {
$dbpassword = "";
$dbuser = "";
$dbhost = "";
$dbname = "";
$engine = "";
$dbaction = "";
}
else {
$engine = $_POST['engine'];
$dbpassword = $_POST["pass"];
$dbuser = $_POST["user"];
$dbhost = $_POST["host"];
$dbaction = $_POST["db_action"];
if (isset($_POST["drop"]))
$dbdrop = $_POST["drop"];
else
@ -553,14 +668,19 @@ function install_step4() {
else {
check_generic ( 1, "Connection with Database");
// Drop database if needed
if ($dbdrop == 1) {
// Drop database if needed and don't want to install over an existing DB
if ($dbdrop == 1 && $dbaction != 'db_exist') {
mysql_query ("DROP DATABASE IF EXISTS $dbname");
}
// Create schema
$step1 = mysql_query ("CREATE DATABASE $dbname");
check_generic ($step1, "Creating database '$dbname'");
if ($dbaction != 'db_exist'){
$step1 = mysql_query ("CREATE DATABASE $dbname");
check_generic ($step1, "Creating database '$dbname'");
}
else{
$step = 1;
}
if ($step1 == 1) {
$step2 = mysql_select_db($dbname);
check_generic ($step2, "Opening database '$dbname'");
@ -613,6 +733,65 @@ function install_step4() {
$everything_ok = 1;
}
break;
case 'oracle':
$connection = oci_connect($dbuser, $dbpassword, '//' . $dbhost . '/' . $dbname);
if (!$connection){
check_generic(0, "Connection with Database");
}
else {
check_generic(1, "Connection with Database");
$step1 = parse_oracle_dump($connection, "pandoradb.oracle.sql");
check_generic($step1, "Creating schema");
if ($step1) {
$step2 = parse_oracle_dump($connection, "pandoradb.data.oracle.sql");
}
check_generic ($step2, "Populating database");
echo "<tr><td><div class='warn'>Please, you will need to setup your Pandora FMS server, editing the </i>/etc/pandora/pandora_server.conf</i> file and set database password.</div></tr></td>";
if ($step2) {
$step3 = is_writable("include");
}
check_generic ($step3, "Write permissions to save config file in './include'");
if ($step3) {
$cfgin = fopen ("include/config.inc.php","r");
$cfgout = fopen ($pandora_config,"w");
$config_contents = fread ($cfgin, filesize("include/config.inc.php"));
$dbtype = 'oracle';
$config_new = '<?php
// Begin of automatic config file
$config["dbtype"] = "' . $dbtype . '"; //DB type (mysql, postgresql, oracle)
$config["dbname"]="' . $dbname . '"; // Oracle DataBase name
$config["dbuser"]="' . $dbuser . '"; // DB User
$config["dbpass"]="' . $dbpassword . '"; // DB Password
$config["dbhost"]="' . $dbhost . '"; // DB Host
$config["homedir"]="' . $path . '"; // Config homedir
$config["homeurl"]="' . $url . '"; // Base URL
// End of automatic config file
?>';
$step4 = fputs ($cfgout, $config_new);
$step4 = $step4 + fputs ($cfgout, $config_contents);
if ($step4 > 0)
$step4 = 1;
fclose ($cfgin);
fclose ($cfgout);
chmod ($pandora_config, 0600);
}
check_generic ($step4, "Created new config file at '" . $pandora_config . "'");
if (($step4 + $step3 + $step2 + $step1) == 4) {
$everything_ok = 1;
}
}
break;
case 'pgsql':
$step1 = $step2 = $step3 = $step4 = $step5 = $step6 = $step7 = 0;
@ -623,14 +802,21 @@ function install_step4() {
else {
check_generic(1, "Connection with Database");
// Drop database if needed
if ($dbdrop == 1) {
// Drop database if needed and don't want to install over an existing DB
if ($dbdrop == 1 && $dbaction != 'db_exist') {
$result = pg_query($connection, "DROP DATABASE \"" . $dbname . "\";");
}
pg_send_query($connection, "CREATE DATABASE \"" . $dbname . "\" WITH ENCODING 'utf8';");
$result = pg_get_result($connection);
if (pg_result_status($result) != PGSQL_FATAL_ERROR) {
if ($dbaction != 'db_exist'){
pg_send_query($connection, "CREATE DATABASE \"" . $dbname . "\" WITH ENCODING 'utf8';");
$result = pg_get_result($connection);
if (pg_result_status($result) != PGSQL_FATAL_ERROR) {
$step1 = 1;
}
check_generic ($step1, "Creating database '$dbname'");
}
else{
$step1 = 1;
}
@ -795,12 +981,19 @@ function install_step4() {
<img align='right' src='images/arrow_next.png' border='0' alt=''></a>";
}
else {
echo "<div class='warn'><b>There were some problems.
$info = "<div class='warn'><b>There were some problems.
Installation was not completed.</b>
<p>Please correct failures before trying again.
All database schemes created in this step have been dropped. </p>
All database ";
if ($engine == 'oracle')
$info .= "objects ";
else
$info .= "schemes ";
$info .= "created in this step have been dropped. </p>
</div>";
echo $info;
switch ($engine) {
case 'mysql':
if (mysql_error() != "") {
@ -813,6 +1006,29 @@ function install_step4() {
break;
case 'pgsql':
break;
case 'oracle':
//Drop all objects of the current instalation
$stmt = oci_parse($connection,
"BEGIN " .
"FOR cur_rec IN (SELECT object_name, object_type " .
"FROM user_objects " .
"WHERE object_type IN ('TABLE', 'VIEW', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE', 'SNAPSHOT', 'MATERIALIZED VIEW')) LOOP " .
"BEGIN " .
"IF cur_rec.object_type = 'TABLE' THEN " .
"EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\" CASCADE CONSTRAINTS'; " .
"ELSE " .
"EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\"'; " .
"END IF; " .
"EXCEPTION " .
"WHEN OTHERS THEN " .
"DBMS_OUTPUT.put_line('FAILED: DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\"'); " .
"END; " .
"END LOOP; " .
"END; ");
$result = oci_execute($stmt);
oci_free_statement($stmt);
break;
}
}
echo "

View File

@ -151,10 +151,21 @@ class MonitorStatus {
case "postgresql":
$rows = get_db_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->system->getPageSize() . ' OFFSET ' . $this->offset);
break;
case "oracle":
$set = array();
$set['limit'] = $this->system->getPageSize();
$set['offset'] = $this->offset;
$rows = oracle_recode_query ($selectSQL . $sql, $set, 'AND', true);
break;
}
if ($rows === false) $rows = array();
if ($config["dbtype"] == 'oracle') {
for ($i=0; $i < count($rows); $i++) {
unset($rows[$i]['rnum']);
}
}
$table = null;
$table->width = '100%';

View File

@ -473,10 +473,22 @@ class viewGraph {
case "postgresql":
$sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->system->getPageSize() . ' OFFSET ' . $this->offset;
break;
case "oracle":
$set = array();
$set['limit'] = $this->system->getPageSize();
$set['offset'] = $this->offset;
$sql = oracle_recode_query ('SELECT * ' . $sql_body, $set);
break;
}
$result = get_db_all_rows_sql ($sql);
if (($config["dbtype"] == 'oracle') && ($result !== false)) {
// Delete rnum row generated by oracle_recode_query() function
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
}
$table = null;
$table->width = '100%';

View File

@ -127,6 +127,12 @@ class EventsView {
case "postgresql":
$sql = $sql . sprintf(' LIMIT %d OFFSET %d', $this->system->getPageSize(), $offset);
break;
case "oracle":
$set = array();
$set['limit'] = $this->system->getPageSize();
$set['offset'] = $offset;
$sql = oracle_recode_query ($sql, $set);
break;
}
$count = get_db_value_sql($sql_count);

View File

@ -104,6 +104,7 @@ if ($free_search != '') {
')';
break;
case "postgresql":
case "oracle":
$whereAlertSimple = 'AND (' .
'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE \'%' . $free_search . '%\') OR ' .
'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE \'%' . $free_search . '%\')) OR ' .

View File

@ -105,6 +105,12 @@ switch ($config["dbtype"]) {
case "postgresql":
$sql .= " LIMIT " . $block_size . " OFFSET " . $offset;
break;
case "oracle":
$set = array();
$set['limit'] = $block_size;
$set['offset'] = $offset;
$sql = oracle_recode_query ($sql, $set);
break;
}
$result = get_db_all_rows_sql ($sql);
@ -112,6 +118,12 @@ if ($result === false) {
$result = array ();
}
if (($config['dbtype'] == 'oracle') && ($result !== false)) {
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
}
$header_title = __('Received data from')." ".get_agentmodule_agent_name ($module_id)." / ".get_agentmodule_name ($module_id);
$header_title .= "<br><br>" . __("From the last") . " " . human_time_description_raw ($period);

View File

@ -117,6 +117,15 @@ switch ($sortField) {
break;
}
switch ($config["dbtype"]) {
case "oracle":
if (isset($order['field']) && $order['field'] == 'tagente_modulo.nombre') {
$order['field'] = 'dbms_lob.substr(tagente_modulo.nombre,4000,1)';
}
break;
}
// Get all module from agent
$sql = sprintf ("
SELECT *

View File

@ -33,12 +33,25 @@ $timestamp_lof = $agent["ultimo_contacto"];
$intervalo_agente = $agent["intervalo"];
// Get last packet
$sql3 = 'SELECT * FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.disabled = 0
AND tagente_modulo.id_agente = ' . $id_agente.
' AND tagente_estado.utimestamp != 0
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
ORDER BY id_module_group, nombre';
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql3 = 'SELECT * FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.disabled = 0
AND tagente_modulo.id_agente = ' . $id_agente.
' AND tagente_estado.utimestamp != 0
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
ORDER BY id_module_group, nombre';
break;
case "oracle":
$sql3 = 'SELECT * FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.disabled = 0
AND tagente_modulo.id_agente = ' . $id_agente.
' AND tagente_estado.utimestamp != 0
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
ORDER BY id_module_group, dbms_lob.substr(nombre,4000,1)';
break;
}
$label_group = 0;
$last_label = "";
@ -69,11 +82,27 @@ switch ($sortField) {
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
case "oracle":
$order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'ASC');
break;
}
break;
case 'down':
$selectNameDown = $selected;
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
break;
case "oracle":
$order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'DESC');
break;
}
break;
}
break;
@ -135,7 +164,15 @@ switch ($sortField) {
$selectIntervalDown = '';
$selectTimestampUp = '';
$selectTimestampDown = '';
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
case "oracle":
$order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'ASC');
break;
}
break;
}

View File

@ -13,6 +13,8 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
if (is_ajax ()) {
$search_agents = (bool) get_parameter ('search_agents');
@ -34,7 +36,15 @@ if (is_ajax ()) {
}
$filter = array ();
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")';
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")';
break;
case "oracle":
$filter[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\') OR UPPER(direccion) LIKE UPPER(\'%'.$string.'%\') OR UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$filter['id_grupo'] = $id_group;
switch ($all) {
@ -79,7 +89,15 @@ print_page_header (__("Export data"), "images/bricks.png");
$group = get_parameter_post ('group', 0);
//$agent = get_parameter_post ('agent', 0);
$agentName = get_parameter_post ('agent', 0);
$agents = get_agents (array('nombre LIKE "' . $agentName . '"'), array ('id_agente'));
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$agents = get_agents (array('nombre LIKE "' . $agentName . '"'), array ('id_agente'));
break;
case "oracle":
$agents = get_agents (array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente'));
break;
}
$agent = $agents[0]['id_agente'];
$module = (array) get_parameter_post ('module_arr', array ());

View File

@ -56,6 +56,9 @@ switch ($config["dbtype"]) {
case "postgresql":
$timestampLastOperation = get_db_value_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP));");
break;
case "oracle":
$timestampLastOperation = get_db_value_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) from dual");
break;
}
activateAjaxRefresh(null, $timestampLastOperation);

View File

@ -141,6 +141,45 @@ switch ($config["dbtype"]) {
)
)';
break;
case "oracle":
$names = oracle_get_db_all_rows_filter ('user_tab_columns',array ('table_name' => 'TAGENTE_MODULO', 'column_name' => '<>NOMBRE'), 'column_name');
$column_names = '';
foreach ($names as $column_name => $value) {
$column_names .= $value['column_name'] . ',';
}
$column_names = substr($column_names,0,-1);
$sql = '
select nombre
from (select distinct dbms_lob.substr(nombre,4000,1) as nombre, ' . $column_names .' from tagente_modulo)
where nombre <> \'delete_pending\' and id_agente in
(
select id_agente
from tagente where id_grupo IN (
select id_grupo
from tusuario_perfil
where id_usuario = \'' . $config['id_user'] . '\'
and id_perfil IN (
select id_perfil
from tperfil where agent_view = 1
)
)
OR
(1 = (
SELECT is_admin FROM tusuario WHERE id_user = \'' . $config['id_user'] . '\'
)
)
OR 0 IN (
select id_grupo
from tusuario_perfil
where id_usuario = \'' . $config['id_user'] . '\'
and id_perfil IN (
select id_perfil
from tperfil where agent_view = 1
)
)
)';
break;
}
$modules = get_db_all_rows_sql($sql);
@ -249,6 +288,25 @@ switch ($config["dbtype"]) {
tagente_estado.estado,
tagente_estado.utimestamp AS utimestamp".$sql." LIMIT " . $config["block_size"] . " OFFSET " . $offset;
break;
case "oracle":
$set = array();
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$sql = "SELECT tagente_modulo.id_agente_modulo,
tagente.intervalo AS agent_interval,
tagente.nombre AS agent_name,
tagente_modulo.nombre AS module_name,
tagente_modulo.history_data,
tagente_modulo.flag AS flag,
tagente.id_grupo AS id_group,
tagente.id_agente AS id_agent,
tagente_modulo.id_tipo_modulo AS module_type,
tagente_modulo.module_interval,
tagente_estado.datos,
tagente_estado.estado,
tagente_estado.utimestamp AS utimestamp".$sql;
$sql = oracle_recode_query ($sql, $set);
break;
}
$result = get_db_all_rows_sql ($sql);
@ -260,6 +318,12 @@ if ($result === false) {
$result = array ();
}
if (($config['dbtype'] == 'oracle') && ($result !== false)) {
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
}
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = 750;

View File

@ -190,7 +190,7 @@ if (is_ajax ()) {
//Hack to translate text "any" in PHP to javascript
//$agent_modules['any_text'] = __('Any');
echo json_encode ($agent_modules);
return;
}

View File

@ -255,6 +255,15 @@ if ($group_rep == 0) {
FROM tevento
WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$pagination." OFFSET ".$offset;
break;
case "oracle":
$set = array();
$set['limit'] = $pagination;
$set['offset'] = $offset;
$sql = "SELECT *
FROM tevento
WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC";
$sql = oracle_recode_query ($sql, $set);
break;
}
}
else {
@ -273,6 +282,22 @@ else {
GROUP BY evento, id_agentmodule
ORDER BY timestamp_rep DESC LIMIT ".$pagination." OFFSET ".$offset;
break;
case "oracle":
$set = array();
$set['limit'] = $pagination;
$set['offset'] = $offset;
$sql = "SELECT a.*, b.event_rep, b.timestamp_rep
FROM (select * from tevento WHERE 1=1 ".$sql_post.") a,
(select min(id_evento) as id_evento, to_char(evento) as evento,
id_agentmodule, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep
from tevento
WHERE 1=1 ".$sql_post."
GROUP BY to_char(evento), id_agentmodule) b
where a.id_evento=b.id_evento and
to_char(a.evento)=to_char(b.evento)
and a.id_agentmodule=b.id_agentmodule";
$sql = oracle_recode_query ($sql, $set);
break;
}
}
@ -280,6 +305,13 @@ else {
//Extract the events by filter (or not) from db
$result = get_db_all_rows_sql ($sql);
// Delete rnum field generated by oracle_recode_query() function
if (($config['dbtype'] == 'oracle') && ($result !== false)) {
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
}
if ($group_rep == 0) {
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 ".$sql_post;
}

View File

@ -64,6 +64,9 @@ switch ($config["dbtype"]) {
case "postgresql":
$sql = "SELECT evento, timestamp, id_agente FROM tevento WHERE 1=1 $sql_group_filter ORDER BY utimestamp DESC LIMIT $MAX_MARQUEE_EVENTS OFFSET 0";
break;
case "oracle":
$sql = "SELECT evento, timestamp, id_agente FROM tevento WHERE (1=1 $sql_group_filter ) AND rownum <= $MAX_MARQUEE_EVENTS ORDER BY utimestamp DESC";
break;
}
$result = get_db_all_rows_sql ($sql);

View File

@ -184,6 +184,19 @@ switch ($config["dbtype"]) {
WHERE 1 = 1" . $sql_post . "
ORDER BY utimestamp DESC LIMIT 30 OFFSET 0";
break;
case "oracle":
$sql="SELECT tevento.id_evento AS event_id,
tevento.id_agente AS id_agent,
tevento.id_usuario AS validated_by,
tevento.id_grupo AS id_group,
tevento.estado AS validated,
tevento.evento AS event_descr,
tevento.utimestamp AS unix_timestamp,
tevento.event_type AS event_type
FROM tevento
WHERE (1 = 1" . $sql_post . ") AND rownum <= 30
ORDER BY utimestamp DESC";
break;
}
$result= get_db_all_rows_sql ($sql);

View File

@ -93,6 +93,14 @@ switch ($opt) {
LEFT JOIN tgis_data_status AS t2 ON t1.id_agente = t2.tagente_id_agente
WHERE id_agente IN (' . implode(',', $idAgentsWithGIS) . ')');
break;
case "oracle":
$agentsGISStatus = get_db_all_rows_sql('SELECT t1.nombre, id_parent, t1.id_agente AS tagente_id_agente,
COALESCE(t2.stored_longitude, ' . $defaultCoords['default_longitude'] . ') AS stored_longitude,
COALESCE(t2.stored_latitude, ' . $defaultCoords['default_latitude'] . ') AS stored_latitude
FROM tagente t1
LEFT JOIN tgis_data_status t2 ON t1.id_agente = t2.tagente_id_agente
WHERE id_agente IN (' . implode(',', $idAgentsWithGIS) . ')');
break;
}
if ($agentsGISStatus === false) {

View File

@ -179,6 +179,9 @@ if ($layers != false) {
case "postgresql":
$timestampLastOperation = get_db_value_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP))");
break;
case "oracle":
$timestampLastOperation = get_db_value_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) from dual");
break;
}
activateSelectControl();

View File

@ -140,6 +140,9 @@ switch ($config["dbtype"]) {
case "postgresql":
$contents = get_db_all_rows_field_filter ("treport_content", "id_report", $id_report, '"order"');
break;
case "oracle":
$contents = get_db_all_rows_field_filter ("treport_content", "id_report", $id_report, '"order"');
break;
}
if ($contents === false) {
return;

View File

@ -147,6 +147,7 @@ switch ($config["dbtype"]) {
$contents = get_db_all_rows_field_filter ('treport_content', 'id_report', $id_report, '`order`');
break;
case "postgresql":
case "oracle":
$contents = get_db_all_rows_field_filter ('treport_content', 'id_report', $id_report, '"order"');
break;
}
@ -365,6 +366,9 @@ foreach ($contents as $content) {
case "postgresql":
$sql = get_db_value_filter('"sql"', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id']));
break;
case "oracle":
$sql = get_db_value_filter('sql', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id']));
break;
}
}
else {

View File

@ -129,6 +129,7 @@ if($searchAlerts) {
)';
break;
case "postgresql":
case "oracle":
$whereAlerts = 'AND (
id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE \'%' . $stringSearchSQL . '%\') OR
id_alert_template IN (

View File

@ -107,6 +107,29 @@ if ($searchModules) {
t1.nombre COLLATE utf8_general_ci LIKE \'%' . $stringSearchSQL . '%\' OR
t3.nombre LIKE \'%' . $stringSearchSQL . '%\'';
break;
case "oracle":
$chunk_sql = '
FROM tagente_modulo AS t1
INNER JOIN tagente AS t2
ON t2.id_agente = t1.id_agente
INNER JOIN tgrupo AS t3
ON t3.id_grupo = t2.id_grupo
INNER JOIN tagente_estado AS t4
ON t4.id_agente_modulo = t1.id_agente_modulo
WHERE (t2.id_grupo IN (' . implode(',', $id_userGroups) . ')
OR 0 IN (
SELECT id_grupo
FROM tusuario_perfil
WHERE id_usuario = \'' . $config['id_user'] . '\'
AND id_perfil IN (
SELECT id_perfil
FROM tperfil WHERE agent_view = 1
)
)
) AND
UPPER(t1.nombre) LIKE UPPER(\'%' . $stringSearchSQL . '%\') OR
t3.nombre LIKE \'%' . $stringSearchSQL . '%\'';
break;
}
$select = "SELECT *, t1.nombre AS module_name, t2.nombre AS agent_name ";

View File

@ -123,9 +123,22 @@ switch ($config["dbtype"]) {
case "postgresql":
$sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d OFFSET %d", $pagination, $offset);
break;
case "oracle":
$set = array();
$set['limit'] = $pagination;
$set['offset'] = $offset;
$sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC");
$sql = oracle_recode_query ($sql, $set);
break;
}
$traps = get_db_all_rows_sql ($sql);
if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
for ($i=0; $i < count($traps); $i++) {
unset($traps[$i]['rnum']);
}
}
// No traps
if (empty ($traps)) {
echo '<div class="nf">'.__('There are no SNMP traps in database').'</div>';
@ -164,6 +177,9 @@ switch ($config["dbtype"]) {
case "postgresql":
$sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC LIMIT %d OFFSET %d";
break;
case "oracle":
$sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC";
break;
}
$whereSubquery = 'WHERE 1=1';
@ -173,6 +189,7 @@ if ($filter_agent != '') {
$whereSubquery .= ' AND source LIKE "' . $filter_agent . '"';
break;
case "postgresql":
case "oracle":
$whereSubquery .= ' AND source LIKE \'' . $filter_agent . '\'';
break;
}
@ -186,6 +203,7 @@ if ($filter_oid != '') {
$whereSubquery .= ' AND (text LIKE "' . $filter_oid . '" OR oid LIKE "' . $filter_oid . '")';
break;
case "postgresql":
case "oracle":
$whereSubquery .= ' AND (text LIKE \'' . $filter_oid . '\' OR oid LIKE \'' . $filter_oid . '\')';
break;
}
@ -196,6 +214,7 @@ if ($filter_oid != '') {
$whereSubquery .= ' AND oid LIKE "' . $filter_oid . '"';
break;
case "postgresql":
case "oracle":
$whereSubquery .= ' AND oid LIKE \'' . $filter_oid . '\'';
break;
}
@ -209,6 +228,7 @@ if ($search_string != '') {
$whereSubquery .= ' AND value LIKE "%' . $search_string . '%"';
break;
case "postgresql":
case "oracle":
$whereSubquery .= ' AND value LIKE \'%' . $search_string . '%\'';
break;
}
@ -235,10 +255,22 @@ switch ($config["dbtype"]) {
case "postgresql":
$sql = sprintf($sql, $whereSubquery, $pagination, $offset);
break;
case "oracle":
$set = array();
$set['limit'] = $pagination;
$set['offset'] = $offset;
$sql = oracle_recode_query ($sql, $set);
break;
}
$traps = get_db_all_rows_sql($sql);
if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
for ($i=0; $i < count($traps); $i++) {
unset($traps[$i]['rnum']);
}
}
if ($config["pure"] == 1) {
echo '<div id="filters" style="display:none;">';
}

View File

@ -57,7 +57,7 @@ if (isset ($_GET["modified"]) && !$view_mode) {
$upd_info["id_skin"] = get_parameter ("skin", $user_info["id_skin"]);
$upd_info["block_size"] = get_parameter ("block_size", $config["block_size"]);
$upd_info["flash_chart"] = get_parameter ("flash_charts", $config["flash_charts"]);
if ( !empty ($password_new)) {
if ($config["user_can_update_password"] && $password_confirm == $password_new) {
$return = update_user_password ($id, $password_new);

View File

@ -300,7 +300,7 @@ END;;
--
BEGIN
LOCK TABLE tnews IN EXCLUSIVE MODE;
INSERT INTO tnews (id_news, author, subject, text, timestamp) VALUES (1,'admin','Welcome to Pandora FMS 3.2!','This is the new Pandora FMS Console. A lot of new features have been added since last version. Please read the documentation about it, and feel free to test any option.\r\n\r\nThe Pandora FMS Team.',current_timestamp);
INSERT INTO tnews (id_news, author, subject, text, timestamp) VALUES (1,'admin','Welcome to Pandora FMS 3.2!','This is the new Pandora FMS Console. A lot of new features have been added since last version. Please read the documentation about it, and feel free to test any option.<br><br>The Pandora FMS Team.',current_timestamp);
INSERT INTO tnews (id_news, author, subject, text, timestamp) VALUES (2,'admin','New GIS Feature','Try our new GIS representation, activate GIS in Setup to see new available options.',current_timestamp);
COMMIT;
END;;
@ -509,7 +509,7 @@ COMMIT;
END;;
-- procedure to insert more than 4000 chars into a string
CREATE OR REPLACE PROCEDURE treport_custom_sql_insert (IDX IN NUMBER, NAME IN VARCHAR2, SQL_TXT IN VARCHAR2, FLAG IN NUMBER) AS g_nclob NCLOB; BEGIN if FLAG = 0 then insert into treport_custom_sql values (IDX, NAME, empty_clob()) returning SQL into g_nclob; dbms_lob.write(g_nclob, length (SQL_TXT), 1, SQL_TXT); else select SQL into g_nclob from treport_custom_sql where ID = IDX for update; dbms_lob.writeappend( g_nclob, length(SQL_TXT), SQL_TXT); end if; END;;
CREATE OR REPLACE PROCEDURE treport_custom_sql_insert (IDX IN NUMBER, NAME IN VARCHAR2, SQL_TXT IN VARCHAR2, FLAG IN NUMBER) AS g_nclob CLOB; BEGIN if FLAG = 0 then insert into treport_custom_sql values (IDX, NAME, empty_clob()) returning SQL into g_nclob; dbms_lob.write(g_nclob, length (SQL_TXT), 1, SQL_TXT); else select SQL into g_nclob from treport_custom_sql where ID = IDX for update; dbms_lob.writeappend( g_nclob, length(SQL_TXT), SQL_TXT); end if; END;;
BEGIN
treport_custom_sql_insert(4, 'Group&#x20;view', 'select&#x20;t1.nombre,&#x20;&#40;select&#x20;count&#40;t3.id_agente&#41;&#x20;from&#x20;tagente&#x20;as&#x20;t3&#x20;where&#x20;t1.id_grupo&#x20;=',0);

View File

@ -102,7 +102,7 @@ CREATE OR REPLACE TRIGGER tagente_datos_inc_inc BEFORE INSERT ON tagente_datos_i
CREATE TABLE tagente_datos_string (
id_agente_modulo NUMBER(10, 0) NOT NULL PRIMARY KEY,
datos NCLOB NOT NULL,
datos CLOB NOT NULL,
utimestamp NUMBER(10, 0) default 0 NOT NULL
);
CREATE INDEX tagente_datos_string_utsta_idx ON tagente_datos_string(utimestamp);
@ -110,9 +110,9 @@ CREATE INDEX tagente_datos_string_utsta_idx ON tagente_datos_string(utimestamp);
CREATE TABLE tagente_datos_log4x (
id_tagente_datos_log4x NUMBER(19, 0) NOT NULL PRIMARY KEY,
id_agente_modulo NUMBER(10, 0) default 0 NOT NULL,
severity NCLOB NOT NULL,
message NCLOB NOT NULL,
stacktrace NCLOB NOT NULL,
severity CLOB NOT NULL,
message CLOB NOT NULL,
stacktrace CLOB NOT NULL,
utimestamp NUMBER(10, 0) default 0 NOT NULL
);
CREATE INDEX tagente_datos_log4x_id_a_m_idx ON tagente_datos_log4x(id_agente_modulo);
@ -124,7 +124,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 NCLOB default '' NOT NULL,
datos CLOB default '' NOT NULL,
timestamp TIMESTAMP default NULL,
estado NUMBER(10, 0) default 0 NOT NULL,
id_agente NUMBER(10, 0) default 0 NOT NULL,
@ -161,15 +161,15 @@ 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 NCLOB default '' NOT NULL,
nombre NCLOB default '' NOT NULL,
descripcion CLOB default '' NOT NULL,
nombre CLOB default '' NOT NULL,
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,
module_interval NUMBER(10, 0) default 0 NOT NULL,
tcp_port NUMBER(10, 0) default 0 NOT NULL,
tcp_send NCLOB default '',
tcp_rcv NCLOB default '',
tcp_send CLOB default '',
tcp_rcv CLOB default '',
snmp_community VARCHAR2(100) default '',
snmp_oid VARCHAR2(255) default '0',
ip_target VARCHAR2(100) default '',
@ -178,9 +178,9 @@ CREATE TABLE tagente_modulo (
id_modulo NUMBER(10, 0) default 0 NOT NULL,
disabled NUMBER(5, 0) default 0 NOT NULL,
id_export NUMBER(10, 0) default 0 NOT NULL,
plugin_user NCLOB default '',
plugin_pass NCLOB default '',
plugin_parameter NCLOB,
plugin_user CLOB default '',
plugin_pass CLOB default '',
plugin_parameter CLOB,
id_plugin NUMBER(10, 0) default 0,
post_process BINARY_DOUBLE default NULL,
prediction_module NUMBER(19, 0) default 0,
@ -195,9 +195,9 @@ CREATE TABLE tagente_modulo (
delete_pending NUMBER(5, 0) default 0 NOT NULL,
policy_linked NUMBER(5, 0) default 0 NOT NULL,
policy_adopted NUMBER(5, 0) default 0 NOT NULL,
custom_string_1 NCLOB default '',
custom_string_2 NCLOB default '',
custom_string_3 NCLOB default '',
custom_string_1 CLOB default '',
custom_string_2 CLOB default '',
custom_string_3 CLOB default '',
custom_integer_1 NUMBER(10, 0) default 0,
custom_integer_2 NUMBER(10, 0) default 0
);
@ -221,9 +221,9 @@ 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 NCLOB default '' NOT NULL,
al_field2 NCLOB default '' NOT NULL,
al_field3 NCLOB default '' NOT NULL,
al_field1 CLOB default '' NOT NULL,
al_field2 CLOB default '' NOT NULL,
al_field3 CLOB default '' NOT NULL,
description VARCHAR2(255) default '',
alert_type NUMBER(5, 0) default 0 NOT NULL,
agent VARCHAR2(100) default '',
@ -245,8 +245,8 @@ 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,
command NCLOB default '',
description NCLOB default '',
command CLOB default '',
description CLOB default '',
internal NUMBER(10, 0) default 0
);
@ -256,11 +256,11 @@ CREATE OR REPLACE TRIGGER talert_commands_inc BEFORE INSERT ON talert_commands R
CREATE TABLE talert_actions (
id NUMBER(10, 0) NOT NULL PRIMARY KEY,
name NCLOB default '',
name CLOB default '',
id_alert_command NUMBER(10, 0) NOT NULL REFERENCES talert_commands(id) ON DELETE CASCADE,
field1 NCLOB default '' NOT NULL,
field2 NCLOB default '',
field3 NCLOB default '',
field1 CLOB default '' NOT NULL,
field2 CLOB default '',
field3 CLOB default '',
id_group NUMBER(19, 0) default 0 NOT NULL,
action_threshold NUMBER(19, 0) default 0 NOT NULL
);
@ -276,12 +276,12 @@ CREATE OR REPLACE TRIGGER talert_actions_update AFTER UPDATE OF ID ON talert_com
-- use to_char(time_to, 'hh24:mi:ss') function to retrieve time_to field info
CREATE TABLE talert_templates (
id NUMBER(10, 0) NOT NULL PRIMARY KEY,
name NCLOB default '',
description NCLOB,
name CLOB default '',
description CLOB,
id_alert_action NUMBER(10, 0) REFERENCES talert_actions(id) ON DELETE SET NULL,
field1 NCLOB default '',
field2 NCLOB default '',
field3 NCLOB NOT NULL,
field1 CLOB default '',
field2 CLOB default '',
field3 CLOB NOT NULL,
type VARCHAR2(50),
value VARCHAR2(255) default '',
matches_value NUMBER(5, 0) default 0,
@ -300,8 +300,8 @@ 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 NCLOB default '' NOT NULL,
field3_recovery NCLOB NOT NULL,
field2_recovery CLOB default '' NOT NULL,
field3_recovery CLOB NOT NULL,
priority NUMBER(10, 0) default 0 NOT NULL,
id_group NUMBER(10, 0) default 0 NOT NULL,
CONSTRAINT t_alert_templates_type_cons CHECK (type IN ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown'))
@ -364,7 +364,7 @@ CREATE OR REPLACE TRIGGER talert_template_mod_ac_update1 AFTER UPDATE OF ID ON t
CREATE TABLE talert_compound (
id NUMBER(10, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(255) default '',
description NCLOB,
description CLOB,
id_agent NUMBER(10, 0) NOT NULL REFERENCES tagente(id_agente) ON DELETE CASCADE,
time_threshold NUMBER(10, 0) default 0 NOT NULL,
max_alerts NUMBER(10, 0) default 1 NOT NULL,
@ -380,7 +380,7 @@ CREATE TABLE talert_compound (
sunday NUMBER(5, 0) default 1,
recovery_notify NUMBER(5, 0) default 0,
field2_recovery VARCHAR2(255) default '' NOT NULL,
field3_recovery NCLOB NOT NULL,
field3_recovery CLOB NOT NULL,
internal_counter NUMBER(10, 0) default 0,
last_fired NUMBER(19, 0) default 0 NOT NULL,
last_reference NUMBER(19, 0) default 0 NOT NULL,
@ -472,13 +472,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 NCLOB default '' NOT NULL,
evento CLOB default '' NOT NULL,
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 NCLOB NOT NULL,
user_comment CLOB NOT NULL,
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 +496,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 NCLOB default '' NOT NULL,
nombre CLOB default '' NOT NULL,
icon VARCHAR2(50) default 'world',
parent NUMBER(10, 0) default 0 NOT NULL,
propagate NUMBER(5, 0) default 0,
@ -512,8 +512,8 @@ CREATE TABLE tincidencia (
id_incidencia NUMBER(19, 0) NOT NULL PRIMARY KEY,
inicio TIMESTAMP default NULL,
cierre TIMESTAMP default NULL,
titulo NCLOB default '' NOT NULL,
descripcion NCLOB NOT NULL,
titulo CLOB default '' NOT NULL,
descripcion CLOB NOT NULL,
id_usuario VARCHAR2(60) default '' NOT NULL,
origen VARCHAR2(100) default '' NOT NULL,
estado NUMBER(10, 0) default 0 NOT NULL,
@ -554,7 +554,7 @@ 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,
mensaje NCLOB NOT NULL,
mensaje CLOB NOT NULL,
timestamp NUMBER(19, 0) default 0 NOT NULL,
subject VARCHAR2(255) default '' NOT NULL,
estado NUMBER(10, 0) default 0 NOT NULL
@ -576,23 +576,23 @@ CREATE OR REPLACE TRIGGER tmodule_group_inc BEFORE INSERT ON tmodule_group REFER
CREATE TABLE tnetwork_component (
id_nc NUMBER(10, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(80) NOT NULL,
description VARCHAR2(250) default NULL,
description VARCHAR2(300) default NULL,
id_group NUMBER(10, 0) default 1 NOT NULL,
type NUMBER(10, 0) default 6 NOT NULL,
max NUMBER(10, 0) default 0 NOT NULL,
min NUMBER(19, 0) default 0 NOT NULL,
module_interval NUMBER(19, 0) default 0 NOT NULL,
tcp_port NUMBER(10, 0) default 0 NOT NULL,
tcp_send NCLOB NOT NULL,
tcp_rcv NCLOB NOT NULL,
tcp_send CLOB NOT NULL,
tcp_rcv CLOB NOT NULL,
snmp_community VARCHAR2(255) default 'NULL' NOT NULL,
snmp_oid VARCHAR2(400) NOT NULL,
id_module_group NUMBER(10, 0) default 0 NOT NULL,
id_modulo NUMBER(10, 0) default 0 NOT NULL,
id_plugin NUMBER(10, 0) default 0,
plugin_user NCLOB default '',
plugin_pass NCLOB default '',
plugin_parameter NCLOB,
plugin_user CLOB default '',
plugin_pass CLOB default '',
plugin_parameter CLOB,
max_timeout NUMBER(10, 0) default 0,
history_data NUMBER(5, 0) default 1,
min_warning BINARY_DOUBLE default 0,
@ -600,9 +600,9 @@ CREATE TABLE tnetwork_component (
min_critical BINARY_DOUBLE default 0,
max_critical BINARY_DOUBLE default 0,
min_ff_event NUMBER(10, 0) default 0,
custom_string_1 NCLOB default '',
custom_string_2 NCLOB default '',
custom_string_3 NCLOB default '',
custom_string_1 CLOB default '',
custom_string_2 CLOB default '',
custom_string_3 CLOB default '',
custom_integer_1 INTEGER default 0,
custom_integer_2 INTEGER default 0,
post_process BINARY_DOUBLE default 0
@ -640,7 +640,7 @@ CREATE TABLE tnota (
id_incident NUMBER(19, 0) NOT NULL,
id_usuario VARCHAR2(100) default '0' NOT NULL,
timestamp TIMESTAMP default CURRENT_TIMESTAMP,
nota NCLOB NOT NULL
nota CLOB NOT NULL
);
CREATE INDEX tnota_id_incident_idx ON tnota(id_incident);
@ -670,7 +670,7 @@ CREATE OR REPLACE TRIGGER tperfil_inc BEFORE INSERT ON tperfil REFERENCING NEW A
CREATE TABLE trecon_script (
id_recon_script NUMBER(10, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(100) default '',
description NCLOB default NULL,
description CLOB default NULL,
script VARCHAR2(250) default ''
);
@ -759,7 +759,7 @@ CREATE TABLE tsesion (
ID_usuario VARCHAR2(60) default '0' NOT NULL,
IP_origen VARCHAR2(100) default '' NOT NULL,
accion VARCHAR2(100) default '' NOT NULL,
descripcion NCLOB default '' NOT NULL,
descripcion CLOB default '' NOT NULL,
fecha TIMESTAMP default NULL,
utimestamp NUMBER(19, 0) default 0 NOT NULL
);
@ -785,12 +785,12 @@ 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 NCLOB default '' NOT NULL,
oid_custom NCLOB default '',
oid CLOB default '' NOT NULL,
oid_custom CLOB default '',
type NUMBER(10, 0) default 0 NOT NULL,
type_custom VARCHAR2(100) default '',
value NCLOB default '',
value_custom NCLOB default '',
value CLOB default '',
value_custom CLOB default '',
alerted NUMBER(5, 0) default 0 NOT NULL,
status NUMBER(5, 0) default 0 NOT NULL,
id_usuario VARCHAR2(150) default '',
@ -837,7 +837,7 @@ CREATE TABLE tnews (
id_news NUMBER(10, 0) NOT NULL PRIMARY KEY,
author VARCHAR2(255) DEFAULT '' NOT NULL,
subject VARCHAR2(255) DEFAULT '' NOT NULL,
text NCLOB NOT NULL,
text CLOB NOT NULL,
timestamp TIMESTAMP default NULL
);
@ -849,7 +849,7 @@ 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,
description NCLOB NOT NULL,
description CLOB NOT NULL,
period NUMBER(10, 0) default 0 NOT NULL,
width NUMBER(10, 0) default 0 NOT NULL,
height NUMBER(10, 0) default 0 NOT NULL,
@ -878,13 +878,13 @@ 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,
description NCLOB NOT NULL,
description CLOB NOT NULL,
private NUMBER(5, 0) default 0 NOT NULL,
id_group NUMBER(19, 0) default 0 NOT NULL,
custom_logo VARCHAR2(200) default NULL,
header NCLOB default NULL,
first_page NCLOB default NULL,
footer NCLOB default NULL,
header CLOB default NULL,
first_page CLOB default NULL,
footer CLOB default NULL,
custom_font VARCHAR2(200) default NULL
);
@ -905,14 +905,14 @@ CREATE TABLE treport_content (
type VARCHAR2(30) default 'simple_graph',
period NUMBER(19, 0) default 0 NOT NULL,
"order" NUMBER(19, 0) default 0 NOT NULL,
description NCLOB,
description CLOB,
id_agent NUMBER(19, 0) default 0 NOT NULL,
text NCLOB default NULL,
external_source NCLOB default NULL,
text CLOB default NULL,
external_source CLOB default NULL,
treport_custom_sql_id NUMBER(10, 0) default 0,
header_definition NCLOB default NULL,
column_separator NCLOB default NULL,
line_separator NCLOB default NULL,
header_definition CLOB default NULL,
column_separator CLOB default NULL,
line_separator CLOB default NULL,
time_from TIMESTAMP default to_date('00:00:00','hh24:mi:ss'),
time_to TIMESTAMP default to_date('00:00:00','hh24:mi:ss'),
monday NUMBER(5, 0) default 1 NOT NULL,
@ -931,7 +931,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 NCLOB default '' NOT NULL,
style CLOB default '' NOT NULL,
id_group NUMBER(10, 0) default 0 NOT NULL,
id_module_group NUMBER(10, 0) default 0 NOT NULL
);
@ -976,7 +976,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,
sql NCLOB default NULL
sql CLOB default NULL
);
CREATE SEQUENCE treport_custom_sql_s INCREMENT BY 1 START WITH 1;
@ -1023,7 +1023,7 @@ CREATE OR REPLACE TRIGGER tlayout_data_inc BEFORE INSERT ON tlayout_data REFEREN
CREATE TABLE tplugin (
id NUMBER(10, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(200) NOT NULL,
description NCLOB,
description CLOB,
max_timeout NUMBER(10, 0) default 0 NOT NULL,
execute VARCHAR2(250) NOT NULL,
net_dst_opt VARCHAR2(50) default '',
@ -1087,7 +1087,7 @@ CREATE OR REPLACE TRIGGER tserver_export_data_inc BEFORE INSERT ON tserver_expor
CREATE TABLE tplanned_downtime (
id NUMBER(19, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(100) NOT NULL,
description NCLOB NOT NULL,
description CLOB NOT NULL,
date_from NUMBER(19, 0) default 0 NOT NULL,
date_to NUMBER(19, 0) default 0 NOT NULL,
executed NUMBER(5, 0) default 0 NOT NULL,
@ -1125,7 +1125,7 @@ CREATE TABLE tgis_data_history (
--timestamp on wich the agent was placed for last time on this position
end_timestamp TIMESTAMP default NULL,
--description of the region correoponding to this placemnt
description NCLOB DEFAULT NULL,
description CLOB DEFAULT NULL,
-- 0 to show that the position cames from the agent, 1 to show that the position was established manualy
manual_placement NUMBER(5, 0) default 0 NOT NULL,
-- Number of data packages received with this position from the start_timestampa to the_end_timestamp
@ -1167,7 +1167,7 @@ CREATE TABLE tgis_data_status (
--0 to show that the position cames from the agent, 1 to show that the position was established manualy
manual_placement NUMBER(5, 0) default 0 NOT NULL,
--description of the region correoponding to this placemnt
description NCLOB NULL,
description CLOB NULL,
PRIMARY KEY(tagente_id_agente)
);
CREATE INDEX tgis_data_status_start_t_idx ON tgis_data_status(start_timestamp);
@ -1220,7 +1220,7 @@ CREATE TABLE tgis_map_connection (
--Type of map server to connect
connection_type VARCHAR2(45) DEFAULT NULL,
--connection information (this can probably change to fit better the possible connection parameters)
conection_data NCLOB DEFAULT NULL,
conection_data CLOB DEFAULT NULL,
--Number of zoom levels available
num_zoom_levels NUMBER(5, 0) DEFAULT NULL,
--Default Zoom Level for the connection
@ -1345,7 +1345,7 @@ CREATE TABLE tnetwork_map (
zoom BINARY_DOUBLE default 1,
distance_nodes BINARY_DOUBLE default 2.5,
center NUMBER(10, 0) default 0 NOT NULL,
contracted_nodes NCLOB
contracted_nodes CLOB
);
CREATE SEQUENCE tnetwork_map_s INCREMENT BY 1 START WITH 1;
@ -1384,7 +1384,7 @@ CREATE OR REPLACE TRIGGER tagent_custom_fields_inc BEFORE INSERT ON tagent_custo
CREATE TABLE tagent_custom_data (
id_field NUMBER(10, 0) NOT NULL REFERENCES tagent_custom_fields(id_field) ON DELETE CASCADE,
id_agent NUMBER(10, 0) NOT NULL REFERENCES tagente(id_agente) ON DELETE CASCADE,
description NCLOB default '',
description CLOB default '',
PRIMARY KEY (id_field, id_agent)
);