schema-related information (like schema version, DB syntax, etc.) moved from "config...
[public/netxms.git] / sql / schema.in
1 /*
2 ** NetXMS Database Schema
3 **
4 ** ex: syntax=sql
5 */
6
7
8 /*
9 ** Metadata
10 */
11
12 CREATE TABLE metadata
13 (
14 var_name varchar(63) not null,
15 var_value varchar(255) not null,
16 PRIMARY KEY(var_name)
17 ) TABLE_TYPE;
18
19
20 /*
21 ** System configuration table
22 */
23
24 CREATE TABLE config
25 (
26 var_name varchar(63) not null,
27 var_value varchar(255) not null,
28 #ifdef DB_ORACLE
29 is_visible integer default 1 not null,
30 need_server_restart integer default 0 not null,
31 #else
32 is_visible integer not null default 1,
33 need_server_restart integer not null default 0,
34 #endif
35 PRIMARY KEY(var_name)
36 ) TABLE_TYPE;
37
38
39 /*
40 ** System configuration data (for large data)
41 */
42
43 CREATE TABLE config_clob
44 (
45 var_name varchar(63) not null,
46 var_value SQL_TEXT not null,
47 PRIMARY KEY(var_name)
48 ) TABLE_TYPE;
49
50
51 /*
52 ** Users
53 */
54
55 CREATE TABLE users
56 (
57 id integer not null,
58 guid varchar(36) not null,
59 name varchar(63) not null,
60 password varchar(48) not null,
61 system_access integer not null,
62 flags integer not null,
63 full_name varchar(127) not null,
64 description varchar(255) not null,
65 grace_logins integer not null,
66 auth_method integer not null,
67 cert_mapping_method integer not null,
68 cert_mapping_data SQL_TEXT not null,
69 PRIMARY KEY(id)
70 ) TABLE_TYPE;
71
72
73 /*
74 ** User groups
75 */
76
77 CREATE TABLE user_groups
78 (
79 id integer not null,
80 guid varchar(36) not null,
81 name varchar(63) not null,
82 system_access integer not null,
83 flags integer not null,
84 description varchar(255) not null,
85 PRIMARY KEY(id)
86 ) TABLE_TYPE;
87
88
89 /*
90 ** Users to groups mapping
91 */
92
93 CREATE TABLE user_group_members
94 (
95 group_id integer not null,
96 user_id integer not null,
97 PRIMARY KEY(group_id,user_id)
98 ) TABLE_TYPE;
99
100
101 /*
102 ** User profiles
103 */
104
105 CREATE TABLE user_profiles
106 (
107 user_id integer not null,
108 var_name varchar(255) not null,
109 var_value SQL_TEXT not null,
110 PRIMARY KEY(user_id,var_name)
111 ) TABLE_TYPE;
112
113
114 /*
115 ** Common object properties
116 */
117
118 CREATE TABLE object_properties
119 (
120 object_id integer not null,
121 name varchar(63) not null,
122 status integer not null,
123 is_deleted integer not null,
124 is_system integer not null,
125 image_id integer not null,
126 last_modified integer not null,
127 inherit_access_rights integer not null,
128 status_calc_alg integer not null,
129 status_prop_alg integer not null,
130 status_fixed_val integer not null,
131 status_shift integer not null,
132 status_translation varchar(8) not null,
133 status_single_threshold integer not null,
134 status_thresholds varchar(8) not null,
135 comments SQL_TEXT not null,
136 PRIMARY KEY(object_id)
137 ) TABLE_TYPE;
138
139
140 /*
141 ** Object custom attributes
142 */
143
144 CREATE TABLE object_custom_attributes
145 (
146 object_id integer not null,
147 attr_name varchar(127) not null,
148 attr_value SQL_TEXT not null,
149 PRIMARY KEY(object_id,attr_name)
150 ) TABLE_TYPE;
151
152
153 /*
154 ** Zone object
155 */
156
157 CREATE TABLE zones
158 (
159 id integer not null, // Zone object's ID
160 zone_guid integer not null, // Globally unique ID for zone
161 zone_type integer not null, // Active or passive zone
162 controller_ip varchar(15) not null,
163 PRIMARY KEY(id)
164 ) TABLE_TYPE;
165
166
167 /*
168 ** Zone IP address list
169 */
170
171 CREATE TABLE zone_ip_addr_list
172 (
173 zone_id integer not null, // Zone object's ID
174 ip_addr varchar(15) not null,
175 PRIMARY KEY(zone_id,ip_addr)
176 ) TABLE_TYPE;
177
178
179 /*
180 ** Nodes information
181 */
182
183 CREATE TABLE nodes
184 (
185 id integer not null,
186 primary_ip varchar(15) not null,
187 node_flags integer not null,
188 snmp_version integer not null,
189 community varchar(127) not null,
190 snmp_oid varchar(255) not null,
191 auth_method integer not null,
192 secret varchar(64) not null,
193 agent_port integer not null,
194 status_poll_type integer not null,
195 node_type integer not null,
196 agent_version varchar(63) not null,
197 platform_name varchar(63) not null,
198 poller_node_id integer not null,
199 zone_guid integer not null,
200 proxy_node integer not null,
201 snmp_proxy integer not null,
202 required_polls integer not null,
203 uname varchar(255) not null,
204 use_ifxtable integer not null,
205 PRIMARY KEY(id)
206 ) TABLE_TYPE;
207
208
209 /*
210 ** Clusters information
211 */
212
213 CREATE TABLE clusters
214 (
215 id integer not null,
216 cluster_type integer not null,
217 PRIMARY KEY(id)
218 ) TABLE_TYPE;
219
220
221 /*
222 ** Cluster members
223 */
224
225 CREATE TABLE cluster_members
226 (
227 cluster_id integer not null,
228 node_id integer not null,
229 PRIMARY KEY(cluster_id,node_id)
230 ) TABLE_TYPE;
231
232
233 /*
234 ** Cluster interconnect subnets
235 */
236
237 CREATE TABLE cluster_sync_subnets
238 (
239 cluster_id integer not null,
240 subnet_addr varchar(15) not null,
241 subnet_mask varchar(15) not null,
242 PRIMARY KEY(cluster_id,subnet_addr)
243 ) TABLE_TYPE;
244
245
246 /*
247 ** Cluster resources
248 */
249
250 CREATE TABLE cluster_resources
251 (
252 cluster_id integer not null,
253 resource_id integer not null,
254 resource_name varchar(255) not null,
255 ip_addr varchar(15) not null,
256 PRIMARY KEY(cluster_id,resource_id)
257 ) TABLE_TYPE;
258
259
260 /*
261 ** Subnets
262 */
263
264 CREATE TABLE subnets
265 (
266 id integer not null,
267 ip_addr varchar(15) not null,
268 ip_netmask varchar(15) not null,
269 zone_guid integer not null,
270 synthetic_mask integer not null,
271 PRIMARY KEY(id)
272 ) TABLE_TYPE;
273
274
275 /*
276 ** Nodes' interfaces
277 */
278
279 CREATE TABLE interfaces
280 (
281 id integer not null,
282 node_id integer not null,
283 ip_addr varchar(15) not null,
284 ip_netmask varchar(15) not null,
285 if_type integer not null,
286 if_index integer not null,
287 mac_addr varchar(15) not null,
288 synthetic_mask integer not null,
289 required_polls integer not null,
290 PRIMARY KEY(id)
291 ) TABLE_TYPE;
292
293
294 /*
295 ** Network services
296 */
297
298 CREATE TABLE network_services
299 (
300 id integer not null,
301 node_id integer not null,
302 service_type integer not null,
303 ip_bind_addr varchar(15) not null,
304 ip_proto integer not null,
305 ip_port integer not null,
306 check_request SQL_TEXT not null,
307 check_responce SQL_TEXT not null,
308 poller_node_id integer not null,
309 required_polls integer not null,
310 PRIMARY KEY(id)
311 ) TABLE_TYPE;
312
313
314 /*
315 ** VPN connectors
316 */
317
318 CREATE TABLE vpn_connectors
319 (
320 id integer not null,
321 node_id integer not null,
322 peer_gateway integer not null,
323 PRIMARY KEY(id)
324 ) TABLE_TYPE;
325
326
327 /*
328 ** VPN connector networks
329 */
330
331 CREATE TABLE vpn_connector_networks
332 (
333 vpn_id integer not null,
334 network_type integer not null, // 0 == local, 1 == remote
335 ip_addr varchar(15) not null,
336 ip_netmask varchar(15) not null,
337 PRIMARY KEY(vpn_id,ip_addr)
338 ) TABLE_TYPE;
339
340
341 /*
342 ** Container objects
343 */
344
345 CREATE TABLE containers
346 (
347 id integer not null,
348 category integer not null,
349 object_class integer not null,
350 PRIMARY KEY(id)
351 ) TABLE_TYPE;
352
353
354 /*
355 ** Condition objects
356 */
357
358 CREATE TABLE conditions
359 (
360 id integer not null,
361 activation_event integer not null,
362 deactivation_event integer not null,
363 source_object integer not null,
364 active_status integer not null,
365 inactive_status integer not null,
366 script SQL_TEXT not null,
367 PRIMARY KEY(id)
368 ) TABLE_TYPE;
369
370
371 /*
372 ** DCI to condition mapping
373 */
374
375 CREATE TABLE cond_dci_map
376 (
377 condition_id integer not null,
378 sequence_number integer not null,
379 dci_id integer not null,
380 node_id integer not null,
381 dci_func integer not null,
382 num_polls integer not null,
383 PRIMARY KEY(condition_id,sequence_number)
384 ) TABLE_TYPE;
385
386
387 /*
388 ** Data collection templates
389 */
390
391 CREATE TABLE templates
392 (
393 id integer not null,
394 version integer,
395 PRIMARY KEY(id)
396 ) TABLE_TYPE;
397
398
399 /*
400 ** Mapping hosts to templates
401 */
402
403 CREATE TABLE dct_node_map
404 (
405 template_id integer not null,
406 node_id integer not null,
407 PRIMARY KEY(template_id,node_id)
408 ) TABLE_TYPE;
409
410
411 /*
412 ** Nodes to subnets mapping
413 */
414
415 CREATE TABLE nsmap
416 (
417 subnet_id integer not null,
418 node_id integer not null,
419 PRIMARY KEY(subnet_id,node_id)
420 ) TABLE_TYPE;
421
422
423 /*
424 ** Container members
425 */
426
427 CREATE TABLE container_members
428 (
429 container_id integer not null,
430 object_id integer not null,
431 PRIMARY KEY(container_id,object_id)
432 ) TABLE_TYPE;
433
434
435 /*
436 ** Container categories
437 */
438
439 CREATE TABLE container_categories
440 (
441 category integer not null,
442 name varchar(63),
443 image_id integer not null,
444 description SQL_TEXT,
445 PRIMARY KEY(category)
446 ) TABLE_TYPE;
447
448
449 /*
450 ** Objects' ACLs
451 */
452
453 CREATE TABLE acl
454 (
455 object_id integer not null,
456 user_id integer not null,
457 access_rights integer not null,
458 PRIMARY KEY(object_id,user_id)
459 ) TABLE_TYPE;
460
461
462 /*
463 ** Trusted nodes - used for cross-node data collection
464 ** Source object is an object providing data (it can be node or condition),
465 ** and target node is a node owning DCI
466 */
467
468 CREATE TABLE trusted_nodes
469 (
470 source_object_id integer not null,
471 target_node_id integer not null,
472 PRIMARY KEY(source_object_id,target_node_id)
473 ) TABLE_TYPE;
474
475
476 /*
477 ** Data collection items
478 **
479 ** If node_id != 0, it's an item bound to node, and template_id points to
480 ** the template used for creating this item. In this case, template_id = 0
481 ** means that item was created manually.
482 ** If node_id = 0, it's a template item, and template_id points to a template
483 ** this item belongs to.
484 ** If both node_id and template_id is 0, it's an error.
485 */
486
487 CREATE TABLE items
488 (
489 item_id integer not null,
490 node_id integer not null,
491 template_id integer not null,
492 template_item_id integer not null,
493 name varchar(255) not null,
494 description varchar(255) not null,
495 source integer not null, // 0 for internal or 1 for native agent or 2 for SNMP
496 datatype integer not null,
497 polling_interval integer not null,
498 retention_time integer not null,
499 adv_schedule integer not null, // 1 if item has advanced schedule
500 status integer not null, // ACTIVE, DISABLED or NOT_SUPPORTED
501 delta_calculation integer not null,
502 transformation SQL_TEXT not null, // Transformation script
503 instance varchar(255) not null, // Free form text which can be used in events
504 all_thresholds integer not null, // 1 if all thresholds should be processed at every check
505 resource_id integer not null, // associated cluster resource ID
506 proxy_node integer not null, // ID of proxy node (for SNMP and agent items)
507 PRIMARY KEY(item_id)
508 ) TABLE_TYPE;
509
510
511 /*
512 ** Schedules for DCIs
513 */
514
515 CREATE TABLE dci_schedules
516 (
517 schedule_id integer not null,
518 item_id integer not null,
519 schedule varchar(255) not null,
520 PRIMARY KEY(item_id,schedule_id)
521 ) TABLE_TYPE;
522
523
524 /*
525 ** Latest raw values for all data collection items
526 */
527
528 CREATE TABLE raw_dci_values
529 (
530 item_id integer not null,
531 raw_value varchar(255),
532 last_poll_time integer,
533 PRIMARY KEY(item_id)
534 ) TABLE_TYPE;
535
536 #ifndef DB_ORACLE
537 CREATE INDEX idx_raw_dci_values_item_id ON raw_dci_values(item_id);
538 #endif
539
540
541 /*
542 ** Events configuration
543 */
544
545 CREATE TABLE event_cfg
546 (
547 event_code integer not null,
548 event_name varchar(63) not null, // Short event name
549 severity integer,
550 flags integer,
551 message varchar(255), // Message template
552 description SQL_TEXT,
553 PRIMARY KEY(event_code)
554 ) TABLE_TYPE;
555
556
557 /*
558 ** Event log
559 */
560
561 CREATE TABLE event_log
562 (
563 event_id SQL_INT64 not null,
564 event_code integer not null,
565 event_timestamp integer,
566 event_source integer, // Source object ID
567 event_severity integer,
568 event_message varchar(255),
569 root_event_id SQL_INT64 default 0,
570 /* Non-zero if current event correlates to some other event */
571 user_tag varchar(63) not null,
572 PRIMARY KEY(event_id)
573 ) TABLE_TYPE;
574
575 CREATE INDEX idx_event_log_event_timestamp ON event_log(event_timestamp);
576
577
578 /*
579 ** Actions on events
580 */
581
582 CREATE TABLE actions
583 (
584 action_id integer not null,
585 action_name varchar(63) not null,
586 action_type integer not null,
587 is_disabled integer,
588 // Field "rcpt_addr" holds e-mail address for e-mail actions,
589 // phone number for sms actions, and remote host address for
590 // remote execution actions
591 rcpt_addr varchar(255),
592 email_subject varchar(255),
593 // Field "action_data" holds message text for e-mail and sms actions,
594 // command line for external command execution actions, or
595 // action name with optional arguments for remote execution actions
596 action_data SQL_TEXT not null,
597 PRIMARY KEY(action_id)
598 ) TABLE_TYPE;
599
600
601 /*
602 ** Event groups
603 */
604
605 CREATE TABLE event_groups
606 (
607 id integer not null,
608 name varchar(63) not null,
609 description varchar(255) not null,
610 range_start integer not null,
611 range_end integer not null,
612 PRIMARY KEY(id)
613 ) TABLE_TYPE;
614
615
616 /*
617 ** Event group members
618 */
619
620 CREATE TABLE event_group_members
621 (
622 group_id integer not null,
623 event_code integer not null,
624 PRIMARY KEY(group_id,event_code)
625 ) TABLE_TYPE;
626
627
628 /*
629 ** Event processing policy
630 */
631
632 CREATE TABLE event_policy
633 (
634 rule_id integer not null, // Rule number
635 flags integer not null,
636 comments SQL_TEXT not null,
637 script SQL_TEXT not null,
638 alarm_message varchar(255) not null,
639 alarm_severity integer not null,
640 alarm_key varchar(255) not null, // Alarm key (used for auto termination)
641 alarm_timeout integer not null, // Timeout before sending event
642 alarm_timeout_event integer not null, // Event to be sent on timeout
643 situation_id integer not null, // Situation to update
644 situation_instance varchar(255) not null,
645 PRIMARY KEY(rule_id)
646 ) TABLE_TYPE;
647
648 CREATE TABLE policy_source_list
649 (
650 rule_id integer not null,
651 object_id integer not null,
652 PRIMARY KEY(rule_id,object_id)
653 ) TABLE_TYPE;
654
655 CREATE TABLE policy_event_list
656 (
657 rule_id integer not null,
658 event_code integer not null,
659 PRIMARY KEY(rule_id,event_code)
660 ) TABLE_TYPE;
661
662 CREATE TABLE policy_action_list
663 (
664 rule_id integer not null,
665 action_id integer not null,
666 PRIMARY KEY(rule_id,action_id)
667 ) TABLE_TYPE;
668
669 CREATE TABLE policy_time_range_list
670 (
671 rule_id integer not null,
672 time_range_id integer not null,
673 PRIMARY KEY(rule_id,time_range_id)
674 ) TABLE_TYPE;
675
676 CREATE TABLE policy_situation_attr_list
677 (
678 rule_id integer not null,
679 situation_id integer not null,
680 attr_name varchar(255) not null,
681 attr_value varchar(255) not null,
682 PRIMARY KEY(rule_id,situation_id,attr_name)
683 ) TABLE_TYPE;
684
685
686 /*
687 ** Time range objects
688 */
689
690 CREATE TABLE time_ranges
691 (
692 time_range_id integer not null,
693 wday_mask integer not null, // Bits 0 .. 6 for each day of week
694 mday_mask integer not null, // Bits 0 .. 30 for each day of month
695 month_mask integer not null, // Bits 0 .. 11 for each month
696 time_range varchar(255) not null, // In format HHMMHHMM[,HHMMHHMM[,...]]
697 PRIMARY KEY(time_range_id)
698 ) TABLE_TYPE;
699
700
701 /*
702 ** Deleted objects
703 */
704
705 CREATE TABLE deleted_objects
706 (
707 object_id integer not null,
708 object_class integer not null,
709 name varchar(63) not null,
710 ip_addr varchar(15) not null,
711 ip_netmask varchar(15) not null,
712 PRIMARY KEY(object_id)
713 ) TABLE_TYPE;
714
715
716 /*
717 ** Threshold checking rules
718 */
719
720 CREATE TABLE thresholds
721 (
722 threshold_id integer not null,
723 item_id integer not null,
724 sequence_number integer not null,
725 fire_value varchar(255) not null,
726 rearm_value varchar(255) not null,
727 check_function integer not null,
728 check_operation integer not null,
729 parameter_1 integer not null,
730 parameter_2 integer not null,
731 event_code integer not null,
732 rearm_event_code integer not null,
733 current_state integer not null,
734 repeat_interval integer not null,
735 PRIMARY KEY(threshold_id)
736 ) TABLE_TYPE;
737
738 CREATE INDEX idx_thresholds_item_id ON thresholds(item_id);
739 CREATE INDEX idx_thresholds_sequence ON thresholds(sequence_number);
740
741
742 /*
743 ** Alarms
744 */
745
746 CREATE TABLE alarms
747 (
748 alarm_id integer not null, // Unique alarm identifier
749 alarm_state integer not null,
750 hd_state integer not null, // Help desk system state
751 hd_ref varchar(63) not null, // Help desk reference
752 creation_time integer not null,
753 last_change_time integer not null,
754 source_object_id integer not null,
755 source_event_code integer not null,
756 source_event_id SQL_INT64 not null,
757 message varchar(255) not null,
758 original_severity integer not null,
759 current_severity integer not null,
760 repeat_count integer not null,
761 alarm_key varchar(255) not null, // Alarm key (used for auto acknowlegment)
762 ack_by integer not null, // ID of user who was acknowleged alarm
763 term_by integer not null, // ID of user who was terminated alarm
764 timeout integer not null,
765 timeout_event integer not null,
766 PRIMARY KEY(alarm_id)
767 ) TABLE_TYPE;
768
769
770 /*
771 ** Alarm notes
772 */
773
774 CREATE TABLE alarm_notes
775 (
776 note_id integer not null,
777 alarm_id integer not null,
778 change_time integer not null,
779 user_id integer not null, // Last edited by
780 note_text SQL_TEXT not null,
781 PRIMARY KEY(note_id)
782 ) TABLE_TYPE;
783
784 CREATE INDEX idx_alarm_notes_alarm_id ON alarm_notes(alarm_id);
785
786
787 /*
788 ** Image catalog
789 */
790
791 CREATE TABLE images
792 (
793 image_id integer not null,
794 name varchar(64),
795 file_name_png varchar(255),
796 file_hash_png varchar(32),
797 file_name_ico varchar(255),
798 file_hash_ico varchar(32),
799 PRIMARY KEY(image_id)
800 ) TABLE_TYPE;
801
802
803 /*
804 ** Default images for various object classes
805 */
806
807 CREATE TABLE default_images
808 (
809 object_class integer not null,
810 image_id integer not null,
811 PRIMARY KEY(object_class)
812 ) TABLE_TYPE;
813
814
815 /*
816 ** OID to node type translation
817 */
818
819 CREATE TABLE oid_to_type
820 (
821 pair_id integer not null,
822 snmp_oid varchar(255) not null,
823 node_type integer not null,
824 node_flags integer not null,
825 PRIMARY KEY(pair_id)
826 ) TABLE_TYPE;
827
828
829 /*
830 ** SNMP trap configuration
831 */
832
833 CREATE TABLE snmp_trap_cfg
834 (
835 trap_id integer not null,
836 snmp_oid varchar(255) not null,
837 event_code integer not null,
838 user_tag varchar(63) not null,
839 description varchar(255),
840 PRIMARY KEY(trap_id)
841 ) TABLE_TYPE;
842
843
844 /*
845 ** SNMP trap parameters mapping
846 */
847
848 CREATE TABLE snmp_trap_pmap
849 (
850 trap_id integer not null,
851 parameter integer not null,
852 snmp_oid varchar(255),
853 description varchar(255),
854 PRIMARY KEY(trap_id,parameter)
855 ) TABLE_TYPE;
856
857
858 /*
859 ** Agent packages
860 */
861
862 CREATE TABLE agent_pkg
863 (
864 pkg_id integer not null,
865 pkg_name varchar(63),
866 version varchar(31),
867 platform varchar(63),
868 pkg_file varchar(255),
869 description varchar(255),
870 PRIMARY KEY(pkg_id)
871 ) TABLE_TYPE;
872
873
874 /*
875 ** Object tools
876 */
877
878 CREATE TABLE object_tools
879 (
880 tool_id integer not null,
881 tool_name varchar(255) not null,
882 tool_type integer not null,
883 tool_data SQL_TEXT not null,
884 description varchar(255) not null,
885 flags integer not null,
886 matching_oid varchar(255) not null,
887 confirmation_text varchar(255) not null,
888 PRIMARY KEY(tool_id)
889 ) TABLE_TYPE;
890
891
892 /*
893 ** Access list for object tools
894 */
895
896 CREATE TABLE object_tools_acl
897 (
898 tool_id integer not null,
899 user_id integer not null,
900 PRIMARY KEY(tool_id,user_id)
901 ) TABLE_TYPE;
902
903
904 /*
905 ** Configuration of columns for SNMP_TABLE and AGENT_TABLE type of object tools
906 */
907
908 CREATE TABLE object_tools_table_columns
909 (
910 tool_id integer not null,
911 col_number integer not null,
912 col_name varchar(255),
913 col_oid varchar(255),
914 col_format integer, // Column format (integer, string, etc.)
915 col_substr integer, // Number of matching substring in regexp
916 PRIMARY KEY(tool_id,col_number)
917 ) TABLE_TYPE;
918
919
920 /*
921 ** Stored syslog messages
922 */
923
924 CREATE TABLE syslog
925 (
926 msg_id SQL_INT64 not null,
927 msg_timestamp integer not null,
928 facility integer not null,
929 severity integer not null,
930 source_object_id integer not null,
931 hostname varchar(127) not null,
932 msg_tag varchar(32) not null,
933 msg_text SQL_TEXT not null,
934 PRIMARY KEY(msg_id)
935 ) TABLE_TYPE;
936
937 CREATE INDEX idx_syslog_msg_timestamp ON syslog(msg_timestamp);
938
939
940 /*
941 ** Script library
942 */
943
944 CREATE TABLE script_library
945 (
946 script_id integer not null,
947 script_name varchar(255) not null,
948 script_code SQL_TEXT not null,
949 PRIMARY KEY(script_id)
950 ) TABLE_TYPE;
951
952
953 /*
954 ** Extended SNMP trap log
955 */
956
957 CREATE TABLE snmp_trap_log
958 (
959 trap_id SQL_INT64 not null,
960 trap_timestamp integer not null,
961 ip_addr varchar(15) not null,
962 object_id integer not null,
963 trap_oid varchar(255) not null,
964 trap_varlist SQL_TEXT not null,
965 PRIMARY KEY(trap_id)
966 ) TABLE_TYPE;
967
968 CREATE INDEX idx_snmp_trap_log_tt ON snmp_trap_log(trap_timestamp);
969
970
971 /*
972 ** Network maps
973 */
974
975 CREATE TABLE maps
976 (
977 map_id integer not null,
978 map_name varchar(255) not null,
979 description SQL_TEXT not null,
980 root_object_id integer not null,
981 PRIMARY KEY(map_id)
982 ) TABLE_TYPE;
983
984
985 /*
986 ** Map ACLs
987 */
988
989 CREATE TABLE map_access_lists
990 (
991 map_id integer not null,
992 user_id integer not null,
993 access_rights integer not null,
994 PRIMARY KEY(map_id,user_id)
995 ) TABLE_TYPE;
996
997
998 /*
999 ** Submaps of network maps
1000 */
1001
1002 CREATE TABLE submaps
1003 (
1004 map_id integer not null,
1005 submap_id integer not null, // Equal to object id
1006 attributes integer not null,
1007 PRIMARY KEY(map_id,submap_id)
1008 ) TABLE_TYPE;
1009
1010
1011 /*
1012 ** Object positioning on submap
1013 */
1014
1015 CREATE TABLE submap_object_positions
1016 (
1017 map_id integer not null,
1018 submap_id integer not null,
1019 object_id integer not null,
1020 x integer not null,
1021 y integer not null,
1022 PRIMARY KEY(map_id,submap_id,object_id)
1023 ) TABLE_TYPE;
1024
1025
1026 /*
1027 ** Object links on submap
1028 */
1029
1030 CREATE TABLE submap_links
1031 (
1032 map_id integer not null,
1033 submap_id integer not null,
1034 object_id1 integer not null,
1035 object_id2 integer not null,
1036 link_type integer not null,
1037 port1 varchar(255) not null,
1038 port2 varchar(255) not null,
1039 PRIMARY KEY(map_id,submap_id,object_id1,object_id2)
1040 ) TABLE_TYPE;
1041
1042
1043 /*
1044 ** Agent configurations
1045 */
1046
1047 CREATE TABLE agent_configs
1048 (
1049 config_id integer not null,
1050 config_name varchar(255) not null,
1051 config_file SQL_TEXT not null,
1052 config_filter SQL_TEXT not null,
1053 sequence_number integer not null,
1054 PRIMARY KEY(config_id)
1055 ) TABLE_TYPE;
1056
1057
1058 /*
1059 ** Address lists
1060 */
1061
1062 CREATE TABLE address_lists
1063 (
1064 list_type integer not null, // discovery filter, etc.
1065 community_id integer not null, // community id for snmp community addr list, otherwise 0
1066 addr_type integer not null, // 0 - addr/mask, 1 - address range
1067 addr1 varchar(15) not null,
1068 addr2 varchar(15) not null,
1069 PRIMARY KEY(list_type,community_id,addr_type,addr1,addr2)
1070 ) TABLE_TYPE;
1071
1072 CREATE INDEX idx_address_lists_list_type ON address_lists(list_type);
1073
1074
1075 /*
1076 ** Graphs
1077 */
1078
1079 CREATE TABLE graphs
1080 (
1081 graph_id integer not null,
1082 owner_id integer not null,
1083 name varchar(255) not null,
1084 config SQL_TEXT not null,
1085 PRIMARY KEY(graph_id)
1086 ) TABLE_TYPE;
1087
1088
1089 /*
1090 ** Graph access lists
1091 */
1092
1093 CREATE TABLE graph_acl
1094 (
1095 graph_id integer not null,
1096 user_id integer not null,
1097 user_rights integer not null,
1098 PRIMARY KEY(graph_id,user_id)
1099 ) TABLE_TYPE;
1100
1101
1102 /*
1103 ** Certificates
1104 */
1105
1106 CREATE TABLE certificates
1107 (
1108 cert_id integer not null,
1109 cert_type integer not null,
1110 cert_data SQL_TEXT not null, // Certificate in PEM format
1111 subject SQL_TEXT not null,
1112 comments SQL_TEXT not null,
1113 PRIMARY KEY(cert_id)
1114 ) TABLE_TYPE;
1115
1116
1117
1118 /*
1119 ** Audit log
1120 */
1121
1122 CREATE TABLE audit_log
1123 (
1124 record_id integer not null,
1125 timestamp integer not null,
1126 subsystem varchar(32) not null,
1127 success integer not null,
1128 user_id integer not null, // 0x7FFFFFFF for system
1129 workstation varchar(63) not null,
1130 object_id integer not null,
1131 message SQL_TEXT not null,
1132 PRIMARY KEY(record_id)
1133 ) TABLE_TYPE;
1134
1135
1136 /*
1137 ** Situations
1138 */
1139
1140 CREATE TABLE situations
1141 (
1142 id integer not null,
1143 name varchar(127) not null,
1144 comments SQL_TEXT not null,
1145 PRIMARY KEY(id)
1146 ) TABLE_TYPE;
1147
1148
1149 /*
1150 ** List of possible community strings
1151 */
1152
1153 CREATE TABLE snmp_communities
1154 (
1155 id integer not null,
1156 community varchar(255) not null,
1157 PRIMARY KEY(id)
1158 ) TABLE_TYPE;
1159
1160
1161 /*
1162 ** Maps for XULRunner client and web clients
1163 */
1164
1165 CREATE TABLE web_maps
1166 (
1167 id integer not null,
1168 title varchar(63) not null,
1169 properties SQL_TEXT not null,
1170 data SQL_TEXT not null,
1171 PRIMARY KEY(id)
1172 ) TABLE_TYPE;
1173