-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData_schema.sql
More file actions
518 lines (364 loc) · 11.3 KB
/
Data_schema.sql
File metadata and controls
518 lines (364 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.20 (Debian 11.20-0+deb10u1)
-- Dumped by pg_dump version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: context; Type: SCHEMA; Schema: -; Owner: www_data
--
CREATE SCHEMA context;
ALTER SCHEMA context OWNER TO www_data;
--
-- Name: feeds; Type: SCHEMA; Schema: -; Owner: www_data
--
CREATE SCHEMA feeds;
ALTER SCHEMA feeds OWNER TO www_data;
--
-- Name: knowledge; Type: SCHEMA; Schema: -; Owner: www_data
--
CREATE SCHEMA knowledge;
ALTER SCHEMA knowledge OWNER TO www_data;
SET default_tablespace = '';
--
-- Name: domain; Type: TABLE; Schema: context; Owner: www_data
--
CREATE TABLE context.domain (
id bigint NOT NULL,
domain_name character varying NOT NULL,
domain_data jsonb
);
ALTER TABLE context.domain OWNER TO www_data;
--
-- Name: domain_id_seq; Type: SEQUENCE; Schema: context; Owner: www_data
--
ALTER TABLE context.domain ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME context.domain_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: domain_role; Type: TABLE; Schema: context; Owner: www_data
--
CREATE TABLE context.domain_role (
id bigint NOT NULL,
domain_name character varying NOT NULL,
role_code character varying NOT NULL,
domain_role_data jsonb
);
ALTER TABLE context.domain_role OWNER TO www_data;
--
-- Name: domain_role_id_seq; Type: SEQUENCE; Schema: context; Owner: www_data
--
ALTER TABLE context.domain_role ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME context.domain_role_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: fqhost; Type: TABLE; Schema: context; Owner: www_data
--
CREATE TABLE context.fqhost (
id bigint NOT NULL,
uqhost character varying NOT NULL,
domain_name character varying NOT NULL,
role_code character(4) NOT NULL,
"timestamp" timestamp with time zone,
last_seen timestamp with time zone
);
ALTER TABLE context.fqhost OWNER TO www_data;
--
-- Name: role_service; Type: TABLE; Schema: context; Owner: www_data
--
CREATE TABLE context.role_service (
id bigint NOT NULL,
role_code character varying NOT NULL,
service_type character varying NOT NULL
);
ALTER TABLE context.role_service OWNER TO www_data;
--
-- Name: service; Type: TABLE; Schema: context; Owner: www_data
--
CREATE TABLE context.service (
id bigint NOT NULL,
service_type character varying NOT NULL,
service_port smallint NOT NULL,
service_name character varying NOT NULL,
check_line character varying,
interface character varying NOT NULL
);
ALTER TABLE context.service OWNER TO www_data;
--
-- Name: fqhost_services; Type: VIEW; Schema: context; Owner: www_data
--
CREATE VIEW context.fqhost_services AS
SELECT fq.uqhost,
fq.domain_name,
rs.service_type,
sv.interface,
sv.service_port
FROM ((context.fqhost fq
JOIN context.role_service rs ON ((fq.role_code = (rs.role_code)::bpchar)))
JOIN context.service sv ON (((rs.service_type)::text = (sv.service_type)::text)));
ALTER TABLE context.fqhost_services OWNER TO www_data;
--
-- Name: host_id_seq; Type: SEQUENCE; Schema: context; Owner: www_data
--
ALTER TABLE context.fqhost ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME context.host_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: role; Type: TABLE; Schema: context; Owner: www_data
--
CREATE TABLE context.role (
id bigint NOT NULL,
role_code character(4) NOT NULL,
role_name character varying
);
ALTER TABLE context.role OWNER TO www_data;
--
-- Name: role_id_seq; Type: SEQUENCE; Schema: context; Owner: www_data
--
ALTER TABLE context.role ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME context.role_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: role_service_id_seq; Type: SEQUENCE; Schema: context; Owner: www_data
--
ALTER TABLE context.role_service ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME context.role_service_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: service_id_seq; Type: SEQUENCE; Schema: context; Owner: www_data
--
ALTER TABLE context.service ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME context.service_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: hard_classes; Type: TABLE; Schema: feeds; Owner: www_data
--
CREATE TABLE feeds.hard_classes (
id bigint NOT NULL,
uqhost character varying NOT NULL,
domain character varying NOT NULL,
os character varying,
ostype character varying,
flavor character varying,
cpus smallint,
arch character varying,
"timestamp" timestamp with time zone
);
ALTER TABLE feeds.hard_classes OWNER TO www_data;
--
-- Name: TABLE hard_classes; Type: COMMENT; Schema: feeds; Owner: www_data
--
COMMENT ON TABLE feeds.hard_classes IS 'CFEngine Hard Classes';
--
-- Name: hard_classes_id_seq; Type: SEQUENCE; Schema: feeds; Owner: www_data
--
ALTER TABLE feeds.hard_classes ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME feeds.hard_classes_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: host_objects; Type: TABLE; Schema: feeds; Owner: www_data
--
CREATE TABLE feeds.host_objects (
id bigint NOT NULL,
uqhost character varying NOT NULL,
domain character varying NOT NULL,
object_id text NOT NULL
);
ALTER TABLE feeds.host_objects OWNER TO www_data;
--
-- Name: TABLE host_objects; Type: COMMENT; Schema: feeds; Owner: www_data
--
COMMENT ON TABLE feeds.host_objects IS 'CFEngine Host Objects in process';
--
-- Name: host_objects_id_seq; Type: SEQUENCE; Schema: feeds; Owner: www_data
--
ALTER TABLE feeds.host_objects ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME feeds.host_objects_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: json_in; Type: TABLE; Schema: feeds; Owner: www_data
--
CREATE TABLE feeds.json_in (
id bigint NOT NULL,
message_time timestamp with time zone NOT NULL,
message_in jsonb,
message_flow smallint DEFAULT 0
);
ALTER TABLE feeds.json_in OWNER TO www_data;
--
-- Name: TABLE json_in; Type: COMMENT; Schema: feeds; Owner: www_data
--
COMMENT ON TABLE feeds.json_in IS 'CFEngine ZMQ messages';
--
-- Name: json_in_id_seq; Type: SEQUENCE; Schema: feeds; Owner: www_data
--
ALTER TABLE feeds.json_in ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME feeds.json_in_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: response; Type: TABLE; Schema: feeds; Owner: www_data
--
CREATE TABLE feeds.response (
id bigint NOT NULL,
feed_message_time timestamp with time zone NOT NULL,
response_time timestamp with time zone NOT NULL,
message_out jsonb
);
ALTER TABLE feeds.response OWNER TO www_data;
--
-- Name: response_id_seq; Type: SEQUENCE; Schema: feeds; Owner: www_data
--
ALTER TABLE feeds.response ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME feeds.response_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: domain p_domain; Type: CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.domain
ADD CONSTRAINT p_domain PRIMARY KEY (domain_name);
--
-- Name: domain_role p_domain_role; Type: CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.domain_role
ADD CONSTRAINT p_domain_role PRIMARY KEY (domain_name, role_code);
--
-- Name: fqhost p_host; Type: CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.fqhost
ADD CONSTRAINT p_host PRIMARY KEY (uqhost, domain_name);
--
-- Name: role p_role; Type: CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.role
ADD CONSTRAINT p_role PRIMARY KEY (role_code);
--
-- Name: role_service p_role_service; Type: CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.role_service
ADD CONSTRAINT p_role_service PRIMARY KEY (role_code, service_type);
--
-- Name: service p_service_type; Type: CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.service
ADD CONSTRAINT p_service_type PRIMARY KEY (service_type);
--
-- Name: hard_classes p_hard_classes; Type: CONSTRAINT; Schema: feeds; Owner: www_data
--
ALTER TABLE ONLY feeds.hard_classes
ADD CONSTRAINT p_hard_classes PRIMARY KEY (uqhost, domain);
--
-- Name: host_objects p_host_objects; Type: CONSTRAINT; Schema: feeds; Owner: www_data
--
ALTER TABLE ONLY feeds.host_objects
ADD CONSTRAINT p_host_objects PRIMARY KEY (uqhost, domain);
--
-- Name: json_in p_json_in; Type: CONSTRAINT; Schema: feeds; Owner: www_data
--
ALTER TABLE ONLY feeds.json_in
ADD CONSTRAINT p_json_in PRIMARY KEY (message_time);
--
-- Name: i_hard_classes; Type: INDEX; Schema: feeds; Owner: www_data
--
CREATE INDEX i_hard_classes ON feeds.hard_classes USING btree (id);
--
-- Name: fqhost f_domain; Type: FK CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.fqhost
ADD CONSTRAINT f_domain FOREIGN KEY (domain_name) REFERENCES context.domain(domain_name);
--
-- Name: domain_role f_domain_role_domain; Type: FK CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.domain_role
ADD CONSTRAINT f_domain_role_domain FOREIGN KEY (domain_name) REFERENCES context.domain(domain_name);
--
-- Name: domain_role f_domain_role_role; Type: FK CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.domain_role
ADD CONSTRAINT f_domain_role_role FOREIGN KEY (role_code) REFERENCES context.role(role_code);
--
-- Name: fqhost f_role; Type: FK CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.fqhost
ADD CONSTRAINT f_role FOREIGN KEY (role_code) REFERENCES context.role(role_code);
--
-- Name: role_service f_role_role; Type: FK CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.role_service
ADD CONSTRAINT f_role_role FOREIGN KEY (role_code) REFERENCES context.role(role_code);
--
-- Name: role_service f_service_serviice_type; Type: FK CONSTRAINT; Schema: context; Owner: www_data
--
ALTER TABLE ONLY context.role_service
ADD CONSTRAINT f_service_serviice_type FOREIGN KEY (service_type) REFERENCES context.service(service_type);
--
-- Name: host_objects f_fqdn; Type: FK CONSTRAINT; Schema: feeds; Owner: www_data
--
ALTER TABLE ONLY feeds.host_objects
ADD CONSTRAINT f_fqdn FOREIGN KEY (uqhost, domain) REFERENCES feeds.hard_classes(uqhost, domain);
--
-- Name: response f_json_in; Type: FK CONSTRAINT; Schema: feeds; Owner: www_data
--
ALTER TABLE ONLY feeds.response
ADD CONSTRAINT f_json_in FOREIGN KEY (feed_message_time) REFERENCES feeds.json_in(message_time);
--
-- PostgreSQL database dump complete
--