Commit 3b0ddb98 authored by Edileuton Henrique de Oliveira's avatar Edileuton Henrique de Oliveira
Browse files

Merge branch 'master' of git:./proinfodata/unstable

parents 57f40b1b 39a0f060
File mode changed from 100644 to 100755
/* OLTP operational database tables */
CREATE TABLE proinfo_inventory (
contact_date DATE DEFAULT CURRENT_DATE NOT NULL,
project INTEGER DEFAULT 0 NOT NULL,
inep CHARACTER VARYING(18) NOT NULL,
macaddr CHARACTER VARYING(18) NOT NULL,
os_type TEXT,
os_distro TEXT,
os_kernel TEXT,
processor TEXT,
memory INTEGER,
disk1_model TEXT,
disk1_size INTEGER,
disk1_used INTEGER,
disk2_model TEXT,
disk2_size INTEGER,
disk2_used INTEGER,
extra_hds SMALLINT DEFAULT 0 NOT NULL,
ts TIMESTAMP
contact_date DATE DEFAULT CURRENT_DATE NOT NULL,
project INTEGER DEFAULT 0 NOT NULL,
inep CHARACTER VARYING(18) NOT NULL,
macaddr CHARACTER VARYING(18) NOT NULL,
os_type TEXT,
os_distro TEXT,
os_kernel TEXT,
processor TEXT,
memory INTEGER,
disk1_model TEXT,
disk1_size INTEGER,
disk1_used INTEGER,
disk2_model TEXT,
disk2_size INTEGER,
disk2_used INTEGER,
extra_hds SMALLINT DEFAULT 0 NOT NULL,
mirror_timestamp TIMESTAMP,
agent_version CHARACTER VARYING(20) NOT NULL
);
CREATE TABLE proinfo_net_usage (
......@@ -31,26 +32,27 @@ CREATE TABLE proinfo_net_usage (
);
CREATE TABLE rejected_inventory (
id INTEGER,
sch_id INTEGER,
cit_id INTEGER,
contact_date DATE NOT NULL,
project INTEGER,
inep CHARACTER VARYING(18) NOT NULL,
macaddr TEXT NOT NULL,
os_type TEXT,
os_distro TEXT,
os_kernel TEXT,
processor TEXT,
memory INTEGER,
disk1_model TEXT,
disk1_size INTEGER,
disk1_used INTEGER,
disk2_model TEXT,
disk2_size INTEGER,
disk2_used INTEGER,
extra_hds SMALLINT,
ts TIMESTAMP
id INTEGER,
sch_id INTEGER,
cit_id INTEGER,
contact_date DATE NOT NULL,
project INTEGER,
inep CHARACTER VARYING(18) NOT NULL,
macaddr TEXT NOT NULL,
os_type TEXT,
os_distro TEXT,
os_kernel TEXT,
processor TEXT,
memory INTEGER,
disk1_model TEXT,
disk1_size INTEGER,
disk1_used INTEGER,
disk2_model TEXT,
disk2_size INTEGER,
disk2_used INTEGER,
extra_hds SMALLINT,
mirror_timestamp TIMESTAMP,
agent_version CHARACTER VARYING(20)
);
CREATE TABLE rejected_net_usage (
......
-- fact tables
CREATE TABLE fact_contact (
id SERIAL PRIMARY KEY,
sch_id INTEGER NOT NULL REFERENCES dim_school,
cit_id INTEGER NOT NULL REFERENCES dim_city,
dat_id DATE NOT NULL REFERENCES dim_date,
macaddr MACADDR NOT NULL,
project project_enum DEFAULT 'proinfo' NOT NULL,
ts TIMESTAMP,
id SERIAL PRIMARY KEY,
sch_id INTEGER NOT NULL REFERENCES dim_school,
cit_id INTEGER NOT NULL REFERENCES dim_city,
dat_id DATE NOT NULL REFERENCES dim_date,
macaddr MACADDR NOT NULL,
project project_enum DEFAULT 'proinfo' NOT NULL,
mirror_timestamp TIMESTAMP,
agent_version CHARACTER VARYING(20) NOT NULL,
UNIQUE (sch_id, cit_id, dat_id, macaddr)
);
......
......@@ -49,7 +49,7 @@ BEGIN
i.disk2_size,
i.disk2_used,
i.extra_hds,
i.ts,
i.mirror_timestamp,
i.version,
'0'::boolean as valid
FROM
......@@ -192,11 +192,11 @@ BEGIN
INSERT INTO rejected_inventory
(sch_id, cit_id, contact_date, project, inep, macaddr,
os_type, os_distro, os_kernel, processor, memory, disk1_model,
disk1_size, disk1_used, disk2_model, disk2_size, disk2_used, ts, version)
disk1_size, disk1_used, disk2_model, disk2_size, disk2_used, mirror_timestamp, agent_version)
(SELECT
sch_id, cit_id, contact_date, project, inep, macaddr,
os_type, os_distro, os_kernel, processor, memory, disk1_model,
disk1_size, disk1_used, disk2_model, disk2_size, disk2_used, ts, version
disk1_size, disk1_used, disk2_model, disk2_size, disk2_used, mirror_timestamp, agent_version
FROM
sa_inventory
WHERE
......
......@@ -16,9 +16,9 @@ BEGIN
--
INSERT INTO fact_contact (sch_id, cit_id, dat_id, macaddr, project, ts, version)
(SELECT sch_id, cit_id, contact_date, macaddr::macaddr, to_project_enum(project), ts, version FROM sa_inventory WHERE valid = '1')
(SELECT sch_id, cit_id, contact_date, macaddr::macaddr, to_project_enum(project), mirror_timestamp, agent_version FROM sa_inventory WHERE valid = '1')
EXCEPT
(SELECT sch_id, cit_id, dat_id, macaddr, project, ts, version FROM fact_contact WHERE dat_id >= result.min_date AND dat_id <= result.max_date);
(SELECT sch_id, cit_id, dat_id, macaddr, project, mirror_timestamp, agent_version FROM fact_contact WHERE dat_id >= result.min_date AND dat_id <= result.max_date);
-- how many rows were inserted?
GET DIAGNOSTICS total_rows = ROW_COUNT;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment