libtblog.sql 3.34 KB
Newer Older
Kevin Atkinson's avatar
Kevin Atkinson committed
1
2
3
4
5
6
7
8
9
10
11
12
-- MYSQL TABLES used for logging subsystem

CREATE TABLE log (
  seq int unsigned NOT NULL auto_increment,
  stamp int unsigned NOT NULL,
  pidx int NOT NULL,             -- unique project id
  uid  int default NULL,         -- numeric user id
  session int unsigned NOT NULL, -- session id (1)
  invocation int unsigned NOT NULL, -- invocation id - unique id for a 
                                 --   particular execution of a script (1)
  parent int unsigned NOT NULL,  -- invocation id of the parent script
  script smallint(3) NOT NULL,   -- numeric id for the script name
Kevin Atkinson's avatar
   
Kevin Atkinson committed
13
14
  level tinyint(2) NOT NULL   ,  -- depth of the script in the call chain
  sublevel tinyint(2) NOT NULL,  -- sub level
Kevin Atkinson's avatar
Kevin Atkinson committed
15
16
17
18
19
20
21
22
  priority smallint(3) NOT NULL, -- syslog priority
  inferred tinyint(1) NOT NULL,  -- 0 - log created with tblog
                                 -- 1 - log created by catching a die or warn
				 -- 2 - log created with a normal print and
                                 --     given the non-default priority
                                 -- 3 - log created with a normal print and
                                 --     given the default priority
  cause varchar(32) NOT NULL,    -- string identifying the "cause" of the error
Kevin Atkinson's avatar
   
Kevin Atkinson committed
23
  type enum('normal','entering','exiting','thecause','extra','summary') 
Kevin Atkinson's avatar
Kevin Atkinson committed
24
25
26
27
28
       NOT NULL default 'normal',-- type of error:
                                 -- normal: normal error generated by tblog
                                 -- entering: auto gen when a script starts
				 -- exiting:  auto gen when a script exists (2)
                                 -- thecause: created by tblog_find_error
Kevin Atkinson's avatar
   
Kevin Atkinson committed
29
30
31
32
				 -- extra: extra information to normal info
				 --   at a lower level
				 -- summary: useful summary of errors,
				 --   ignore all info at lower levels
Kevin Atkinson's avatar
Kevin Atkinson committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  relevant tinyint(1) NOT NULL,  -- if the error was considered relevent
                                 -- by tblog_find_error
  mesg text NOT NULL,            -- the text of the message
  PRIMARY KEY (seq),
  KEY (session)
);

-- (1) These ids are equal to the sequence number of the "entering" log
--     message
-- (2) Due to a number of factors every "exiting" message in not 
--     garanteed to have a 1-1 relation with the "entering" message.
--     The two major ones are
--     (1) A Fork not followed by a "exec" will most likely to cause
--     multiple exiting messages.  (2) If "exec" is used the script
--     will not have an exiting message.

-- NOTE: It may be beneficial to split this table into three:
--   session pidx uid
--   invocation session parent script level 
--   seq stamp [session] invocation priority inferred cause type relevant mesg
-- ...

CREATE TABLE scripts (
  script smallint(3) NOT NULL auto_increment,
Kevin Atkinson's avatar
   
Kevin Atkinson committed
57
  script_name varchar(24) NOT NULL default '',
Kevin Atkinson's avatar
Kevin Atkinson committed
58
59
60
61
62
63
  PRIMARY KEY  (script),
  UNIQUE KEY id (name)
);

CREATE TABLE priorities (
  priority smallint(3) NOT NULL,
Kevin Atkinson's avatar
   
Kevin Atkinson committed
64
  priority_name varchar(8) NOT NULL,
Kevin Atkinson's avatar
Kevin Atkinson committed
65
66
67
68
  primary key (priority),
  unique key (name)
);

Leigh B. Stoller's avatar
Leigh B. Stoller committed
69
70
71
72
73
74
75
76
replace into priorities values (000, 'EMERG');
replace into priorities values (100, 'ALERT');
replace into priorities values (200, 'CRIT');
replace into priorities values (300, 'ERR');
replace into priorities values (400, 'WARNING');
replace into priorities values (500, 'NOTICE');
replace into priorities values (600, 'INFO');
replace into priorities values (700, 'DEBUG');
Kevin Atkinson's avatar
   
Kevin Atkinson committed
77

Leigh B. Stoller's avatar
Leigh B. Stoller committed
78
replace into exported_tables values ('state_timeouts');