2012-08-29 Miguel de Dios <miguel.dedios@artica.es>

* pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
	include/db/mysql.php,
	extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
	extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
	extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
	godmode/agentes/planned_downtime.list.php,
	godmode/agentes/planned_downtime.editor.php, godmode/menu.php,
	include/ajax/planned_downtime.ajax.php: refactoriced the code for
	planned downtime, now this have new feature such as set a downtime
	with a periodicity each week, each month and set the agents and
	the modules with Quiet state instead the old form (but the old still
	is). And the page is more easy and quickly to set or config a
	planned downtime.
	
	* godmode/alerts/configure_alert_template.php,
	include/javascript/pandora.js: cleaned source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6919 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-08-29 09:46:05 +00:00
parent bd5abdf277
commit d14eeb3887
14 changed files with 1160 additions and 218 deletions

View File

@ -1,3 +1,22 @@
2012-08-29 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
include/db/mysql.php,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
godmode/agentes/planned_downtime.list.php,
godmode/agentes/planned_downtime.editor.php, godmode/menu.php,
include/ajax/planned_downtime.ajax.php: refactoriced the code for
planned downtime, now this have new feature such as set a downtime
with a periodicity each week, each month and set the agents and
the modules with Quiet state instead the old form (but the old still
is). And the page is more easy and quickly to set or config a
planned downtime.
* godmode/alerts/configure_alert_template.php,
include/javascript/pandora.js: cleaned source code style.
2012-06-27 Vanessa Gil <vanessa.gil@artica.es>
* extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,

View File

@ -73,6 +73,24 @@ CREATE TABLE IF NOT EXISTS `talert_special_days` (
-- -----------------------------------------------------
ALTER TABLE `talert_templates` ADD COLUMN `special_day` tinyint(1) DEFAULT '0';
-- -----------------------------------------------------
-- Table `tplanned_downtime`
-- -----------------------------------------------------
ALTER TABLE `tplanned_downtime` ADD COLUMN `monday` tinyint(1) default 0;
ALTER TABLE `tplanned_downtime` ADD COLUMN `tuesday` tinyint(1) default 0;
ALTER TABLE `tplanned_downtime` ADD COLUMN `wednesday` tinyint(1) default 0;
ALTER TABLE `tplanned_downtime` ADD COLUMN `thursday` tinyint(1) default 0;
ALTER TABLE `tplanned_downtime` ADD COLUMN `friday` tinyint(1) default 0;
ALTER TABLE `tplanned_downtime` ADD COLUMN `saturday` tinyint(1) default 0;
ALTER TABLE `tplanned_downtime` ADD COLUMN `sunday` tinyint(1) default 0;
ALTER TABLE `tplanned_downtime` ADD COLUMN `periodically_time_from` time NULL default NULL;
ALTER TABLE `tplanned_downtime` ADD COLUMN `periodically_time_to` time NULL default NULL;
ALTER TABLE `tplanned_downtime` ADD COLUMN `periodically_day_from` int(100) unsigned default NULL;
ALTER TABLE `tplanned_downtime` ADD COLUMN `periodically_day_to` int(100) unsigned default NULL;
ALTER TABLE `tplanned_downtime` ADD COLUMN `type_downtime` varchar(100) NOT NULL default 'disabled_agents_alerts';
ALTER TABLE `tplanned_downtime` ADD COLUMN `type_execution` varchar(100) NOT NULL default 'once';
ALTER TABLE `tplanned_downtime` ADD COLUMN `type_periodicity` varchar(100) NOT NULL default 'weekly';
-- -----------------------------------------------------
-- Table `tplanned_downtime_agents`
-- -----------------------------------------------------
@ -83,6 +101,21 @@ ALTER TABLE tplanned_downtime_agents
ADD FOREIGN KEY(`id_downtime`) REFERENCES tplanned_downtime(`id`)
ON DELETE CASCADE;
ALTER TABLE `tplanned_downtime_agents` ADD COLUMN `all_modules` tinyint(1) default 1;
-- -----------------------------------------------------
-- Table `tplanned_downtime_modules`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` (
`id` int(20) unsigned NOT NULL auto_increment,
`id_agent` mediumint(8) unsigned NOT NULL default '0',
`id_agent_module` int(10) NOT NULL,
`id_downtime` mediumint(8) NOT NULL default '0',
PRIMARY KEY (`id`),
FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tevento`
-- -----------------------------------------------------

View File

@ -68,13 +68,13 @@ CREATE OR REPLACE TRIGGER tnetflow_report_content_inc BEFORE INSERT ON tnetflow_
-- -----------------------------------------------------
-- Table `tincidencia`
-- -----------------------------------------------------
alter table tincidencia add (id_agent NUMBER(10,0) default 0 NULL);
ALTER TABLE tincidencia ADD (id_agent NUMBER(10,0) default 0 NULL);
-- -----------------------------------------------------
-- Table `tagente`
-- -----------------------------------------------------
alter table tagente add (url_address CLOB default '' NULL);
alter table tagente add (quiet NUMBER(5, 0) default 0 NOT NULL);
ALTER TABLE tagente ADD (url_address CLOB default '' NULL);
ALTER TABLE tagente ADD (quiet NUMBER(5, 0) default 0 NOT NULL);
-- -----------------------------------------------------
-- Table `talert_special_days`
@ -93,39 +93,69 @@ CREATE OR REPLACE TRIGGER talert_special_days_inc BEFORE INSERT ON talert_specia
-- -----------------------------------------------------
-- Table `talert_templates`
-- -----------------------------------------------------
alter table talert_templates add (special_day NUMBER(5,0) default 0);
ALTER TABLE talert_templates ADD (special_day NUMBER(5,0) default 0);
-- -----------------------------------------------------
-- Table `talert_templates`
-- -----------------------------------------------------
ALTER TABLE tplanned_downtime ADD (monday NUMBER(5, 0) default 0);
ALTER TABLE tplanned_downtime ADD (tuesday NUMBER(5, 0) default 0);
ALTER TABLE tplanned_downtime ADD (wednesday NUMBER(5, 0) default 0);
ALTER TABLE tplanned_downtime ADD (thursday NUMBER(5, 0) default 0);
ALTER TABLE tplanned_downtime ADD (friday NUMBER(5, 0) default 0);
ALTER TABLE tplanned_downtime ADD (saturday NUMBER(5, 0) default 0);
ALTER TABLE tplanned_downtime ADD (sunday NUMBER(5, 0) default 0);
ALTER TABLE tplanned_downtime ADD (periodically_time_from DATE default NULL);
ALTER TABLE tplanned_downtime ADD (periodically_time_to DATE default NULL);
ALTER TABLE tplanned_downtime ADD (periodically_day_from NUMBER(19, 0) default NULL);
ALTER TABLE tplanned_downtime ADD (periodically_day_to NUMBER(19, 0) default NULL);
ALTER TABLE tplanned_downtime ADD (type_downtime VARCHAR2(100) NOT NULL default 'disabled_agents_alerts');
ALTER TABLE tplanned_downtime ADD (type_execution VARCHAR2(100) NOT NULL default 'once');
ALTER TABLE tplanned_downtime ADD (type_periodicity VARCHAR2(100) NOT NULL default 'weekly');
-- -----------------------------------------------------
-- Table `tplanned_downtime_agents`
-- -----------------------------------------------------
DELETE FROM tplanned_downtime_agents
WHERE id_downtime NOT IN (SELECT id FROM tplanned_downtime);
alter table tplanned_downtime_agents
ALTER TABLE tplanned_downtime_agents
add constraint tplanned_downtimes_foreign_key
foreign key (id_downtime)
references tplanned_downtime (id);
ALTER TABLE tplanned_downtime_agents ADD (all_modules NUMBER(5, 0) default 1);
-- -----------------------------------------------------
-- Table `tplanned_downtime_modules`
-- -----------------------------------------------------
CREATE TABLE tplanned_downtime_modules (
id NUMBER(19, 0) NOT NULL PRIMARY KEY,
id_agent NUMBER(19, 0) default 0 NOT NULL,
id_agent_module NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_downtime NUMBER(19, 0) default 0 NOT NULL REFERENCES tplanned_downtime(id) ON DELETE CASCADE
);
CREATE SEQUENCE tplanned_downtime_modules_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tplanned_downtime_modules_inc BEFORE INSERT ON tplanned_downtime_modules REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_modules_s.nextval INTO :NEW.ID FROM dual; END tplanned_downtime_modules_inc;;
-- -----------------------------------------------------
-- Table `tevento`
-- -----------------------------------------------------
alter table tevento add (source VARCHAR2(100) default '' NOT NULL);
alter table tevento add (id_extra VARCHAR2(100) default '' NOT NULL);
ALTER TABLE tevento ADD (source VARCHAR2(100) default '' NOT NULL);
ALTER TABLE tevento ADD (id_extra VARCHAR2(100) default '' NOT NULL);
-- -----------------------------------------------------
-- Table `talert_snmp`
-- -----------------------------------------------------
ALTER TABLE talert_snmp add (_snmp_f1_ CLOB default '');
ALTER TABLE talert_snmp add (_snmp_f2_ CLOB default '');
ALTER TABLE talert_snmp add (_snmp_f3_ CLOB default '');
ALTER TABLE talert_snmp add (_snmp_f4_ CLOB default '');
ALTER TABLE talert_snmp add (_snmp_f5_ CLOB default '');
ALTER TABLE talert_snmp add (_snmp_f6_ CLOB default '');
ALTER TABLE talert_snmp add (trap_type NUMBER(10, 0) DEFAULT -1 NOT NULL);
ALTER TABLE talert_snmp add (single_value VARCHAR2(255) DEFAULT '');
ALTER TABLE talert_snmp ADD (_snmp_f1_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f2_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f3_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f4_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f5_ CLOB default '');
ALTER TABLE talert_snmp ADD (_snmp_f6_ CLOB default '');
ALTER TABLE talert_snmp ADD (trap_type NUMBER(10, 0) DEFAULT -1 NOT NULL);
ALTER TABLE talert_snmp ADD (single_value VARCHAR2(255) DEFAULT '');
-- -----------------------------------------------------
-- Table `tevent_filter`
@ -190,7 +220,7 @@ ALTER TABLE tmensajes MODIFY mensaje VARCHAR2(255) NOT NULL DEFAULT '';
-- Table `talert_compound`
-- -----------------------------------------------------
alter table talert_compound add (special_day NUMBER(5,0) default 0);
ALTER TABLE talert_compound ADD (special_day NUMBER(5,0) default 0);
-- -----------------------------------------------------
-- Table `tnetwork_component`

View File

@ -23,11 +23,11 @@ ALTER TABLE "tusuario" ADD COLUMN "not_login" SMALLINT NOT NULL default 0;
-- -----------------------------------------------------
CREATE TABLE "tnetflow_filter" (
"id_sg" SERIAL NOT NULL PRIMARY KEY,
"id_name" varchar(600) NOT NULL default '',
"id_group" INTEGER,
"ip_dst" TEXT NOT NULL,
"id_name" varchar(600) NOT NULL default '',
"id_group" INTEGER,
"ip_dst" TEXT NOT NULL,
"ip_src" TEXT NOT NULL,
"dst_port" TEXT NOT NULL,
"dst_port" TEXT NOT NULL,
"src_port" TEXT NOT NULL,
"advanced_filter" TEXT NOT NULL,
"filter_args" TEXT NOT NULL,
@ -39,19 +39,19 @@ CREATE TABLE "tnetflow_filter" (
-- Table `tnetflow_report`
-- -----------------------------------------------------
CREATE TABLE "tnetflow_report" (
"id_report" SERIAL NOT NULL PRIMARY KEY,
"id_name" varchar(150) NOT NULL default '',
"id_report" SERIAL NOT NULL PRIMARY KEY,
"id_name" varchar(150) NOT NULL default '',
"description" TEXT,
"id_group" INTEGER
"id_group" INTEGER
);
-- -----------------------------------------------------
-- Table `tnetflow_report_content`
-- -----------------------------------------------------
CREATE TABLE "tnetflow_report_content" (
"id_rc" SERIAL NOT NULL PRIMARY KEY,
"id_rc" SERIAL NOT NULL PRIMARY KEY,
"id_report" INTEGER NOT NULL default 0 REFERENCES tnetflow_report("id_report") ON DELETE CASCADE,
"id_filter" INTEGER NOT NULL default 0 REFERENCES tnetflow_filter("id_sg") ON DELETE CASCADE,
"id_filter" INTEGER NOT NULL default 0 REFERENCES tnetflow_filter("id_sg") ON DELETE CASCADE,
"date" BIGINT NOT NULL default 0,
"period" INTEGER NOT NULL default 0,
"max" INTEGER NOT NULL default 0,
@ -88,6 +88,24 @@ CREATE TABLE "talert_special_days" (
ALTER TABLE "talert_templates" ADD COLUMN "special_day" SMALLINT default 0;
-- -----------------------------------------------------
-- Table `tplanned_downtime`
-- -----------------------------------------------------
ALTER TABLE "tplanned_downtime" ADD COLUMN "monday" SMALLINT default 0;
ALTER TABLE "tplanned_downtime" ADD COLUMN "tuesday" SMALLINT default 0;
ALTER TABLE "tplanned_downtime" ADD COLUMN "wednesday" SMALLINT default 0;
ALTER TABLE "tplanned_downtime" ADD COLUMN "thursday" SMALLINT default 0;
ALTER TABLE "tplanned_downtime" ADD COLUMN "friday" SMALLINT default 0;
ALTER TABLE "tplanned_downtime" ADD COLUMN "saturday" SMALLINT default 0;
ALTER TABLE "tplanned_downtime" ADD COLUMN "sunday" SMALLINT default 0;
ALTER TABLE "tplanned_downtime" ADD COLUMN "periodically_time_from" TIME default NULL;
ALTER TABLE "tplanned_downtime" ADD COLUMN "periodically_time_to" TIME default NULL;
ALTER TABLE "tplanned_downtime" ADD COLUMN "periodically_day_from" SMALLINT default NULL;
ALTER TABLE "tplanned_downtime" ADD COLUMN "periodically_day_to" SMALLINT default NULL;
ALTER TABLE "tplanned_downtime" ADD COLUMN "type_downtime" VARCHAR( 100 ) NOT NULL default 'disabled_agents_alerts';
ALTER TABLE "tplanned_downtime" ADD COLUMN "type_execution" VARCHAR( 100 ) NOT NULL default 'once';
ALTER TABLE "tplanned_downtime" ADD COLUMN "type_periodicity" VARCHAR( 100 ) NOT NULL default 'weekly';
-- -----------------------------------------------------
-- Table `tplanned_downtime_agents`
-- -----------------------------------------------------
@ -99,6 +117,18 @@ ADD CONSTRAINT downtime_foreign
FOREIGN KEY("id_downtime")
REFERENCES "tplanned_downtime"("id");
ALTER TABLE "tplanned_downtime_agents" ADD COLUMN "all_modules" SMALLINT default 1;
-- -----------------------------------------------------
-- Table "tplanned_downtime_modules"
-- -----------------------------------------------------
CREATE TABLE "tplanned_downtime_modules" (
"id" BIGSERIAL NOT NULL PRIMARY KEY,
"id_agent" BIGINT NOT NULL default 0,
"id_agent_module" INTEGER NOT NULL default 0,
"id_downtime" BIGINT NOT NULL REFERENCES tplanned_downtime("id") ON DELETE CASCADE
);
-- -----------------------------------------------------
-- Table `tevento`
-- -----------------------------------------------------

View File

@ -44,15 +44,18 @@ check_login();
//Initialize data
$id_agent = get_parameter ("id_agent");
$id_group = (int) get_parameter ("id_group", 0);
$name = '';
$description = '';
$date_from = (string) get_parameter ('date_from', date ('Y-m-j'));
$time_from = (string) get_parameter ('time_from', date ('h:iA'));
$date_to = (string) get_parameter ('date_to', date ('Y-m-j'));
$time_to = (string) get_parameter ('time_to', date ('h:iA'));
$name = (string) get_parameter ('name', '');
$description = (string) get_parameter ('description', '');
$once_date_from = (string) get_parameter ('date_from', date ('Y-m-j'));
$once_time_from = (string) get_parameter ('time_from', date ('h:iA'));
$once_date_to = (string) get_parameter ('date_to', date ('Y-m-j'));
$once_time_to = (string) get_parameter ('time_to', date ('h:iA'));
$periodically_day_from = (int) get_parameter ('periodically_day_from', 1);
$periodically_day_to = (int) get_parameter ('periodically_day_to', 31);
$periodically_time_from = (string) get_parameter ('periodically_time_from', date ('h:iA'));
$periodically_time_to = (string) get_parameter ('periodically_time_to', date ('h:iA'));
$first_create = (int) get_parameter ('first_create', 0);
$first_update = (int) get_parameter ('first_update', 0);
$create_downtime = (int) get_parameter ('create_downtime');
@ -66,7 +69,17 @@ $delete_downtime_agent = (int) get_parameter ("delete_downtime_agent", 0);
$groups = users_get_groups ();
$only_alerts = (bool) get_parameter ('only_alerts', 0);
$type_downtime = get_parameter('type_downtime', 'quiet');
$type_execution = get_parameter('type_execution', 'once');
$type_periodicity = get_parameter('type_periodicity', 'weekly');
$monday = (bool) get_parameter ('monday');
$tuesday = (bool) get_parameter ('tuesday');
$wednesday = (bool) get_parameter ('wednesday');
$thursday = (bool) get_parameter ('thursday');
$friday = (bool) get_parameter ('friday');
$saturday = (bool) get_parameter ('saturday');
$sunday = (bool) get_parameter ('sunday');
// STOP DOWNTIME
if ($stop_downtime == 1) {
@ -80,7 +93,7 @@ if ($stop_downtime == 1) {
$only_alerts = $result['only_alerts'];
$date_stop = date ("Y-m-j",get_system_time ());
$time_stop = date ("h:iA",get_system_time ());
$date_time_stop = strtotime ($date_stop.' '.$time_stop);
$date_time_stop = strtotime ($date_stop . ' ' . $time_stop);
$values = array(
'name' => $name,
@ -97,33 +110,66 @@ if ($stop_downtime == 1) {
// INSERT A NEW DOWNTIME_AGENT ASSOCIATION
if ($insert_downtime_agent == 1) {
$agents = $_POST["id_agent"];
$agents = (array)get_parameter("id_agents", array());
$module_names = (array)get_parameter("module", array());
$all_modules = false;
if (empty($module_names))
$all_modules = true;
else {
//It is empty.
if ($module_names[0] === 0)
$all_modules = true;
}
for ($a=0;$a <count($agents); $a++) {
$id_agente_dt = $agents[$a];
$values = array(
'id_downtime' => $id_downtime,
'id_agent' => $id_agente_dt);
'id_agent' => $id_agente_dt,
'all_modules' => $all_modules);
$result = db_process_sql_insert('tplanned_downtime_agents', $values);
if ($result && !$all_modules) {
foreach ($module_names as $module_name) {
$module =
modules_get_agentmodule_id($module_name, $id_agente_dt);
$values = array(
'id_downtime' => $id_downtime,
'id_agent' => $id_agente_dt,
'id_agent_module' => $module["id_agente_modulo"]);
$result = db_process_sql_insert('tplanned_downtime_modules', $values);
}
}
}
}
// DELETE A DOWNTIME_AGENT ASSOCIATION
if ($delete_downtime_agent == 1) {
$id_da = get_parameter ("id_downtime_agent");
$id_da = (int)get_parameter ("id_downtime_agent", 0);
$id_agent_delete = (int)get_parameter('id_agent', 0);
$result = db_process_sql_delete('tplanned_downtime_agents', array('id' => $id_da));
$row_to_delete = db_get_row('tplanned_downtime_agents', 'id', $id_da);
$result = db_process_sql_delete('tplanned_downtime_agents',
array('id' => $id_da));
if ($result) {
//Delete modules in downtime
db_process_sql_delete('tplanned_downtime_modules',
array('id_downtime' => $row_to_delete['id_downtime'],
'id_agent' => $id_agent_delete));
}
}
// UPDATE OR CREATE A DOWNTIME (MAIN DATA, NOT AGENT ASSOCIATION)
if ($create_downtime || $update_downtime) {
$description = (string) get_parameter ('description');
$name = (string) get_parameter ('name');
$check = db_get_value ('name', 'tplanned_downtime', 'name', $name);
$datetime_from = strtotime ($date_from.' '.$time_from);
$datetime_to = strtotime ($date_to.' '.$time_to);
$datetime_from = strtotime ($once_date_from.' '.$once_time_from);
$datetime_to = strtotime ($once_date_to.' '.$once_time_to);
if ($datetime_from > $datetime_to) {
echo '<h3 class="error">'.__('Not created. Error inserting data').': START &gt; END</h3>';
@ -138,9 +184,26 @@ if ($create_downtime || $update_downtime) {
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'executed' => 0,
'id_group' => $id_group,
'only_alerts' => (int)$only_alerts);
$result = db_process_sql_insert('tplanned_downtime', $values);
'only_alerts' => 0,
'monday' => $monday,
'tuesday' => $tuesday,
'wednesday' => $wednesday,
'thursday' => $thursday,
'friday' => $friday,
'saturday' => $saturday,
'sunday' => $sunday,
'periodically_time_from' => $periodically_time_from,
'periodically_time_to' => $periodically_time_to,
'periodically_day_from' => $periodically_day_from,
'periodically_day_to' => $periodically_day_to,
'type_downtime' => $type_downtime,
'type_execution' => $type_execution,
'type_periodicity' => $type_periodicity
);
$result = db_process_sql_insert(
'tplanned_downtime', $values);
}
else {
echo "<h3 class='error'>" .
@ -159,8 +222,24 @@ if ($create_downtime || $update_downtime) {
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'executed' => 0,
'id_group' => $id_group,
'only_alerts' => (int)$only_alerts);
'only_alerts' => 0,
'monday' => $monday,
'tuesday' => $tuesday,
'wednesday' => $wednesday,
'thursday' => $thursday,
'friday' => $friday,
'saturday' => $saturday,
'sunday' => $sunday,
'periodically_time_from' => $periodically_time_from,
'periodically_time_to' => $periodically_time_to,
'periodically_day_from' => $periodically_day_from,
'periodically_day_to' => $periodically_day_to,
'type_downtime' => $type_downtime,
'type_execution' => $type_execution,
'type_periodicity' => $type_periodicity
);
$result = db_process_sql_update('tplanned_downtime', $values, array('id' => $id_downtime));
}
else {
@ -192,17 +271,17 @@ if ($create_downtime || $update_downtime) {
if ($id_downtime > 0) {
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ("SELECT `id`, `name`, `description`, `date_from`, `date_to`, `id_group`, `only_alerts`
$sql = sprintf ("SELECT *
FROM `tplanned_downtime` WHERE `id` = %d",
$id_downtime);
break;
case "postgresql":
$sql = sprintf ("SELECT \"id\", \"name\", \"description\", \"date_from\", \"date_to\", \"id_group\", \"only_alerts\"
$sql = sprintf ("SELECT *
FROM \"tplanned_downtime\" WHERE \"id\" = %d",
$id_downtime);
break;
case "oracle":
$sql = sprintf ("SELECT id, name, description, date_from, date_to, id_group, only_alerts
$sql = sprintf ("SELECT *
FROM tplanned_downtime WHERE id = %d",
$id_downtime);
break;
@ -215,7 +294,20 @@ if ($id_downtime > 0) {
$date_to = strftime ('%Y-%m-%d', $result["date_to"]);
$time_from = strftime ('%I:%M%p', $result["date_from"]);
$time_to = strftime ('%I:%M%p', $result["date_to"]);
$only_alerts = $result["only_alerts"];
$monday = $result['monday'];
$tuesday = $result['tuesday'];
$wednesday = $result['wednesday'];
$thursday = $result['thursday'];
$friday = $result['friday'];
$saturday = $result['saturday'];
$sunday = $result['sunday'];
$periodically_time_from = $result['periodically_time_from'];
$periodically_time_to = $result['periodically_time_to'];
$periodically_day_from = $result['periodically_day_from'];
$periodically_day_to = $result['periodically_day_to'];
$type_downtime = $result['type_downtime'];
$type_execution = $result['type_execution'];
$type_periodicity = $result['type_periodicity'];
if ($id_group == 0)
$id_group = $result['id_group'];
@ -226,20 +318,120 @@ $table->width = '98%';
$table->data = array ();
$table->data[0][0] = __('Name');
$table->data[0][1] = html_print_input_text ('name', $name, '', 25, 40, true);
$table->data[1][0] = __('Group');
$table->data[1][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group, '', '', 0, true);
$table->data[2][0] = __('Description');
$table->data[2][1] = html_print_textarea ('description', 3, 35, $description, '', true);
$table->data[3][0] = __('Timestamp from');
$table->data[3][1] = html_print_input_text ('date_from', $date_from, '', 10, 10, true);
$table->data[3][1] .= html_print_input_text ('time_from', $time_from, '', 7, 7, true);
$disabled_type = false;
$table->data[4][0] = __('Timestamp to');
$table->data[4][1] = html_print_input_text ('date_to', $date_to, '', 10, 10, true);
$table->data[4][1] .= html_print_input_text ('time_to', $time_to, '', 7, 7, true);
if ($id_downtime > 0) {
$disabled_type = true;
}
$table->data[3][0] = __('Type');
$table->data[3][1] = html_print_select(array('quiet' => __('Quiet'),
'disable_agents' => __('Disabled Agents'),
'disable_agents_alerts' => __('Disabled Agents and Alerts')),
'type_downtime', $type_downtime, '', '', 0, true, false, true,
'', $disabled_type);
$table->data[4][0] = __('Execution');
$table->data[4][1] = html_print_select(array('once' => __('once'),
'periodically' => __('Periodically')),
'type_execution', $type_execution, 'change_type_execution();', '', 0, true);
$days = array_combine(range(1, 31), range(1, 31));
$table->data[5][0] = __('Configure the time');
$table->data[5][1] = "
<div id='once_time' style='display: none;'>
<table>
<tr>
<td>" . __('From:') . "</td>
<td>".
html_print_input_text ('once_date_from', $once_date_from, '', 10, 10, true) .
html_print_input_text ('once_time_from', $once_time_from, '', 7, 7, true) .
"</td>
</tr>
<tr>
<td>" . __('To:') . "</td>
<td>".
html_print_input_text ('once_date_to', $once_date_to, '', 10, 10, true) .
html_print_input_text ('once_time_to', $once_time_to, '', 7, 7, true) .
"</td>
</tr>
</table>
</div>
<div id='periodically_time' style='display: none;'>
<table>
<tr>
<td>" . __('Type Periodicity:') . "</td>
<td>".
html_print_select(array(
'weekly' => __('Weekly'),
'monthly' => __('Monthly')),
'type_periodicity', $type_periodicity, 'change_type_periodicity();', '', 0, true) .
"</td>
</tr>
<tr>
<td colspan='2'>
<table id='weekly_item' style='display: none;'>
<tr>
<td>" . __('Mon') .
html_print_checkbox ('monday', 1, $monday, true) .
"</td>
<td>" . __('Tue') .
html_print_checkbox ('tuesday', 1, $tuesday, true) .
"</td>
<td>" . __('Wed') .
html_print_checkbox ('wednesday', 1, $wednesday, true) .
"</td>
<td>" . __('Thu') .
html_print_checkbox ('thursday', 1, $thursday, true) .
"</td>
<td>" . __('Fri') .
html_print_checkbox ('friday', 1, $friday, true) .
"</td>
<td>" . __('Sat') .
html_print_checkbox ('saturday', 1, $saturday, true) .
"</td>
<td>" . __('Sun') .
html_print_checkbox ('sunday', 1, $sunday, true) .
"</td>
</tr>
</table>
<table id='monthly_item' style='display: none;'>
<tr>
<td>" . __('From day:') . "</td>
<td>".
html_print_select($days,
'periodically_day_from', $periodically_day_from, '', '', 0, true) .
"</td>
<td>" . __('To day:') . "</td>
<td>".
html_print_select($days,
'periodically_day_to', $periodically_day_to, '', '', 0, true) .
"</td>
</tr>
</table>
<table>
<tr>
<td>" . __('From hour:') . "</td>
<td>".
html_print_input_text (
'periodically_time_from',
$periodically_time_from, '', 7, 7, true) .
"</td>
<td>" . __('To hour:') . "</td>
<td>".
html_print_input_text (
'periodically_time_to',
$periodically_time_to, '', 7, 7, true) .
"</td>
</tr>
</table>
</td>
</tr>
</table>
</div>";
$table->data[5][0] = __('Group');
$table->data[5][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group, '', '', 0, true);
$table->data[6][0] = __('Only alerts');
$table->data[6][1] = html_print_checkbox('only_alerts', 1, $only_alerts, true);
echo '<form method="POST" action="index.php?sec=gagente&amp;sec2=godmode/agentes/planned_downtime.editor">';
if ($id_downtime > 0) {
@ -268,14 +460,15 @@ if ($id_downtime > 0) {
echo "<td valign=top>";
// Show available agents to include into downtime
echo '<h4>'.__('Available agents').':</h4>';
echo '<h4>' . __('Available agents') . ':</h4>';
$filter_group = get_parameter("filter_group", 0);
$filter_cond = '';
if($filter_group > 0)
$filter_cond = " AND id_grupo = $filter_group ";
$sql = sprintf ("SELECT tagente.id_agente, tagente.nombre, tagente.id_grupo
$sql = sprintf ("SELECT tagente.id_agente, tagente.nombre,
tagente.id_grupo
FROM tagente
WHERE tagente.id_agente NOT IN (
SELECT tagente.id_agente
@ -299,7 +492,7 @@ if ($id_downtime > 0) {
$disabled_add_button = true;
}
echo "<form method=post action='index.php?sec=gagente&sec2=godmode/agentes/planned_downtime&first_update=1&id_downtime=$id_downtime'>";
echo "<form method=post action='index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.editor&id_downtime=$id_downtime'>";
html_print_select_groups(false, "AR", true, 'filter_group', $filter_group, '', '', '', false, false, true, '', false, 'width:180px');
@ -307,9 +500,16 @@ if ($id_downtime > 0) {
html_print_submit_button (__('Filter by group'), '', false, 'class="sub next"',false);
echo "</form>";
echo "<form method=post action='index.php?sec=gagente&sec2=godmode/agentes/planned_downtime&first_update=1&insert_downtime_agent=1&id_downtime=$id_downtime'>";
echo "<form method=post action='index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
echo html_print_select ($data, "id_agent[]", '', '', '', 0, false, true, true, '', false, 'width: 180px;');
echo html_print_select ($data, "id_agents[]", '', '', '', 0, false, true, true, '', false, 'width: 180px;');
echo '<h4>' . __('Available modules:') .
ui_print_help_tip (__('Only for type Quiet for downtimes.'), true) . '</h4>';
if ($type_downtime != 'quiet')
echo '<div style="display: none;">';
echo html_print_select (array(), "module[]", '', '', '', 0, false, true, true, '', false, 'width: 180px;');
echo "</div>";
echo "<br /><br /><br />";
html_print_submit_button (__('Add'), '', $disabled_add_button, 'class="sub next"',false);
echo "</form>";
@ -320,7 +520,7 @@ if ($id_downtime > 0) {
$sql = sprintf ("SELECT tagente.nombre, tplanned_downtime_agents.id,
tagente.id_os, tagente.id_agente, tagente.id_grupo,
tagente.ultimo_contacto
tagente.ultimo_contacto, tplanned_downtime_agents.all_modules
FROM tagente, tplanned_downtime_agents
WHERE tplanned_downtime_agents.id_agent = tagente.id_agente
AND tplanned_downtime_agents.id_downtime = %d ",$id_downtime);
@ -330,6 +530,7 @@ if ($id_downtime > 0) {
echo '<div class="nf">'. __('There are no scheduled downtimes').'</div>';
}
else {
$table->id = 'list';
$table->class = 'databox';
$table->width = '98%';
$table->data = array ();
@ -338,63 +539,396 @@ if ($id_downtime > 0) {
$table->head[1] = __('Group');
$table->head[2] = __('OS');
$table->head[3] = __('Last contact');
$table->head[4] = __('Remove');
$table->align[4] = "center";;
$table->head['count_modules'] = __('Modules');
$table->head[5] = __('Actions');
$table->align[5] = "center";
$table->size[5] = "5%";
foreach ($downtimes as $downtime) {
$data = array ();
$data[0] = $downtime['nombre'];
$data[1] = db_get_sql ("SELECT nombre FROM tgrupo WHERE id_grupo = ". $downtime["id_grupo"]);
$data[1] = db_get_sql ("SELECT nombre
FROM tgrupo
WHERE id_grupo = ". $downtime["id_grupo"]);
$data[2] = ui_print_os_icon ($downtime["id_os"], true, true);
$data[3] = $downtime["ultimo_contacto"];
$data[4] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/planned_downtime&amp;id_agent='.
$id_agent.'&amp;delete_downtime_agent=1&amp;first_update=1&amp;id_downtime_agent='.$downtime["id"].'&amp;id_downtime='.$id_downtime.'">' .
html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete')));
if ($downtime["all_modules"]) {
$data['count_modules'] = __("All modules");
}
else {
$data['count_modules'] = __("Some modules");
}
array_push ($table->data, $data);
$data[5] = '<a href="javascript:show_editor_module(' . $downtime["id_agente"] . ');">' .
html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Delete'))) . "</a>";
$data[5] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/planned_downtime.editor'.
'&amp;id_agent=' . $downtime["id_agente"] .
'&amp;delete_downtime_agent=1&amp;id_downtime_agent='.$downtime["id"].'&amp;id_downtime='.$id_downtime.'">' .
html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . "</a>";
$table->data['agent_' . $downtime["id_agente"]] = $data;
}
html_print_table ($table);
}
}
ui_require_css_file ('datepicker');
ui_require_jquery_file ('ui.core');
ui_require_jquery_file ('ui.datepicker');
$table = null;
$table->id = 'loading';
$table->colspan['loading'][0] = '6';
$table->style[0] = 'text-align: center;';
$table->data = array();
$table->data['loading'] = array();
$table->data['loading'][0] = html_print_image("images/spinner.gif", true);
echo "<div style='display: none;'>";
html_print_table ($table);
echo "</div>";
$table = null;
$table->id = 'editor';
$table->colspan['module'][1] = '5';
$table->data = array();
$table->data['module'] = array();
$table->data['module'][0] = '';
$table->data['module'][1] = "<h4>" . __('Modules') . "</h4>";
//List of modules, empty, it is populated by javascript.
$table->data['module'][1] = "
<table cellspacing='4' cellpadding='4' border='0' width='98%'
id='modules_in_agent' class='databox_color'>
<thead>
<tr>
<th scope='col' class='header c0'>" . __('Module') . "</th>
<th scope='col' class='header c1'>" . __('Action') . "</th>
</tr>
</thead>
<tbody>
<tr class='datos' id='template' style='display: none;'>
<td class='name_module' style=''></td>
<td class='cell_delete_button' style='text-align: center; width:10%;' id=''>"
. '<a class="link_delete"
onclick="if(!confirm(\'' . __('Are you sure?') . '\')) return false;"
href="">'
. html_print_image("images/cross.png", true,
array("border" => '0', "alt" => __('Delete'))) . "</a>"
. "</td>
</tr>
<tr class='datos2' id='add_modules_row'>
<td class='datos2' style='' id=''>"
. __("Add Module:") . '&nbsp;'
. html_print_select(array(),
'modules', '', '', '', 0, true)
. "</td>
<td class='datos2 button_cell' style='text-align: center; width:10%;' id=''>"
. '<div id="add_button_div">'
. '<a class="add_button" href="">'
. html_print_image("images/add.png", true,
array("border" => '0', "alt" => __('Add'))) . "</a>"
. '</div>'
. "<div id='spinner_add' style='display: none;'>"
. html_print_image("images/spinner.gif", true)
. "</div>"
. "</td>
</tr>
</tbody></table>";
echo "<div style='display: none;'>";
html_print_table ($table);
echo "</div>";
echo "<div style='display: none;'>";
echo "<div id='spinner_template'>";
html_print_image("images/spinner.gif");
echo "</div>";
echo "</div>";
echo "<div id='some_modules_text' style='display: none;'>";
echo __('Some modules');
echo "</div>";
echo "<div id='some_modules_text' style='display: none;'>";
echo __('Some modules');
echo "</div>";
echo "<div id='all_modules_text' style='display: none;'>";
echo __("All modules");
echo "</div>";
ui_require_jquery_file ('timeentry');
?>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
$("#text-time_from, #text-time_to").timeEntry ({
spinnerImage: 'images/time-entry.png',
spinnerSize: [20, 20, 0]
var id_downtime = <?php echo $id_downtime?>;
var action_in_progress = false;
function change_type_execution() {
switch ($("#type_execution").val()) {
case 'once':
$("#periodically_time").hide();
$("#once_time").show();
break;
case 'periodically':
$("#once_time").hide();
$("#periodically_time").show();
break;
}
}
function change_type_periodicity() {
switch ($("#type_periodicity").val()) {
case 'weekly':
$("#monthly_item").hide();
$("#weekly_item").show();
break;
case 'monthly':
$("#weekly_item").hide();
$("#monthly_item").show();
break;
}
}
function show_editor_module(id_agent) {
//Avoid freak states.
if (action_in_progress)
return;
//Check if the row editor module exists
if ($('#loading_' + id_agent).length > 0) {
//The row exists
$('#loading_' + id_agent).remove();
}
else {
if ($('#module_editor_' + id_agent).length == 0) {
$("#list-agent_" + id_agent).after(
$("#loading-loading").clone().attr('id', 'loading_' + id_agent));
jQuery.post ('ajax.php',
{"page": "include/ajax/planned_downtime.ajax",
"get_modules_downtime": 1,
"id_agent": id_agent,
"id_downtime": id_downtime
},
function (data) {
if (data['correct']) {
//Check if the row editor module exists
if ($('#loading_' + id_agent).length > 0) {
//The row exists
$('#loading_' + id_agent).remove();
$("#list-agent_" + id_agent).after(
$("#editor-module").clone()
.attr('id', 'module_editor_' + id_agent)
.hide());
fill_row_editor(id_agent, data);
}
}
},
"json"
);
}
else {
if ($('#module_editor_' + id_agent).is(':visible')) {
$('#module_editor_' + id_agent).hide();
}
else {
$('#module_editor_' + id_agent).css('display', '');
}
}
}
}
function fill_row_editor(id_agent, data) {
//$("#modules", $('#module_editor_' + id_agent)).empty();
//Fill the select for to add modules
$.each(data['in_agent'], function(id_module, name) {
$("#modules", $('#module_editor_' + id_agent))
.append($("<option value='" + id_module + "'>" + name + "</option>"));
});
$("#text-date_from, #text-date_to").datepicker ();
$.datepicker.regional["<?php echo $config['language']; ?>"];
$(".add_button", $('#module_editor_' + id_agent)).
attr('href', 'javascript:' +
'add_module_in_downtime(' + id_agent + ')');
//Fill the list of modules
$.each(data['in_downtime'], function(id_module, name) {
var template_row = $("#template").clone();
$(template_row).css('display', '');
$(template_row).attr('id', 'row_module_in_downtime_' + id_module);
$(".name_module", template_row).html(name);
$(".link_delete", template_row).attr('href',
'javascript:' +
'delete_module_from_downtime(' + id_downtime + ',' + id_module + ');');
$("#add_modules_row", $('#module_editor_' + id_agent))
.before(template_row);
});
//.show() is crap, because put a 'display: block;'.
$('#module_editor_' + id_agent).css('display', '');
}
function add_row_module(id_downtime, id_agent, id_module, name) {
var template_row = $("#template").clone();
$(template_row).css('display', '');
$(template_row).attr('id', 'row_module_in_downtime_' + id_module);
$(".name_module", template_row).html(name);
$(".link_delete", template_row).attr('href',
'javascript:' +
'delete_module_from_downtime(' + id_downtime + ',' + id_module + ');');
$("#add_modules_row", $('#module_editor_' + id_agent))
.before(template_row);
}
$("#filter_group").click (
function () {
$(this).css ("width", "auto");
function fill_selectbox_modules(id_downtime, id_agent) {
jQuery.post ('ajax.php',
{"page": "include/ajax/planned_downtime.ajax",
"get_modules_downtime": 1,
"id_agent": id_agent,
"id_downtime": id_downtime,
"none_value": 1
},
function (data) {
if (data['correct']) {
$("#modules", $('#module_editor_' + id_agent)).empty();
//Fill the select for to add modules
$.each(data['in_agent'], function(id_module, name) {
$("#modules", $('#module_editor_' + id_agent))
.append($("<option value='" + id_module + "'>" + name + "</option>"));
});
$("#modules", $('#module_editor_' + id_agent)).val(0);
}
},
"json"
);
}
function add_module_in_downtime(id_agent) {
var module_sel = $("#modules", $('#module_editor_' + id_agent)).val();
if (module_sel == 0) {
alert('<?php echo __("Please select a module."); ?>');
}
else {
action_in_progress = true;
$("#add_button_div", $('#module_editor_' + id_agent)).toggle();
$("#spinner_add", $('#module_editor_' + id_agent)).toggle();
jQuery.post ('ajax.php',
{"page": "include/ajax/planned_downtime.ajax",
"add_module_into_downtime": 1,
"id_agent": id_agent,
"id_module": module_sel,
"id_downtime": id_downtime
},
function (data) {
if (data['correct']) {
$("#list-agent_"
+ id_agent
+ '-count_modules').html(
$("#some_modules_text").html());
add_row_module(id_downtime, id_agent,
module_sel, data['name']);
fill_selectbox_modules(id_downtime, id_agent);
$("#add_button_div", $('#module_editor_' + id_agent))
.toggle();
$("#spinner_add", $('#module_editor_' + id_agent))
.toggle();
}
action_in_progress = false;
},
"json"
);
}
}
function delete_module_from_downtime(id_downtime, id_module) {
var spinner = $("#spinner_template").clone();
var old_cell_content =
$(".cell_delete_button", "#row_module_in_downtime_" + id_module)
.clone(true);
$(".cell_delete_button", "#row_module_in_downtime_" + id_module)
.html(spinner);
action_in_progress = true;
jQuery.post ('ajax.php',
{"page": "include/ajax/planned_downtime.ajax",
"delete_module_from_downtime": 1,
"id_downtime": id_downtime,
"id_module": id_module
},
function (data) {
if (data['correct']) {
fill_selectbox_modules(id_downtime, data['id_agent']);
$("#row_module_in_downtime_" + id_module).remove();
if (data['all_modules']) {
$("#list-agent_"
+ data['id_agent']
+ '-count_modules').html(
$("#all_modules_text").html());
}
}
else {
$(".cell_delete_button", "#row_module_in_downtime_" + id_module)
.html($(old_cell_content));
}
action_in_progress = false;
},
"json"
);
}
$(document).ready (function () {
$("#id_agents").change(agent_changed_by_multiple_agents);
change_type_execution();
change_type_periodicity();
$("#text-periodically_time_from, #text-periodically_time_to, #text-once_time_from, #text-once_time_to").timeEntry ({
spinnerImage: 'images/time-entry.png',
spinnerSize: [20, 20, 0]
});
$("#text-once_date_from, #text-once_date_to").datepicker ();
$.datepicker.regional["<?php echo $config['language']; ?>"];
$("#filter_group").click (
function () {
$(this).css ("width", "auto");
});
$("#filter_group").blur (function () {
$(this).css ("width", "180px");
});
$("#id_agent").click (
function () {
$(this).css ("width", "auto");
});
$("#id_agent").blur (function () {
$(this).css ("width", "180px");
});
});
$("#filter_group").blur (function () {
$(this).css ("width", "180px");
});
$("#id_agent").click (
function () {
$(this).css ("width", "auto");
});
$("#id_agent").blur (function () {
$(this).css ("width", "180px");
});
});
</script>

View File

@ -64,15 +64,15 @@ $table->head = array ();
$table->head[0] = __('Name #Ag.');
$table->head[1] = __('Description');
$table->head[2] = __('Group');
$table->head[3] = __('From');
$table->head[4] = __('To');
$table->head[5] = __('Affect');
$table->head[3] = __('Type');
$table->head[4] = __('Execution');
$table->head[5] = __('Configuration');
$table->head[6] = __('Delete');
$table->head[7] = __('Update');
$table->head[8] = __('Running');
$table->head[9] = __('Stop downtime');
$table->align[2] = "center";
$table->align[5] = "center";
//$table->align[5] = "center";
$table->align[6] = "center";
$table->align[7] = "center";
$table->align[8] = "center";
@ -101,14 +101,68 @@ else {
$data[0] = $downtime['name']. " ($total)";
$data[1] = $downtime['description'];
$data[2] = ui_print_group_icon ($downtime['id_group'], true);
$data[3] = date ("Y-m-d H:i", $downtime['date_from']);
$data[4] = date ("Y-m-d H:i", $downtime['date_to']);
if ($downtime['only_alerts']) {
$data[5] = __('Only alerts');
}
else {
$data[5] = __('All');
$type_text = array('quiet' => __('Quiet'),
'disable_agents' => __('Disabled Agents'),
'disable_agents_alerts' => __('Disabled Agents and Alerts'));
$data[3] = $type_text[$downtime['type_downtime']];
$execution_text = array('once' => __('once'),
'periodically' => __('Periodically'));
$data[4] = $execution_text[$downtime['type_execution']];
switch ($downtime['type_execution']) {
case 'once':
$data[5] = date ("Y-m-d H:i", $downtime['date_from']) .
"&nbsp;" . __('to') . "&nbsp;".
date ("Y-m-d H:i", $downtime['date_to']);
break;
case 'periodically':
switch ($downtime['type_periodicity']) {
case 'weekly':
$data[5] = __('Weekly:');
$data[5] .= "&nbsp;";
if ($downtime['monday']) {
$data[5] .= __('Mon');
$data[5] .= "&nbsp;";
}
if ($downtime['tuesday']) {
$data[5] .= __('Tue');
$data[5] .= "&nbsp;";
}
if ($downtime['wednesday']) {
$data[5] .= __('Wed');
$data[5] .= "&nbsp;";
}
if ($downtime['thursday']) {
$data[5] .= __('Thu');
$data[5] .= "&nbsp;";
}
if ($downtime['friday']) {
$data[5] .= __('Fri');
$data[5] .= "&nbsp;";
}
if ($downtime['saturday']) {
$data[5] .= __('Sat');
$data[5] .= "&nbsp;";
}
if ($downtime['sunday']) {
$data[5] .= __('Sun');
$data[5] .= "&nbsp;";
}
break;
case 'monthly':
$data[5] = __('Monthly:');
$data[5] .= $downtime['periodically_day_from'];
$data[5] .= "&nbsp;" . __('to') . "&nbsp;";
$data[5] .= $downtime['periodically_day_to'];
break;
}
break;
}
if ($downtime["executed"] == 0) {
$data[6] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/planned_downtime.list&amp;'.
'delete_downtime=1&amp;id_downtime='.$downtime['id'].'">' .

View File

@ -182,17 +182,17 @@ function update_template ($step) {
$priority = (int) get_parameter ('priority');
$id_group = get_parameter ("id_group");
$name_check = db_get_value ('name', 'talert_templates', 'name', $name);
$values = array ('name' => $name,
'type' => $type,
'description' => $description,
'value' => $value,
'max_value' => $max,
'min_value' => $min,
'id_group' => $id_group,
'matches_value' => $matches,
'priority' => $priority);
'type' => $type,
'description' => $description,
'value' => $value,
'max_value' => $max,
'min_value' => $min,
'id_group' => $id_group,
'matches_value' => $matches,
'priority' => $priority);
$result = alerts_update_alert_template ($id,$values);
}
elseif ($step == 2) {
@ -260,14 +260,14 @@ function update_template ($step) {
'min_alerts' => $min_alerts
);
break;
}
}
$result = alerts_update_alert_template ($id, $values);
}
elseif ($step == 3) {
$recovery_notify = (bool) get_parameter ('recovery_notify');
$field2_recovery = (string) get_parameter ('field2_recovery');
$field3_recovery = (string) get_parameter ('field3_recovery');
$values = array ('recovery_notify' => $recovery_notify,
'field2_recovery' => $field2_recovery,
'field3_recovery' => $field3_recovery);

View File

@ -176,7 +176,7 @@ if (check_acl ($config['id_user'], 0, "AW")) {
$menu_godmode["gservers"]["sub"] = $sub;
}
if (check_acl ($config['id_user'], 0, "LW")) {
if (check_acl ($config['id_user'], 0, "LW")) {
enterprise_hook ('snmpconsole_menu');
}

View File

@ -0,0 +1,135 @@
<?php
//Pandora FMS- http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
include_once($config['homedir'] . "/include/functions_io.php");
include_once($config['homedir'] . "/include/functions_db.php");
include_once($config['homedir'] . "/include/functions_modules.php");
$get_modules_downtime = (bool)get_parameter('get_modules_downtime', 0);
$delete_module_from_downtime = (bool)get_parameter('delete_module_from_downtime', 0);
$add_module_into_downtime = (bool)get_parameter('add_module_into_downtime', 0);
if ($get_modules_downtime) {
$return = array();
$return['correct'] = 1;
$return['in_agent'] = array();
$return['in_downtime'] = array();
$id_agent = (int)get_parameter('id_agent', 0);
$id_downtime = (int)get_parameter('id_downtime', 0);
$none_value = (bool)get_parameter('none_value', false);
$rows = db_get_all_rows_filter('tplanned_downtime_modules',
array('id_agent' => $id_agent, 'id_downtime' => $id_downtime));
if (empty($rows))
$rows = array();
$id_modules_downtime = array();
foreach ($rows as $row) {
$id_modules_downtime[$row['id_agent_module']] = true;
}
$modules = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent));
if (empty($modules))
$modules = array();
foreach ($modules as $module) {
if (empty($id_modules_downtime[$module['id_agente_modulo']])) {
$return['in_agent'][$module['id_agente_modulo']] = io_safe_output($module['nombre']);
}
else {
$return['in_downtime'][$module['id_agente_modulo']] = io_safe_output($module['nombre']);
}
}
if ($none_value) {
$return['in_agent'][0] = __('None');
}
echo json_encode($return);
exit;
}
if ($delete_module_from_downtime) {
$return = array();
$return['correct'] = 0;
$return['all_modules'] = 0;
$return['id_agent'] = 0;
$id_module = (int)get_parameter('id_module', 0);
$id_downtime = (int)get_parameter('id_downtime', 0);
$row = db_get_row_filter('tplanned_downtime_modules',
array('id_agent_module' => $id_module,
'id_downtime' => $id_downtime));
$return['id_agent'] = $row['id_agent'];
$result = db_process_sql_delete('tplanned_downtime_modules',
array('id_downtime' => $id_downtime,
'id_agent_module' => $id_module));
if ($result) {
$rows = db_get_all_rows_filter('tplanned_downtime_modules',
array('id_downtime' => $id_downtime,
'id_agent' => $row['id_agent']));
if (empty($rows)) {
db_process_sql_update('tplanned_downtime_agents',
array('all_modules' => 1),
array('id_agent' => $row['id_agent'],
'id_downtime' => $id_downtime));
$return['all_modules'] = 1;
$return['id_agent'] = $row['id_agent'];
}
$return['correct'] = 1;
}
echo json_encode($return);
exit;
}
if ($add_module_into_downtime) {
$return = array();
$return['correct'] = 0;
$return['name'] = '';
$id_agent = (int)get_parameter('id_agent', 0);
$id_module = (int)get_parameter('id_module', 0);
$id_downtime = (int)get_parameter('id_downtime', 0);
$values = array();
$values['id_agent'] = $id_agent;
$values['id_agent_module'] = $id_module;
$values['id_downtime'] = $id_downtime;
$correct = db_process_sql_insert('tplanned_downtime_modules', $values);
if ($correct) {
db_process_sql_update('tplanned_downtime_agents',
array('all_modules' => 0),
array('id_agent' => $id_agent,
'id_downtime' => $id_downtime));
$return['correct'] = 1;
$return['name'] = db_get_value('nombre', 'tagente_modulo',
'id_agente_modulo', $id_module);
}
echo json_encode($return);
exit;
}
?>

View File

@ -198,8 +198,8 @@ function mysql_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function mysql_db_process_sql_insert($table, $values) {
//Empty rows or values not processed
//Empty rows or values not processed
if (empty ($values))
return false;
@ -239,7 +239,7 @@ function mysql_db_process_sql_insert($table, $values) {
$query .= '('.implode (', ', $fields).')';
$query .= ' VALUES ('.$values_str.')';
return db_process_sql ($query, 'insert_id');
}

View File

@ -209,13 +209,13 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
$('#module').append ($('<option></option>').html (s).attr ("value", val));
$('#module').fadeIn ('normal');
});
if (selected != undefined)
$('#module').attr ('value', selected);
$('#module').css ("width", "auto");
$('#module').css ("max-width", "");
$('#module').removeAttr('disabled');
if (selected != undefined)
$('#module').attr ('value', selected);
$('#module').css ("width", "auto");
$('#module').css ("max-width", "");
$('#module').removeAttr('disabled');
},
"json"
);

View File

@ -472,11 +472,11 @@ CREATE OR REPLACE TRIGGER talert_compound_actions_update AFTER UPDATE OF ID ON t
CREATE OR REPLACE TRIGGER talert_compound_action_update1 AFTER UPDATE OF ID ON talert_actions FOR EACH ROW BEGIN UPDATE talert_compound_actions SET ID_ALERT_ACTION = :NEW.ID WHERE ID_ALERT_ACTION = :OLD.ID; END;;
CREATE TABLE talert_special_days (
id NUMBER(10,0) NOT NULL PRIMARY KEY,
date DATE default '0000-00-00' NOT NULL,
same_day VARCHAR2(20) default 'sunday',
description CLOB,
CONSTRAINT talert_special_days_same_day_cons CHECK (same_day IN ('monday','tuesday','wednesday','thursday','friday','saturday','sunday'))
id NUMBER(10,0) NOT NULL PRIMARY KEY,
date DATE default '0000-00-00' NOT NULL,
same_day VARCHAR2(20) default 'sunday',
description CLOB,
CONSTRAINT talert_special_days_same_day_cons CHECK (same_day IN ('monday','tuesday','wednesday','thursday','friday','saturday','sunday'))
);
-- on update trigger
@ -1188,6 +1188,9 @@ CREATE SEQUENCE tserver_export_data_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tserver_export_data_inc BEFORE INSERT ON tserver_export_data REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tserver_export_data_s.nextval INTO :NEW.ID FROM dual; END tserver_export_data_inc;;
-- -----------------------------------------------------
-- Table `tplanned_downtime`
-- -----------------------------------------------------
CREATE TABLE tplanned_downtime (
id NUMBER(19, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(100) NOT NULL,
@ -1196,22 +1199,50 @@ CREATE TABLE tplanned_downtime (
date_to NUMBER(19, 0) default 0 NOT NULL,
executed NUMBER(5, 0) default 0 NOT NULL,
id_group NUMBER(19, 0) default 0 NOT NULL,
only_alerts NUMBER(5, 0) default 0 NOT NULL
only_alerts NUMBER(5, 0) default 0 NOT NULL,
monday NUMBER(5, 0) default 0,
tuesday NUMBER(5, 0) default 0,
wednesday NUMBER(5, 0) default 0,
thursday NUMBER(5, 0) default 0,
friday NUMBER(5, 0) default 0,
saturday NUMBER(5, 0) default 0,
sunday NUMBER(5, 0) default 0,
-- Need to set better datatype
periodically_time_from DATE default NULL,
periodically_time_to DATE default NULL,
--
periodically_day_from NUMBER(19, 0) default NULL,
periodically_day_to NUMBER(19, 0) default NULL,
type_downtime VARCHAR2(100) NOT NULL default 'disabled_agents_alerts',
type_execution VARCHAR2(100) NOT NULL default 'once',
type_periodicity VARCHAR2(100) NOT NULL default 'weekly'
);
CREATE SEQUENCE tplanned_downtime_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tplanned_downtime_inc BEFORE INSERT ON tplanned_downtime REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_s.nextval INTO :NEW.ID FROM dual; END tplanned_downtime_inc;;
-- -----------------------------------------------------
-- Table `tplanned_downtime_agents`
-- -----------------------------------------------------
CREATE TABLE tplanned_downtime_agents (
id NUMBER(19, 0) NOT NULL PRIMARY KEY,
id_agent NUMBER(19, 0) default 0 NOT NULL,
id_downtime NUMBER(19, 0) default 0 NOT NULL REFERENCES tplanned_downtime(id) ON DELETE CASCADE,
all_modules NUMBER(5, 0) default 1
);
CREATE SEQUENCE tplanned_downtime_agents_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tplanned_downtime_agents_inc BEFORE INSERT ON tplanned_downtime_agents REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_agents_s.nextval INTO :NEW.ID FROM dual; END tplanned_downtime_agents_inc;;
-- -----------------------------------------------------
-- Table `tplanned_downtime_modules`
-- -----------------------------------------------------
CREATE TABLE tplanned_downtime_modules (
id NUMBER(19, 0) NOT NULL PRIMARY KEY,
id_agent NUMBER(19, 0) default 0 NOT NULL,
id_agent_module NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_downtime NUMBER(19, 0) default 0 NOT NULL REFERENCES tplanned_downtime(id) ON DELETE CASCADE
);
CREATE SEQUENCE tplanned_downtime_agents_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tplanned_downtime_agents_inc BEFORE INSERT ON tplanned_downtime_agents REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_agents_s.nextval INTO :NEW.ID FROM dual; END tplanned_downtime_agents_inc;;
CREATE SEQUENCE tplanned_downtime_modules_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tplanned_downtime_modules_inc BEFORE INSERT ON tplanned_downtime_modules REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tplanned_downtime_modules_s.nextval INTO :NEW.ID FROM dual; END tplanned_downtime_modules_inc;;
-- GIS extension Tables

View File

@ -993,6 +993,9 @@ CREATE TABLE "tserver_export_data" (
"timestamp" TIMESTAMP without time zone default '1970-01-01 00:00:00'
);
-- -----------------------------------------------------
-- Table "tplanned_downtime"
-- -----------------------------------------------------
CREATE TABLE "tplanned_downtime" (
"id" BIGSERIAL NOT NULL PRIMARY KEY,
"name" VARCHAR( 100 ) NOT NULL,
@ -1001,17 +1004,45 @@ CREATE TABLE "tplanned_downtime" (
"date_to" BIGINT NOT NULL default 0,
"executed" SMALLINT NOT NULL default 0,
"id_group" BIGINT NOT NULL default 0,
"only_alerts" SMALLINT NOT NULL default 0
"only_alerts" SMALLINT NOT NULL default 0,
"monday" SMALLINT default 0,
"tuesday" SMALLINT default 0,
"wednesday" SMALLINT default 0,
"thursday" SMALLINT default 0,
"friday" SMALLINT default 0,
"saturday" SMALLINT default 0,
"sunday" SMALLINT default 0,
"periodically_time_from" TIME default NULL,
"periodically_time_to" TIME default NULL,
"periodically_day_from" SMALLINT default NULL,
"periodically_day_to" SMALLINT default NULL,
"type_downtime" VARCHAR( 100 ) NOT NULL default 'disabled_agents_alerts',
"type_execution" VARCHAR( 100 ) NOT NULL default 'once',
"type_periodicity" VARCHAR( 100 ) NOT NULL default 'weekly'
);
-- -----------------------------------------------------
-- Table "tplanned_downtime_agents"
-- -----------------------------------------------------
CREATE TABLE "tplanned_downtime_agents" (
"id" BIGSERIAL NOT NULL PRIMARY KEY,
"id_agent" BIGINT NOT NULL default 0,
"id_downtime" BIGINT NOT NULL REFERENCES tplanned_downtime("id") ON DELETE CASCADE
"all_modules" SMALLINT default 1
);
-- GIS extension Tables
-- -----------------------------------------------------
-- Table "tplanned_downtime_modules"
-- -----------------------------------------------------
CREATE TABLE "tplanned_downtime_modules" (
"id" BIGSERIAL NOT NULL PRIMARY KEY,
"id_agent" BIGINT NOT NULL default 0,
"id_agent_module" INTEGER NOT NULL default 0,
"id_downtime" BIGINT NOT NULL REFERENCES tplanned_downtime("id") ON DELETE CASCADE
);
-- GIS extension Tables
-- -----------------------------------------------------
-- Table "tgis_data_history"
-- -----------------------------------------------------

View File

@ -546,59 +546,71 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
PRIMARY KEY (`id_grupo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tincidencia`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tincidencia` (
`id_incidencia` bigint(6) unsigned zerofill NOT NULL auto_increment,
`inicio` datetime NOT NULL default '1970-01-01 00:00:00',
`cierre` datetime NOT NULL default '1970-01-01 00:00:00',
`titulo` text NOT NULL,
`descripcion` text NOT NULL,
`id_usuario` varchar(60) NOT NULL default '',
`origen` varchar(100) NOT NULL default '',
`estado` int(10) NOT NULL default '0',
`prioridad` int(10) NOT NULL default '0',
`id_grupo` mediumint(4) unsigned NOT NULL default '0',
`actualizacion` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`id_creator` varchar(60) default NULL,
`id_lastupdate` varchar(60) default NULL,
`id_agente_modulo` bigint(100) NOT NULL,
`notify_email` tinyint(3) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NULL default 0,
PRIMARY KEY (`id_incidencia`),
KEY `incident_index_1` (`id_usuario`,`id_incidencia`),
KEY `id_agente_modulo` (`id_agente_modulo`)
`id_incidencia` bigint(6) unsigned zerofill NOT NULL auto_increment,
`inicio` datetime NOT NULL default '1970-01-01 00:00:00',
`cierre` datetime NOT NULL default '1970-01-01 00:00:00',
`titulo` text NOT NULL,
`descripcion` text NOT NULL,
`id_usuario` varchar(60) NOT NULL default '',
`origen` varchar(100) NOT NULL default '',
`estado` int(10) NOT NULL default '0',
`prioridad` int(10) NOT NULL default '0',
`id_grupo` mediumint(4) unsigned NOT NULL default '0',
`actualizacion` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`id_creator` varchar(60) default NULL,
`id_lastupdate` varchar(60) default NULL,
`id_agente_modulo` bigint(100) NOT NULL,
`notify_email` tinyint(3) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NULL default 0,
PRIMARY KEY (`id_incidencia`),
KEY `incident_index_1` (`id_usuario`,`id_incidencia`),
KEY `id_agente_modulo` (`id_agente_modulo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tlanguage`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS`tlanguage` (
`id_language` varchar(6) NOT NULL default '',
`name` varchar(100) NOT NULL default '',
PRIMARY KEY (`id_language`)
`id_language` varchar(6) NOT NULL default '',
`name` varchar(100) NOT NULL default '',
PRIMARY KEY (`id_language`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tlink`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tlink` (
`id_link` int(10) unsigned zerofill NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '',
`link` varchar(255) NOT NULL default '',
PRIMARY KEY (`id_link`)
`id_link` int(10) unsigned zerofill NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '',
`link` varchar(255) NOT NULL default '',
PRIMARY KEY (`id_link`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tmensajes`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tmensajes` (
`id_mensaje` int(10) unsigned NOT NULL auto_increment,
`id_usuario_origen` varchar(60) NOT NULL default '',
`id_usuario_destino` varchar(60) NOT NULL default '',
`mensaje` text NOT NULL,
`timestamp` bigint (20) unsigned NOT NULL default '0',
`subject` varchar(255) NOT NULL default '',
`estado` int(4) unsigned NOT NULL default '0',
PRIMARY KEY (`id_mensaje`)
`id_mensaje` int(10) unsigned NOT NULL auto_increment,
`id_usuario_origen` varchar(60) NOT NULL default '',
`id_usuario_destino` varchar(60) NOT NULL default '',
`mensaje` text NOT NULL,
`timestamp` bigint (20) unsigned NOT NULL default '0',
`subject` varchar(255) NOT NULL default '',
`estado` int(4) unsigned NOT NULL default '0',
PRIMARY KEY (`id_mensaje`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tmodule_group`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tmodule_group` (
`id_mg` tinyint(4) unsigned NOT NULL auto_increment,
`name` varchar(150) NOT NULL default '',
PRIMARY KEY (`id_mg`)
`id_mg` tinyint(4) unsigned NOT NULL auto_increment,
`name` varchar(150) NOT NULL default '',
PRIMARY KEY (`id_mg`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -1126,46 +1138,79 @@ CREATE TABLE IF NOT EXISTS `tserver_export_data` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tplanned_downtime`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tplanned_downtime` (
`id` MEDIUMINT( 8 ) NOT NULL AUTO_INCREMENT,
`name` VARCHAR( 100 ) NOT NULL,
`description` TEXT NOT NULL,
`date_from` bigint(20) NOT NULL default '0',
`date_to` bigint(20) NOT NULL default '0',
`executed` tinyint(1) UNSIGNED NOT NULL default 0,
`id_group` mediumint(8) unsigned NULL default 0,
`only_alerts` tinyint(1) UNSIGNED NOT NULL default 0,
PRIMARY KEY ( `id` )
`id` MEDIUMINT( 8 ) NOT NULL AUTO_INCREMENT,
`name` VARCHAR( 100 ) NOT NULL,
`description` TEXT NOT NULL,
`date_from` bigint(20) NOT NULL default '0',
`date_to` bigint(20) NOT NULL default '0',
`executed` tinyint(1) UNSIGNED NOT NULL default 0,
`id_group` mediumint(8) unsigned NULL default 0,
`only_alerts` tinyint(1) UNSIGNED NOT NULL default 0,
`monday` tinyint(1) default 0,
`tuesday` tinyint(1) default 0,
`wednesday` tinyint(1) default 0,
`thursday` tinyint(1) default 0,
`friday` tinyint(1) default 0,
`saturday` tinyint(1) default 0,
`sunday` tinyint(1) default 0,
`periodically_time_from` time NULL default NULL,
`periodically_time_to` time NULL default NULL,
`periodically_day_from` int(100) unsigned default NULL,
`periodically_day_to` int(100) unsigned default NULL,
`type_downtime` varchar(100) NOT NULL default 'disabled_agents_alerts',
`type_execution` varchar(100) NOT NULL default 'once',
`type_periodicity` varchar(100) NOT NULL default 'weekly',
PRIMARY KEY ( `id` )
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tplanned_downtime_agents`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tplanned_downtime_agents` (
`id` int(20) unsigned NOT NULL auto_increment,
`id_agent` mediumint(8) unsigned NOT NULL default '0',
`id_downtime` mediumint(8) NOT NULL default '0',
PRIMARY KEY (`id`),
FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`)
ON DELETE CASCADE
`id` int(20) unsigned NOT NULL auto_increment,
`id_agent` mediumint(8) unsigned NOT NULL default '0',
`id_downtime` mediumint(8) NOT NULL default '0',
`all_modules` tinyint(1) default 1,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tplanned_downtime_modules`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` (
`id` int(20) unsigned NOT NULL auto_increment,
`id_agent` mediumint(8) unsigned NOT NULL default '0',
`id_agent_module` int(10) NOT NULL,
`id_downtime` mediumint(8) NOT NULL default '0',
PRIMARY KEY (`id`),
FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- GIS extension Tables
-- -----------------------------------------------------
-- Table `tgis_data_history`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tgis_data_history` (
`id_tgis_data` INT NOT NULL AUTO_INCREMENT COMMENT 'key of the table' ,
`longitude` DOUBLE NOT NULL ,
`latitude` DOUBLE NOT NULL ,
`altitude` DOUBLE NULL ,
`start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'timestamp on wich the agente started to be in this position' ,
`end_timestamp` TIMESTAMP NULL COMMENT 'timestamp on wich the agent was placed for last time on this position' ,
`description` TEXT NULL COMMENT 'description of the region correoponding to this placemnt' ,
`manual_placement` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '0 to show that the position cames from the agent, 1 to show that the position was established manualy' ,
`number_of_packages` INT NOT NULL DEFAULT 1 COMMENT 'Number of data packages received with this position from the start_timestampa to the_end_timestamp' ,
`tagente_id_agente` INT(10) UNSIGNED NOT NULL COMMENT 'reference to the agent' ,
PRIMARY KEY (`id_tgis_data`) ,
INDEX `start_timestamp_index` USING BTREE (`start_timestamp` ASC),
INDEX `end_timestamp_index` USING BTREE (`end_timestamp` ASC) )
`id_tgis_data` INT NOT NULL AUTO_INCREMENT COMMENT 'key of the table' ,
`longitude` DOUBLE NOT NULL ,
`latitude` DOUBLE NOT NULL ,
`altitude` DOUBLE NULL ,
`start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'timestamp on wich the agente started to be in this position' ,
`end_timestamp` TIMESTAMP NULL COMMENT 'timestamp on wich the agent was placed for last time on this position' ,
`description` TEXT NULL COMMENT 'description of the region correoponding to this placemnt' ,
`manual_placement` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '0 to show that the position cames from the agent, 1 to show that the position was established manualy' ,
`number_of_packages` INT NOT NULL DEFAULT 1 COMMENT 'Number of data packages received with this position from the start_timestampa to the_end_timestamp' ,
`tagente_id_agente` INT(10) UNSIGNED NOT NULL COMMENT 'reference to the agent' ,
PRIMARY KEY (`id_tgis_data`) ,
INDEX `start_timestamp_index` USING BTREE (`start_timestamp` ASC),
INDEX `end_timestamp_index` USING BTREE (`end_timestamp` ASC) )
ENGINE = InnoDB
COMMENT = 'Table to store historical GIS information of the agents';