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