1 --*************************************************************************
2 -- (c) Copyright 2002, De Winter Information Solutions
3 -- This is free software; you can redistribute it and/or modify it under the
4 -- terms of the GNU General Public License, see the file COPYING.
5 --*************************************************************************/
7 -- Gnucomo database creation script.
10 -- This SQL script creates the initial tables for the Gnucomo database.
11 -- Before running this script with 'psql -f', you should have your
12 -- DBA create the database and give access permissions.
14 -- $Log: create.sql,v $
15 -- Revision 1.6 2003-01-20 07:29:48 arjen
16 -- Added new tables to the database: parameter_class and parameter_notification
18 -- Revision 1.5 2003/01/18 08:46:48 arjen
19 -- Added new records to the 'type_of_issue' table.
20 -- Changed semantics of actionid 9 in the 'action' table.
24 CREATE SEQUENCE "action_actionid_seq";
28 "actionid" bigint DEFAULT nextval('"action_actionid_seq"'::text) NOT NULL,
30 "statuscode" character varying(3),
35 COPY "action" FROM stdin;
36 1 Entry in the system NEW This indicates that a notification has been entered into the system.
37 2 Display to user OPN The notification has been displayed to the user. It doesn't mean that the user actually read the notification, but he/she should be aware. For that reason we consider the notification to be OPEN
38 3 Remarks added PEN Remarks have been added to the notification.
39 4 Priority changed manually PEN The priority of the notification has been changed by the user.
40 5 Priority changed automatically PEN The priority of the notification has been changed by the system. This can be the result of an action by the user or an automatical escalation.
41 6 Action taken PEN An action has been taken.
42 7 Assignment to user PEN The notification has been assigned to an user.
43 8 More information or research needed. INV The notification is relevant and will be handled, however more information or research will be needed. For that reason the status has been altered to UNDER INVESTIGATION.
44 9 Investigation completed PEN Investigation has been done. Information is available to fix the problem.
45 10 Job output no longer valid CLS By making a newer job output a valid reference, this data has been obsoleted. Since it was a reference once the output isn't interesting anymore and thus the notification can be closed.
46 11 Action taken - please verify CLS An action has been taken and things should have been resolved. Before the notification can be closed a verification has to be done. The new status is now VERIFY.
47 12 Action not verified PEN A check has been done and the results were not good. New verification is needed. The status has been changed back to PEN.
48 13 Action verified CLS A check has been done and the results were approved. The notification has been closed.
49 15 SMS sent OPN An SMS has been sent.
50 14 E-mail sent OPN An e-mail has been sent.
51 16 Fax sent OPN An fax has been sent.
52 17 Log entries shown \N The log entries relevant to the notification have been shown.
53 18 Notification closed CLS The notification has been closed.
54 19 Notification reopend OPN The notification has been reopend.
57 CREATE UNIQUE INDEX action_actionid_key ON "action" USING btree (actionid);
59 CREATE UNIQUE INDEX act_pk ON "action" USING btree (actionid);
61 CREATE UNIQUE INDEX act_actionname ON "action" USING btree (actionname);
63 CREATE INDEX act_statuscode ON "action" USING btree (statuscode);
65 SELECT setval ('"action_actionid_seq"', 19, true);
70 CREATE SEQUENCE "action_user_actionstepid_seq";
72 CREATE TABLE "action_user"
74 "actionstepid" bigint DEFAULT
75 nextval('"action_user_actionstepid_seq"'::text) NOT NULL,
78 "notificationid" bigint,
79 "timestamp" timestamp with time zone,
80 "statuscode" character varying(3),
84 CREATE UNIQUE INDEX action_user_actionstepid_key ON action_user USING btree (actionstepid);
86 CREATE INDEX anu_actionid ON action_user USING btree (actionid);
88 CREATE INDEX anu_username ON action_user USING btree (username);
90 CREATE INDEX anu_notificationid ON action_user USING btree (notificationid);
92 CREATE INDEX anu_timestamp ON action_user USING btree ("timestamp");
94 CREATE INDEX anu_statuscode ON action_user USING btree (statuscode);
96 SELECT setval ('"action_user_actionstepid_seq"', 1, false);
101 CREATE TABLE "db_value"
108 COPY "db_value" FROM stdin;
117 CREATE TABLE "history"
121 change_nature text, -- CREATED, MODIFIED or REMOVED
122 changed_property text,
131 CREATE SEQUENCE "log_logid_seq";
135 "logid" bigint DEFAULT nextval('"log_logid_seq"'::text) NOT NULL,
137 "original_filename" text,
139 "object_timestamp" timestamp with time zone,
140 "timestamp" timestamp with time zone,
142 "processed" boolean DEFAULT false,
143 "recognized" boolean DEFAULT false
146 CREATE UNIQUE INDEX log_logid_key ON log USING btree (logid);
148 CREATE INDEX log_objectid ON log USING btree (objectid);
150 CREATE INDEX log_original_filename ON log USING btree (original_filename);
152 CREATE INDEX log_servicecode ON log USING btree (servicecode);
154 CREATE INDEX log_object_timestmap ON log USING btree ("timestamp");
156 CREATE INDEX log_timestmap ON log USING btree ("timestamp");
158 CREATE INDEX log_timestamp ON log USING btree (object_timestamp);
160 CREATE INDEX log_processed ON log USING btree (processed);
162 SELECT setval ('"log_logid_seq"', 1, false);
168 CREATE SEQUENCE "log_advid_seq";
171 CREATE TABLE "log_adv"
173 "log_advid" bigint DEFAULT
174 nextval('"log_advid_seq"'::text) NOT NULL,
175 "logid" bigint NOT NULL,
176 "detailed_table" text
180 CREATE INDEX log_adv_logid ON log_adv USING btree (logid);
182 CREATE UNIQUE INDEX log_adv_log_advid ON log_adv USING btree (log_advid);
184 SELECT setval ('"log_advid_seq"', 1, false);
186 CREATE TABLE log_adv_kernel_network
193 packet_length bigint,
199 destination_port int,
205 syn boolean DEFAULT false,
212 ) INHERITS (log_adv);
216 CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER "plpgsql_call_handler" LANCOMPILER '';
217 CREATE FUNCTION "funct_processlog" () RETURNS opaque AS '
218 -- Initial date: September 18th 2002
219 -- Update: November 13th 2002
220 -- Author: Brenno J.S.A.A.F. de Winter
221 -- Abstract: This routine sets a flag
228 UPDATE db_value SET setting_value = ''TRUE'' WHERE setting = ''log_flag'';
231 ' LANGUAGE 'plpgsql';
234 CREATE TRIGGER "log_insert" AFTER INSERT ON "log" FOR EACH ROW EXECUTE PROCEDURE "funct_processlog" ();
239 CREATE TABLE "log_notification"
241 "notificationid" bigint,
245 CREATE UNIQUE INDEX lon_pk ON log_notification USING btree (notificationid, logid);
247 CREATE UNIQUE INDEX lon_notificationid ON log_notification USING btree (notificationid);
249 CREATE UNIQUE INDEX lon_logid ON log_notification USING btree (logid);
254 CREATE SEQUENCE "notification_notificationid_seq";
256 CREATE TABLE "notification"
258 "notificationid" bigint DEFAULT
259 nextval('"notification_notificationid_seq"'::text) NOT NULL,
261 "type_of_issueid" bigint,
262 "timestamp" timestamp with time zone,
263 "statuscode" character varying(3),
265 "escalation_count_timestamp" timestamp with time zone,
266 "repeat_notification_timestamp" timestamp with time zone,
267 "securitylevel_view" integer,
268 "securitylevel_add" integer,
269 "securitylevel_close" integer
272 CREATE UNIQUE INDEX notification_notificationid_key ON notification USING btree (notificationid);
274 CREATE INDEX not_objectid ON notification USING btree (objectid);
276 CREATE INDEX not_type_of_issueid ON notification USING btree (type_of_issueid);
278 CREATE INDEX not_timestamp ON notification USING btree ("timestamp");
280 CREATE INDEX not_statuscode ON notification USING btree (statuscode);
282 CREATE INDEX not_priority ON notification USING btree (priority);
284 CREATE INDEX not_escalation_count_timestamp ON notification USING btree (escalation_count_timestamp);
286 CREATE INDEX not_repeat_notification_timesta ON notification USING btree (repeat_notification_timestamp);
288 SELECT setval ('"notification_notificationid_seq"', 1, false);
293 CREATE SEQUENCE "object_objectid_seq";
295 CREATE TABLE "object"
297 "objectid" bigint DEFAULT nextval('"object_objectid_seq"'::text) NOT NULL,
300 "scp_enabled" boolean,
302 "mail_enabled" boolean,
304 "sms_enabled" boolean,
306 "fax_enabled" boolean,
308 "object_description" text,
310 "physical_location" text,
317 CREATE UNIQUE INDEX object_objectid_key ON object USING btree (objectid);
319 CREATE UNIQUE INDEX obj_objectname ON object USING btree (objectname);
321 CREATE UNIQUE INDEX obj_objectcode ON object USING btree (objectcode);
323 CREATE INDEX obj_mail_from ON object USING btree (mail_from);
325 CREATE INDEX os ON object (os);
327 CREATE INDEX os_version ON object (os, os_version);
329 SELECT setval ('"object_objectid_seq"', 1, false);
334 CREATE TABLE "object_issue"
337 "type_of_issueid" bigint,
338 "default_priority" integer,
339 "escalation" boolean,
340 "escalation_time" time without time zone,
341 "max_priority" integer,
342 "adjust_setting" text
345 CREATE UNIQUE INDEX obj_pk ON object_issue USING btree (objectid, type_of_issueid);
347 CREATE INDEX obj_objectid ON object_issue USING btree (objectid);
349 CREATE UNIQUE INDEX obj_type_of_notificationid ON object_issue USING btree (type_of_issueid);
354 CREATE TABLE "object_priority"
357 "priorityid" integer,
361 "repeat_notification" boolean,
362 "interval_for_repeat" time without time zone
365 CREATE UNIQUE INDEX obi_pk ON object_priority USING btree (objectid, priorityid);
367 CREATE INDEX obi_objectid ON object_priority USING btree (objectid);
369 CREATE INDEX obi_priorityid ON object_priority USING btree (priorityid);
374 CREATE TABLE "object_service"
378 "expected_interval" bigint,
379 "last_entry" timestamp with time zone,
380 "default_priority" integer,
381 "maximum_priority" integer,
385 CREATE UNIQUE INDEX obs_pk ON object_service USING btree (objectid, servicecode);
387 CREATE INDEX obs_objectid ON object_service USING btree (objectid);
389 CREATE INDEX obs_servicecode ON object_service USING btree (servicecode);
391 CREATE INDEX obs_accepted ON object_service USING btree (accepted);
396 CREATE TABLE "object_user"
400 "security_level" integer
403 CREATE UNIQUE INDEX ous_pk ON object_user USING btree (objectid, username);
405 CREATE INDEX ous_objectid ON object_user USING btree (objectid);
407 CREATE INDEX ous_username ON object_user USING btree (username);
409 CREATE INDEX ous_security_level ON object_user USING btree (security_level);
414 CREATE SEQUENCE "paramid_seq";
416 CREATE TABLE "parameter"
418 "paramid" bigint DEFAULT nextval('"paramid_seq"'::text) NOT NULL,
424 primary key (paramid)
427 CREATE UNIQUE INDEX param_obj_name ON parameter USING btree (objectid, name, class);
429 SELECT setval ('"paramid_seq"', 1, true);
434 CREATE TABLE "parameter_class"
436 "name" text, -- Name of the class: see parameter.class
437 "property_name" text,
439 "property_type" text, -- STATIC or DYNAMIC
440 "min" float, -- Default minimum value
441 "max" float, -- Default maximum value
442 "notify" boolean, -- Notify if something changes ?
444 primary key (name, property_name)
447 INSERT INTO parameter_class (name, property_name, description, property_type, notify)
448 VALUES ('package', 'version', 'The installed version of the package', 'STATIC', 't');
453 CREATE TABLE "parameter_notification"
455 "notificationid" bigint,
458 primary key (notificationid, paramid)
464 CREATE TABLE "priority"
470 "repeat_notification" boolean,
471 "interval_for_repeat" time without time zone
475 CREATE UNIQUE INDEX pri_pk ON priority USING btree (priority);
480 CREATE TABLE "property"
485 type text, -- STATIC or DYNAMIC
489 primary key (paramid, name)
495 CREATE TABLE "service"
499 "default_priority" integer,
500 "max_priority" integer
503 COPY "service" FROM stdin;
513 CREATE UNIQUE INDEX ser_pk ON service USING btree (servicecode);
515 CREATE UNIQUE INDEX ser_servicename ON service USING btree (servicename);
519 CREATE TABLE "status"
521 "statuscode" character varying(3),
523 "open_notification" boolean,
528 COPY "status" FROM stdin;
529 new new entry t Just detected, but nothing has been done yet
530 opn open notification t The notification has been displayed to a user or a user has been notified. However nothing has been done yet.
531 pen pending t The notification is currently being worked on.
532 ver waiting for verification t The notification has been worked on and is currently awaiting the approval/verification.
533 rej rejected f The notification has been identified as a false postive and was reject. The notification is now closed
534 cls closed f The notification has been closed
535 inv needs investigation t The notification is currently under investigation and is awaiting additional details before one can work on this again.
538 CREATE UNIQUE INDEX sta_pk ON status USING btree (statuscode);
540 CREATE UNIQUE INDEX sta_statusname ON status USING btree (statusname);
542 CREATE INDEX sta_open_notification ON status USING btree (open_notification);
547 CREATE TABLE supported_os
553 CREATE UNIQUE INDEX spp_os ON supported_os (os_name);
558 CREATE SEQUENCE "type_of_issue_type_of_issue_seq";
560 CREATE TABLE "type_of_issue"
562 "type_of_issueid" bigint DEFAULT
563 nextval('"type_of_issue_type_of_issue_seq"'::text) NOT NULL,
565 "suggested_priority" text,
568 automated_check boolean,
571 recheck_interval timestamp
575 COPY "type_of_issue" FROM stdin;
576 1 manual entry 4 A manual entry of a notification t
577 2 parameter created 3 A new parameter was created t
578 3 property modified 3 The STATIC property of a parameter was modified t
579 4 parameter removed 3 A parameter was removed t
582 CREATE UNIQUE INDEX type_of_issue_type_of_issue_key ON type_of_issue USING btree (type_of_issueid);
584 CREATE UNIQUE INDEX toi_name ON type_of_issue USING btree (name);
586 CREATE INDEX toi_active ON type_of_issue USING btree (active);
588 SELECT setval ('"type_of_issue_type_of_issue_seq"', 4, true);
595 "username" text NOT NULL,
596 "active_sessionid" bigint,
597 "account_active" boolean,
598 "security_level" integer
601 CREATE UNIQUE INDEX usr_username ON usr USING btree (username);
603 CREATE UNIQUE INDEX usr_active_sessionid ON usr USING btree (active_sessionid);
605 CREATE INDEX usr_account_active ON usr USING btree (account_active);
607 CREATE INDEX usr_security_level ON usr USING btree (security_level);