connect ssdb;

create table system(
	rec_key int auto_increment primary key,	
	sys_id char(16) not null,
	sys_type int null,
	sys_serial varchar(16) not null,
	hostname varchar(64) not null,
	ip_addr char(16) not null,
	active smallint not null,
	local smallint null,
	time int unsigned null);

create table archive_list(
	arc_id int auto_increment primary key,
	dbname varchar(32),
	startdate char(12),	
	enddate char(12));

create table sss_config(
	mode integer,
	status integer,
	max_subscriptions integer,
	curr_subscriptions integer);

create table event(
	sys_id char(16) not null,
	event_id integer auto_increment primary key,
	class_id int not null,
	type_id int not null,
	event_count int not null,
	event_start bigint not null,
	event_end bigint not null,
	event_time bigint,
	event_action smallint not null);

create table event_class(
	sys_id char(16) not null,
	class_id integer not null,
	class_desc varchar(128) not null);

create table event_type(
	sys_id char(16) not null,
	type_id int not null,
	class_id int not null,
	type_desc varchar(128) not null,
	throttled int not null,
	sehthrottle int unsigned not null,
	sehfrequency int unsigned not null,
	priority int not null,
	enabled int not null);

create table event_action(
	sys_id char(16) not null,
	action_id int auto_increment primary key,
	forward_hostname varchar(64) null,
	dsmthrottle int unsigned not null,
	dsmfrequency int unsigned not null,
	action varchar(255),
	retrycount int not null,
	timeoutval int not null,
	userstring varchar(32) not null,
	action_desc varchar(80) not null,
	private int not null,
	dsmdso int not null);

create table event_actionref(
	sys_id char(16) not null,
	ref_id int auto_increment primary key,
	class_id int not null,
	type_id int not null,
	action_id int not null);

create table actions_taken(
	sys_id char(16) not null,
	event_id int not null,
	action_taken_id int auto_increment primary key,
	action_id integer not null,
	action_time bigint not null,
	action_args varchar(255));

create table system_data(
	sys_id char(16) not null,
	sysdata_id int auto_increment primary key,
	event_id int not null,
	msg_string varchar(255));

create table test_data(
	sys_id char(16) not null,
	data_id int auto_increment primary key,
	event_id int not null,
	test_name varchar(128) not null,
	test_flag char not null);	

create table availdata(
	sys_id char(16) not null,
	avail_id int auto_increment primary key,
	event_id int not null,    
	event_time bigint null,
	lasttick bigint null,	
	prev_start bigint null,  
	start bigint null,  
	status_int int null,
	bounds int null,
	diag_type varchar(16) null,
	diag_file varchar(128) null,
	syslog varchar(128) null,
	hinvchange smallint null,
	verchange smallint null,
	metrics smallint null,
	flag smallint null,
	shutdowncomment varchar(80) null,
	summary varchar(255));

create table ssrv_ipaddr(
	ipaddrstr varchar(36) not null,
	enabled int not null);

create table tool(
	tool_name varchar(32) not null,
        tool_option varchar(64) null,
        option_default varchar(255));

create table key_table(
	keyname varchar(128) not null,
	subkeyname varchar(255),
	value varchar(255),
	subvalue varchar(255));

create table sss_auth(
        auth_host varchar(128) not null,
        auth_user varchar(36), 
        auth_key  varchar(16) not null,
        auth_mask varchar(16) not null,
        auth_pwd  varchar(32) not null,
        auth_encr int);

create index sys_id on system(sys_id);
create index class_id on event_class (class_id, sys_id);
create index type_id on event_type (type_id,sys_id);
create index action_id on actions_taken (action_id,sys_id,event_id);
create index action_id on event_action(action_id);
