source: ccsd/trunk/dbschema/ccs_graphs.schema @ 1269

Last change on this file since 1269 was 1269, checked in by ckb6, 6 years ago

This commit contains the ccsd side of minipulating snmp instructions and snmp state. This is used as a link between ccsd and the polling system (rrdbot-script)

  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1--
2-- PostgreSQL create schema for CRCnet Configuration Systems billing module
3--
4-- All prices in these tables should be sales tax exclusive
5--
6-- Author:  Chris Browning <ckb6@cs.waikato.ac.nz>
7--          Matt Brown  <matt@crc.net.nz>
8-- Version:  $Id$
9--
10
11
12CREATE TABLE rrdbot_class (
13    class_id    SERIAL          PRIMARY KEY,
14    class_name  varchar(64)     UNIQUE NOT NULL,
15    poll        varchar(64),
16    interval    integer,
17    cf          varchar(8),
18    archive     varchar(256),
19    depends     integer         DEFAULT 0
20);
21
22CREATE TABLE rrdbot_class_parts (
23    part_id     SERIAL          PRIMARY KEY,
24    class_id    integer,
25    name        varchar(64),
26    poll        varchar(64),
27    type        varchar(64),
28    min         integer         DEFAULT NULL,
29    max         integer         DEFAULT NULL
30);
31
32-- Graph classes that we know about
33CREATE TABLE graph_group (
34    group_id        SERIAL          PRIMARY KEY,
35    group_name      varchar(64)
36);
37
38-- Graphs that we know about
39CREATE TABLE graph_type (
40    graph_id        SERIAL          PRIMARY KEY,
41    group_id        integer NOT NULL REFERENCES graph_group (group_id) ON DELETE CASCADE,
42    class_id        integer NOT NULL REFERENCES rrdbot_class (class_id) ON DELETE CASCADE,
43    title           varchar(64),
44    filename        varchar(64),
45    virtical_label  varchar(64)
46);
47
48
49-- All the graph parts, relate to a graph by graph_id
50-- ie, LINE, AREA etc
51CREATE TABLE graph_parts (
52    part_id         SERIAL      PRIMARY KEY,
53    graph_id        integer NOT NULL REFERENCES graph_type (graph_id) ON DELETE CASCADE,
54    graph_order     integer,
55    type            varchar(10),
56    colour          varchar(20),
57    text            varchar(64),
58    varname         varchar(64),
59    cf              varchar(8),
60    filename        varchar(128)
61);
62
63
64
65CREATE TABLE graph_time ( 
66    time_id SERIAL PRIMARY KEY,
67    start_time varchar(10),
68    end_time varchar(10),
69    name varchar(20) NOT NULL
70);
71
72-- rrdbot-script discoveries
73CREATE TABLE snmp_discovery (
74    host_id       integer   NOT NULL REFERENCES host (host_id) ON DELETE CASCADE,
75    --name of class found
76    class_id      integer   NOT NULL REFERENCES rrdbot_class (class_id) ON DELETE CASCADE,
77    num           varchar(8)   NOT NULL,
78    ip_address    varchar(20),
79    link_id       integer,
80    --Time of last discovery of this class
81    timestamp       timestamp with time zone NOT NULL DEFAULT NOW()
82);
83CREATE TABLE snmp_instructions (
84    host_id      integer   NOT NULL REFERENCES host (host_id) ON DELETE CASCADE,
85    instr       integer,
86    param1      varchar(64),
87    param2      varchar(64),
88    param3      varchar(64)
89);
90
91CREATE TABLE snmp_state (
92    state      integer   NOT NULL
93);
94
95CREATE VIEW graphview as SELECT a.title, a.group_id, f.group_name, b.link_id, b.ip_address, b.num, a.graph_id, d.host_name, d.host_id, e.description from graph_type a, snmp_discovery b LEFT JOIN link e ON e.link_id=b.link_id, rrdbot_class c, host d, graph_group f WHERE c.class_id=b.class_id AND a.class_id = c.class_id AND d.host_id=b.host_id AND f.group_id=a.group_id;
96
97CREATE VIEW mirrortmp as select a.*, b.host_id as host_id2, b.link_id as link_id2, b.host_name as host_name2, b.graph_id as graph_id2, b.ip_address as ip_address2, b.num as num2 from graphview a, graphview b where  b.host_id!=a.host_id AND b.link_id=a.link_id AND b.graph_id=a.graph_id AND a.link_id!=0;
98
99CREATE VIEW mirrorview as SELECT a.*, b.host_id2, b.host_name2, b.ip_address2, b.num2 from graphview a LEFT JOIN mirrortmp b on a.host_id=b.host_id AND a.link_id=b.link_id AND a.graph_id=b.graph_id;
100
101create view rrdbotlog as select a.host_id, a.class_id, c.class_name, b.host_name, a.num, a.ip_address, a.timestamp, a.link_id, d.description from snmp_discovery a LEFT JOIN link d on a.link_id=d.link_id, host b, rrdbot_class c where b.host_id=a.host_id and c.class_id=a.class_id;
102-- vim: ft=sql
Note: See TracBrowser for help on using the repository browser.