PageRenderTime 80ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/opennms-base-assembly/src/main/filtered/etc/create.sql

https://github.com/ajakubo1/opennms
SQL | 2660 lines | 1209 code | 254 blank | 1197 comment | 1 complexity | 0a52967f0296d9fe4e220b03a6606906 MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0
  1. --# create.sql -- SQL to build the initial tables for the OpenNMS Project
  2. --#
  3. --# Modifications:
  4. --# 2013 Nov 15: Added protocol field in datalinkinterface table
  5. --# 2009 Sep 29: Added linkTypeId field in datalinkinterface table
  6. --# 2009 Mar 27: Added Users, Groups tables
  7. --# 2009 Jan 28: Added Acks tables - david@opennms.org
  8. --# 2007 Apr 10: Added statistics report tables - dj@opennms.org
  9. --# 2006 Apr 17: Added pathOutage table
  10. --# 2005 Mar 11: Added alarms table
  11. --# 2004 Aug 30: See create.sql.changes
  12. --#
  13. --# Copyright (C) 2005-2006 The OpenNMS Group, Inc., Inc. All rights reserved.
  14. --# Parts Copyright (C) 1999-2001 Oculan Corp. All rights reserved.
  15. --#
  16. --# This program is free software; you can redistribute it and/or modify
  17. --# it under the terms of the GNU General Public License as published by
  18. --# the Free Software Foundation; either version 2 of the License, or
  19. --# (at your option) any later version.
  20. --#
  21. --# This program is distributed in the hope that it will be useful,
  22. --# but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. --# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. --# GNU General Public License for more details.
  25. --#
  26. --# You should have received a copy of the GNU General Public License
  27. --# along with this program; if not, write to the Free Software
  28. --# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  29. --#
  30. --# For more information contact:
  31. --# OpenNMS Licensing <license@opennms.org>
  32. --# http://www.opennms.org/
  33. --# http://www.sortova.com/
  34. --#
  35. drop table accessLocks cascade;
  36. drop table accesspoints cascade;
  37. drop table category_node cascade;
  38. drop table categories cascade;
  39. drop table assets cascade;
  40. drop table usersNotified cascade;
  41. drop table notifications cascade;
  42. drop table outages cascade;
  43. drop table ifServices cascade;
  44. drop table snmpInterface cascade;
  45. drop table ipInterface cascade;
  46. drop table alarms cascade;
  47. drop table memos cascade;
  48. drop table node cascade;
  49. drop table service cascade;
  50. drop table distPoller cascade;
  51. drop table events cascade;
  52. drop table vulnerabilities cascade;
  53. drop table vulnPlugins cascade;
  54. drop table serverMap cascade;
  55. drop table serviceMap cascade;
  56. drop table pathOutage cascade;
  57. drop table demandPolls cascade;
  58. drop table pollResults cascade;
  59. drop table reportLocator cascade;
  60. drop table atinterface cascade;
  61. drop table stpnode cascade;
  62. drop table stpinterface cascade;
  63. drop table iprouteinterface cascade;
  64. drop table datalinkinterface cascade;
  65. drop table inventory cascade;
  66. drop table element cascade;
  67. drop table map cascade;
  68. drop table location_monitors cascade;
  69. drop table location_specific_status_changes cascade;
  70. drop table vlan cascade;
  71. drop table statisticsReportData cascade;
  72. drop table resourceReference cascade;
  73. drop table statisticsReport cascade;
  74. drop table acks cascade;
  75. drop table users cascade;
  76. drop table groups cascade;
  77. drop table group_user cascade;
  78. drop table category_user cascade;
  79. drop table category_group cascade;
  80. drop table filterfavorites cascade;
  81. drop sequence catNxtId;
  82. drop sequence nodeNxtId;
  83. drop sequence serviceNxtId;
  84. drop sequence eventsNxtId;
  85. drop sequence alarmsNxtId;
  86. drop sequence memoNxtId;
  87. drop sequence outageNxtId;
  88. drop sequence notifyNxtId;
  89. drop sequence userNotifNxtId;
  90. drop sequence demandPollNxtId;
  91. drop sequence pollResultNxtId;
  92. drop sequence vulnNxtId;
  93. drop sequence reportNxtId;
  94. drop sequence reportCatalogNxtId;
  95. drop sequence mapNxtId;
  96. drop sequence opennmsNxtId; --# should be used for all sequences, eventually
  97. drop sequence filternextid;
  98. drop index filternamesidx;
  99. --# Begin quartz persistence
  100. drop table qrtz_job_listeners;
  101. drop table qrtz_trigger_listeners;
  102. drop table qrtz_fired_triggers;
  103. drop table qrtz_paused_trigger_grps;
  104. drop table qrtz_scheduler_state;
  105. drop table qrtz_locks;
  106. drop table qrtz_simple_triggers;
  107. drop table qrtz_cron_triggers;
  108. drop table qrtz_blob_triggers;
  109. drop table qrtz_triggers;
  110. drop table qrtz_job_details;
  111. drop table qrtz_calendars;
  112. --# End quartz persistence
  113. CREATE FUNCTION plpgsql_call_handler ()
  114. RETURNS OPAQUE AS '$libdir/plpgsql.so' LANGUAGE 'c';
  115. CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql'
  116. HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL';
  117. --##################################################################
  118. --# The following commands set up automatic sequencing functionality
  119. --# for fields which require this.
  120. --#
  121. --# DO NOT forget to add an "install" comment so that the installer
  122. --# knows to fix and renumber the sequences if need be
  123. --##################################################################
  124. --# Sequence for the nodeID column in the aggregate_status_views and the
  125. --# aggregate_status_definitions tables (eventually all tables, perhaps)
  126. --# sequence, column, table
  127. --# install: opennmsNxtId id aggregate_status_views
  128. create sequence opennmsNxtId minvalue 1;
  129. --# Sequence for the nodeID column in the node table
  130. --# sequence, column, table
  131. --# install: nodeNxtId nodeID node
  132. create sequence nodeNxtId minvalue 1;
  133. --# Sequence for the serviceID column in the service table
  134. --# sequence, column, table
  135. --# install: serviceNxtId serviceID service
  136. create sequence serviceNxtId minvalue 1;
  137. --# Sequence for the eventID column in the events table
  138. --# sequence, column, table
  139. --# install: eventsNxtId eventID events
  140. create sequence eventsNxtId minvalue 1;
  141. --# Sequence for the alarmId column in the alarms table
  142. --# sequence, column, table
  143. --# install: alarmsNxtId alarmId alarms
  144. create sequence alarmsNxtId minvalue 1;
  145. --# Sequence for the id column in the memos table
  146. --# sequence, column, table
  147. --# install: memoNxtId id memos
  148. create sequence memoNxtId minvalue 1;
  149. --# Sequence for the outageID column in the outages table
  150. --# sequence, column, table
  151. --# install: outageNxtId outageID outages
  152. create sequence outageNxtId minvalue 1;
  153. --# Sequence for the notifyID column in the notification table
  154. --# sequence, column, table
  155. --# install: notifyNxtId notifyID notifications
  156. create sequence notifyNxtId minvalue 1;
  157. --# Sequence for the vulnerabilityID column in the vulnerabilities table
  158. --# sequence, column, table
  159. --# install: vulnNxtId vulnerabilityID vulnerabilities
  160. create sequence vulnNxtId minvalue 1;
  161. --# Sequence for the id column in the categories table
  162. --# sequence, column, table
  163. --# install: catNxtId categoryid categories
  164. create sequence catNxtId minvalue 1;
  165. --# Sequence for the id column in the usersNotified table
  166. --# sequence, column, table
  167. --# install: userNotifNxtId id usersNotified
  168. create sequence userNotifNxtId minvalue 1;
  169. --# Sequence for the id column in the demandPolls table
  170. --# sequence, column, table
  171. --# install: demandPollNxtId id demandPolls
  172. create sequence demandPollNxtId minvalue 1;
  173. --# Sequence for the id column in the pollResults table
  174. --# sequence, column, table
  175. --# install: pollResultNxtId id pollResults
  176. create sequence pollResultNxtId minvalue 1;
  177. --# Sequence for the mapID column in the map table
  178. --# sequence, column, table
  179. --# install: mapNxtId mapid map
  180. create sequence mapNxtId minvalue 1;
  181. --# Sequence for the filterid column in the filterfavorites table
  182. --# sequence, column, table
  183. --# install: filternextid filterid filterfavorites
  184. create sequence filternextid minvalue 1;
  185. --# A table to use to manage upsert access
  186. CREATE TABLE accessLocks (
  187. lockName varchar(40) not null,
  188. constraint pk_accessLocks PRIMARY KEY (lockName)
  189. );
  190. --#
  191. --########################################################################
  192. --# serverMap table - Contains a list of IP Addresses mapped to
  193. --# OpenNMS servers
  194. --#
  195. --# This table contains the following fields:
  196. --#
  197. --# ipAddr : IP address of the device to be monitored
  198. --# serverName : Text field to store the server name
  199. --#
  200. --########################################################################
  201. create table serverMap (
  202. ipAddr text not null,
  203. serverName varchar(64) not null );
  204. create index server_name_idx on serverMap(serverName);
  205. --########################################################################
  206. --# serviceMap table - Contains a list of IP Addresses mapped to
  207. --# OpenNMS services
  208. --#
  209. --# This table contains the following fields:
  210. --#
  211. --# ipAddr : IP address of the device to be monitored
  212. --# serviceName : Text field to store the service name
  213. --#
  214. --########################################################################
  215. create table serviceMap (
  216. ipAddr text not null,
  217. serviceMapName varchar(255) not null
  218. );
  219. create index servicemap_name_idx on serviceMap(serviceMapName);
  220. create index serviceMap_ipaddr_idx on serviceMap(ipAddr);
  221. --########################################################################
  222. --# distPoller table - Contains information on Distributed Pollers
  223. --# installed in this OpenNMS instance.
  224. --#
  225. --# This table contains the following fields:
  226. --#
  227. --# dpName : A human-readable name for each system. Typically,
  228. --# the system's hostname (not fully qualified).
  229. --# dpIP : IP address of the distributed poller.
  230. --# dpComment : Free-form text field
  231. --# dpDiscLimit : Numeric representation of percentage of interface speed
  232. --# available to discovery process. See documentation for
  233. --# "bandwidth troll"
  234. --# dpLastNodePull : Time of last pull of new nodes from the DP
  235. --# dpLastEventPull : Time of last pull of events from the DP
  236. --# dpLastPackagePush : Time of last push of Package (config) to the DP
  237. --# dpAdminState: Reflects desired state for this distributed poller.
  238. --# 1 = Up, 0 = Down
  239. --# dpRunState : Reflects the current perceived state of the distributed
  240. --# poller. 1 = Up, 0 = Down
  241. --#
  242. --########################################################################
  243. create table distPoller (
  244. dpName varchar(12) not null,
  245. dpIP text not null,
  246. dpComment varchar(256),
  247. dpDiscLimit numeric(5,2),
  248. dpLastNodePull timestamp with time zone,
  249. dpLastEventPull timestamp with time zone,
  250. dpLastPackagePush timestamp with time zone,
  251. dpAdminState integer,
  252. dpRunState integer,
  253. constraint pk_dpName primary key (dpName)
  254. );
  255. --########################################################################
  256. --# node Table - Contains information on nodes discovered and potentially
  257. --# managed by OpenNMS. nodeSys* fields map to SNMP MIB 2
  258. --# system table information.
  259. --#
  260. --# This table contains the following fields:
  261. --#
  262. --# nodeID : Unique identifier for node. Note that this is the
  263. --# enabler for overlapping IP ranges and that uniquity
  264. --# is dependent on combination of dpName & IP address
  265. --# dpName : Distributed Poller responsible for this node
  266. --# nodeCreateTime : Time node was added to the database
  267. --# nodeParentID : In the case that the node is virtual or an independent
  268. --# device in a chassis that should be reflected as a
  269. --# subcomponent or "child", this field reflects the nodeID
  270. --# of the chassis/physical node/"parent" device.
  271. --# Currently unused.
  272. --# nodeType : Flag indicating status of node
  273. --# 'A' - active
  274. --# 'D' - deleted
  275. --# nodeSysOID : SNMP MIB-2 system.sysObjectID.0
  276. --# nodeSysName : SNMP MIB-2 system.sysName.0
  277. --# nodeSysDescription : SNMP MIB-2 system.sysDescr.0
  278. --# nodeSysLocation : SNMP MIB-2 system.sysLocation.0
  279. --# nodeSysContact : SNMP MIB-2 system.sysContact.0
  280. --# nodeLabel : User-friendly name associated with the node.
  281. --# nodeLabelSource : Flag indicating source of nodeLabel
  282. --# 'U' = user defined
  283. --# 'H' = IP hostname
  284. --# 'S' = sysName
  285. --# 'A' = IP address
  286. --# nodeNetBIOSName : NetBIOS workstation name associated with the node.
  287. --# nodeDomainName : NetBIOS damain name associated with the node.
  288. --# operatingSystem : Operating system running on the node.
  289. --# lastCapsdPoll : Date and time of last Capsd scan.
  290. --# foreignSource : When importing nodes this contains the source of the
  291. --# nodes, null otherwise
  292. --# foriegnId : When importing nodes this contains the id of the node
  293. --# as known to the foriegn source, null otherwise
  294. --########################################################################
  295. create table node (
  296. nodeID integer not null,
  297. dpName varchar(12),
  298. nodeCreateTime timestamp with time zone not null,
  299. nodeParentID integer,
  300. nodeType char(1),
  301. nodeSysOID varchar(256),
  302. nodeSysName varchar(256),
  303. nodeSysDescription varchar(256),
  304. nodeSysLocation varchar(256),
  305. nodeSysContact varchar(256),
  306. nodeLabel varchar(256),
  307. nodeLabelSource char(1),
  308. nodeNetBIOSName varchar(16),
  309. nodeDomainName varchar(16),
  310. operatingSystem varchar(64),
  311. lastCapsdPoll timestamp with time zone,
  312. foreignSource varchar(64),
  313. foreignId varchar(64),
  314. constraint pk_nodeID primary key (nodeID),
  315. constraint fk_dpName foreign key (dpName) references distPoller
  316. );
  317. create index node_id_type_idx on node(nodeID, nodeType);
  318. create index node_label_idx on node(nodeLabel);
  319. create index node_dpname_idx on node(dpName);
  320. create unique index node_foreign_unique_idx on node(foreignSource, foreignId);
  321. --#########################################################################
  322. --# snmpInterface Table - Augments the ipInterface table with information
  323. --# available from IP interfaces which also support
  324. --# SNMP.
  325. --#
  326. --# This table provides the following information:
  327. --#
  328. --# nodeID : Unique identifier for node to which this if belongs
  329. --# snmpIpAdEntNetMask : SNMP MIB-2 ipAddrTable.ipAddrEntry.ipAdEntNetMask
  330. --# Value is interface's subnet mask
  331. --# snmpPhysAddr : SNMP MIB-2 ifTable.ifEntry.ifPhysAddress
  332. --# Value is interface's MAC Address
  333. --# snmpIfIndex : SNMP MIB-2 ifTable.ifEntry.ifIndex
  334. --# Value is interface's arbitrarily assigned index,
  335. --# or -100 if we can query the agent, but we can't find
  336. --# this IP address in the ifTable.
  337. --# snmpIfDescr : SNMP MIB-2 ifTable.ifEntry.ifDescr
  338. --# Value is interface's manufacturer/product name/version
  339. --# snmpIfType : SNMP MIB-2 ifTable.ifEntry.ifType
  340. --# Value is interface's physical/link protocol
  341. --# snmpIfName : SNMP MIB-2 ifTable.ifEntry.ifName
  342. --# Value is interface's device name
  343. --# snmpIfSpeed : SNMP MIB-2 ifTable.ifEntry.ifSpeed
  344. --# Value is estimate of interface's data rate
  345. --# snmpIfAdminStatus : SNMP MIB-2 ifTable.ifEntry.ifAdminStatus
  346. --# Value is interface's desired status
  347. --# 1 = Up, 2 = Down, 3 = Testing
  348. --# snmpIfOperStatus : SNMP MIB-2 ifTable.ifEntry.ifOperStatus
  349. --# Value is interface's current operational status
  350. --# 1 = Up, 2 = Down, 3 = Testing
  351. --# snmpIfAlias : SNMP MIB-2 ifXTable.ifXEntry.ifAlias
  352. --# Value is interface's device alias
  353. --# snmpCollect : 'C' means collect 'N' means don't collect
  354. --# : 'UC' means collect 'UN' means don't collect (user override)
  355. --# This has been moved from the isSnmpPrimary field in the
  356. --# ipinterface table
  357. --# snmpLastCapsdPoll : Date and time of last poll by capsd or provisiond
  358. --# snmpPoll : 'P' means polled 'N' means not polled (interface admin and oper status)
  359. --# snmpLastSnmpPoll : Date and time of last snmp poll
  360. --#
  361. --# NOTE: Although not marked as "not null" the snmpIfIndex field
  362. --# should never be null. This table is considered to be uniquely
  363. --# keyed by nodeId and snmpIfIndex. Eventually ipAddr and
  364. --# snmpIpAdEntNetMask will be removed and netmask added to
  365. --# the ipInterface table.
  366. --########################################################################
  367. create table snmpInterface (
  368. id INTEGER DEFAULT nextval('opennmsNxtId') NOT NULL,
  369. nodeID integer not null,
  370. snmpIpAdEntNetMask varchar(45),
  371. snmpPhysAddr varchar(32),
  372. snmpIfIndex integer not null,
  373. snmpIfDescr varchar(256),
  374. snmpIfType integer,
  375. snmpIfName varchar(96),
  376. snmpIfSpeed bigint,
  377. snmpIfAdminStatus integer,
  378. snmpIfOperStatus integer,
  379. snmpIfAlias varchar(256),
  380. snmpLastCapsdPoll timestamp with time zone,
  381. snmpCollect varchar(2) default 'N',
  382. snmpPoll varchar(1) default 'N',
  383. snmpLastSnmpPoll timestamp with time zone,
  384. CONSTRAINT snmpinterface_pkey primary key (id),
  385. constraint fk_nodeID2 foreign key (nodeID) references node ON DELETE CASCADE
  386. );
  387. create unique index snmpinterface_nodeid_ifindex_unique_idx on snmpinterface(nodeID, snmpIfIndex);
  388. create index snmpinterface_nodeid_idx on snmpinterface(nodeID);
  389. --########################################################################
  390. --# ipInterface Table - Contains information on interfaces which support
  391. --# TCP/IP as well as current status information.
  392. --# ipAddr is integer, to support easier filtering.
  393. --#
  394. --# This table contains the following information:
  395. --#
  396. --# nodeID : Unique identifier of the node that "owns" this interface
  397. --# ipAddr : IP Address associated with this interface
  398. --# ifIndex : SNMP index of interface, used to uniquely identify
  399. --# unnumbered interfaces, or null if there is no mapping to
  400. --# snmpInterface table. Can be -100 if old code added an
  401. --# snmpInterface table entry but no SNMP data could be gathered.
  402. --#
  403. --# NOTE: The combination of nodeID, ipAddr, and ifIndex must be unique,
  404. --# and this must be enforced programmatically.
  405. --#
  406. --# ipHostname : IP Hostname associated with this interface
  407. --# isManaged : Character used as a boolean flag
  408. --# 'M' - Managed
  409. --# 'A' - Alias
  410. --# 'D' - Deleted
  411. --# 'U' - Unmanaged
  412. --# 'F' - Forced Unmanaged (via the user interface)
  413. --# 'N' - Not polled as part of any package
  414. --# 'X' - Remotely Monitored only
  415. --# ipStatus : If interface supports SNMP this field will
  416. --# hold a numeric representation of interface's
  417. --# operational status (same as 'snmpIfOperStatus'
  418. --# field in the snmpInterface table).
  419. --# 1 = Up, 2 = Down, 3 = Testing
  420. --# ipLastCapsdPoll : Date and time of last poll by capsd or provisiond
  421. --# isSnmpPrimary : Character used as a boolean flag
  422. --# 'P' - Primary SNMP
  423. --# 'S' - Secondary SNMP
  424. --# 'N' - Not eligible (does not support SNMP or
  425. --# or has no ifIndex)
  426. --# NOTE: 'C' is no longer a valid value for isSnmpPrimary
  427. --# this has moved to the snmpinterface table
  428. --#
  429. --########################################################################
  430. create table ipInterface (
  431. id INTEGER DEFAULT nextval('opennmsNxtId') NOT NULL,
  432. nodeID integer not null,
  433. ipAddr text not null,
  434. ifIndex integer,
  435. ipHostname varchar(256),
  436. isManaged char(1),
  437. ipStatus integer,
  438. ipLastCapsdPoll timestamp with time zone,
  439. isSnmpPrimary char(1),
  440. snmpInterfaceId integer,
  441. CONSTRAINT ipinterface_pkey PRIMARY KEY (id),
  442. CONSTRAINT snmpinterface_fkey2 FOREIGN KEY (snmpInterfaceId) REFERENCES snmpInterface (id) ON DELETE SET NULL,
  443. constraint fk_nodeID1 foreign key (nodeID) references node ON DELETE CASCADE
  444. );
  445. create unique index ipinterface_nodeid_ipaddr_notzero_idx on ipInterface (nodeID, ipAddr) WHERE ipAddr != '0.0.0.0';
  446. create index ipinterface_nodeid_ipaddr_ismanaged_idx on ipInterface (nodeID, ipAddr, isManaged);
  447. create index ipinterface_ipaddr_ismanaged_idx on ipInterface (ipAddr, isManaged);
  448. create index ipinterface_ipaddr_idx on ipInterface (ipAddr);
  449. create index ipinterface_nodeid_ismanaged_idx on ipInterface (ipAddr);
  450. create index ipinterface_nodeid_idx on ipInterface (nodeID);
  451. create index ipinterface_snmpInterfaceId_idx on ipInterface (snmpInterfaceId);
  452. --########################################################################
  453. --# service Table - Contains a name<->number mapping for services
  454. --# (e.g., poller packages)
  455. --#
  456. --# This table provides the following information:
  457. --#
  458. --# serviceID : Unique integer mapping to service/poller package
  459. --# serviceName : Name associated with service/poller package
  460. --########################################################################
  461. create table service (
  462. serviceID integer default nextval('serviceNxtId') not null,
  463. serviceName varchar(255) not null,
  464. constraint pk_serviceID primary key (serviceID)
  465. );
  466. create unique index service_servicename_key on service (serviceid);
  467. --########################################################################
  468. --# ifServices Table - Contains a mapping of interfaces to services available
  469. --# on those interfaces (e.g., FTP, SMTP, DNS, etc.) and
  470. --# recent polling status information.
  471. --#
  472. --# This table provides the following information:
  473. --#
  474. --# nodeID : Unique integer identifier for node
  475. --# ipAddr : IP Address of node's interface
  476. --# ifIndex : SNMP ifIndex, if available, null otherwise
  477. --# serviceID : Unique integer identifier of service/poller package
  478. --# lastGood : Date and time of last successful poll by this poller package
  479. --# lastFail : Date and time of last failed poll by this poller package
  480. --# qualifier : Service qualifier. May be used to distinguish two
  481. --# services which have the same serviceID. For example, in the
  482. --# case of the HTTP service a qualifier might be the specific
  483. --# port on which the HTTP server was found.
  484. --# status : Flag indicating the status of the service.
  485. --# 'A' - Active
  486. --# 'D' - Deleted
  487. --# 'U' - Unmanaged (per capsd configuration change and CAPSD)
  488. --# 'F' - Forced unmanaged (via user interface)
  489. --# 'N' - Not polled as part of any of the packages that the
  490. --# interface belongs to
  491. --# 'X' - service is remotely monitored only
  492. --# source : Flag indicating how the service was detected.
  493. --# 'P' - Plugin
  494. --# 'F' - Forced (via CapsdPluginBehavior.conf)
  495. --# notify : Flag indicating if this service should be notified on or not
  496. --# 'Y' - to notify
  497. --# 'N' = not to notify
  498. --########################################################################
  499. create table ifServices (
  500. id integer default nextval('opennmsNxtId') NOT NULL,
  501. nodeID integer not null,
  502. ipAddr text not null,
  503. ifIndex integer,
  504. serviceID integer not null,
  505. lastGood timestamp with time zone,
  506. lastFail timestamp with time zone,
  507. qualifier char(16),
  508. status char(1),
  509. source char(1),
  510. notify char(1),
  511. ipInterfaceId integer not null,
  512. CONSTRAINT ifservices_pkey PRIMARY KEY (id),
  513. CONSTRAINT ipinterface_fkey FOREIGN KEY (ipInterfaceId) REFERENCES ipInterface (id) ON DELETE CASCADE,
  514. constraint fk_nodeID3 foreign key (nodeID) references node ON DELETE CASCADE,
  515. constraint fk_serviceID1 foreign key (serviceID) references service ON DELETE CASCADE
  516. );
  517. create unique index ifservices_nodeid_ipaddr_svc_unique on ifservices(nodeID, ipAddr, serviceId);
  518. create index ifservices_nodeid_ipaddr_status on ifservices(nodeID, ipAddr, status);
  519. create index ifservices_nodeid_status on ifservices(nodeid, status);
  520. create index ifservices_nodeid_idx on ifservices(nodeID);
  521. create index ifservices_serviceid_idx on ifservices(serviceID);
  522. create index ifservices_nodeid_serviceid_idx on ifservices(nodeID, serviceID);
  523. create index ifservicves_ipInterfaceId_idx on ifservices(ipInterfaceId);
  524. --##################################################################
  525. --# events Table -- This table provides information on the events
  526. --# that are passed into the event subsystem. It
  527. --# contains information defining the event as
  528. --# unique, while additional information is stored
  529. --# in the eventsDetail table.
  530. --#
  531. --# This table provides the following information:
  532. --#
  533. --# eventID : Unique identifier for the event
  534. --# eventUei : Universal Event Identifer (UEI) for this event
  535. --# eventSnmp : Contains the eid, eidtext (optionally), specific,
  536. --# and generic identifier for the SNMP Trap. This
  537. --# maps directly to the <snmp> element in the
  538. --# Event Data Stream DTD.
  539. --# eventTime : The <time> element from the Event Data Stream DTD,
  540. --# which is the time the event was received by the
  541. --# source process.
  542. --# eventCreateTime : Creation time of event in database
  543. --# eventHost : The <host> element from the Event Data Stream DTD
  544. --# eventSource : The entity/process which generated the event.
  545. --# eventSnmphost : The <snmphost> element from the Event Data Stream DTD
  546. --# eventDpName : The dpName of the Dist Poller which received the
  547. --# event
  548. --# eventParms : The <parms> element from the Event Data Stream DTD
  549. --# nodeID : Unique integer identifier for node
  550. --# ifindex : The <ifindex> element from the Event Data Stream DTD
  551. --# ipAddr : IP Address of node's interface
  552. --# serviceID : Unique integer identifier of service/poller package
  553. --# eventDescr : Free-form textual description of the event
  554. --# eventLogmsg : The log message for the event
  555. --# eventSeverity : Severity of event
  556. --# 1 = Indeterminate
  557. --# 2 = Cleared (implementation is now in alarms)
  558. --# 3 = Normal
  559. --# 4 = Warning
  560. --# 5 = Minor
  561. --# 6 = Major
  562. --# 7 = Critical
  563. --# eventPathOutage : Event Path outage information
  564. --# eventCorrelation : The event correlation configured for this event
  565. --# (stored as an XML string)
  566. --# eventSuppressedCount : The number of times the event was suppressed
  567. --# (if event correlation was set for suppression)
  568. --# eventOperInstruct : Operator instruction for event.
  569. --# eventAutoAction : Automated Action for event. Should
  570. --# consist of fully-qualfied pathname to
  571. --# executable command, with possible variables
  572. --# used to reference event-specific data
  573. --# eventOperAction : Operator Action for event. Should
  574. --# consist of fully-qualfied pathname to
  575. --# executable command, with possible variables
  576. --# used to reference event-specific data
  577. --# eventOperActionMenuText : Menu text displayed to Operator, which if
  578. --# selected, will invoke action described in
  579. --# eventOperAction
  580. --# eventLoggroup : Logical group with which to associate event.
  581. --# This field provides a means of logically
  582. --# grouping related events.
  583. --# eventNotification : Notification string. Should consist of
  584. --# a fully-qualfied pathname to an executable
  585. --# which invokes the notification software, and
  586. --# will likely contain event-specific variables
  587. --# eventTticket : Trouble ticket integration string. Should
  588. --# consist of fully-qualfied pathname to
  589. --# executable command, with possible variables
  590. --# used to reference event-specific data
  591. --# eventTticketState : Trouble ticket on/off boolean
  592. --# 1=on, 0=off
  593. --# eventForward : Contains a list of triplets:
  594. --# Destination,State,Mechanism;Destination,State,Mechanism;
  595. --# which reflect the following:
  596. --# - State is a boolean flag as to whether the
  597. --# entry is active or not. 1=on, 0=off.
  598. --# - Destination is hostname or IP of system to
  599. --# forward the event to
  600. --# - Method is the means by which it will be
  601. --# forwarded. A keyword, e.g., SNMP
  602. --# eventMouseOverText : Text to be displayed on MouseOver event, if
  603. --# the event is displayed in the browser and
  604. --# the operator needs additional info.
  605. --# eventLog : Flag indicating if the event is to be logged, set
  606. --# from the 'dest' attribute on the incoming event
  607. --# Y = log, N = do not log
  608. --# eventDisplay : Flag indicating if the event is to be displayed, set
  609. --# from the 'dest' attribute on the incoming event
  610. --# Y = display, N = do not display
  611. --# eventAckUser : The user who acknowledged this event. If
  612. --# null, then this event has not been acknowledged.
  613. --# eventAckTime : The time this event was acknowledged.
  614. --# alarmID : If this event is configured for alarmReduction, the alarmId
  615. --# of the reduced event will set in this column
  616. --#
  617. --##################################################################
  618. create table events (
  619. eventID integer not null,
  620. eventUei varchar(256) not null,
  621. nodeID integer,
  622. eventTime timestamp with time zone not null,
  623. eventHost varchar(256),
  624. eventSource varchar(128) not null,
  625. ipAddr text,
  626. eventDpName varchar(12) not null,
  627. eventSnmphost varchar(256),
  628. serviceID integer,
  629. eventSnmp varchar(256),
  630. eventParms text,
  631. eventCreateTime timestamp with time zone not null,
  632. eventDescr text,
  633. eventLoggroup varchar(32),
  634. eventLogmsg text,
  635. eventSeverity integer not null,
  636. eventPathOutage varchar(1024),
  637. eventCorrelation varchar(1024),
  638. eventSuppressedCount integer,
  639. eventOperInstruct varchar(1024),
  640. eventAutoAction varchar(256),
  641. eventOperAction varchar(256),
  642. eventOperActionMenuText varchar(64),
  643. eventNotification varchar(128),
  644. eventTticket varchar(128),
  645. eventTticketState integer,
  646. eventForward varchar(256),
  647. eventMouseOverText varchar(64),
  648. eventLog char(1) not null,
  649. eventDisplay char(1) not null,
  650. ifIndex integer,
  651. eventAckUser varchar(256),
  652. eventAckTime timestamp with time zone,
  653. alarmID integer,
  654. constraint pk_eventID primary key (eventID)
  655. );
  656. create index events_uei_idx on events(eventUei);
  657. create index events_nodeid_idx on events(nodeID);
  658. create index events_ipaddr_idx on events(ipaddr);
  659. create index events_serviceid_idx on events(serviceID);
  660. create index events_time_idx on events(eventTime);
  661. create index events_severity_idx on events(eventSeverity);
  662. create index events_log_idx on events(eventLog);
  663. create index events_display_idx on events(eventDisplay);
  664. create index events_ackuser_idx on events(eventAckUser);
  665. create index events_acktime_idx on events(eventAckTime);
  666. create index events_alarmid_idx on events(alarmID);
  667. create index events_nodeid_display_ackuser on events(nodeid, eventdisplay, eventackuser);
  668. --########################################################################
  669. --#
  670. --# outages table -- This table maintains a record of outage periods for
  671. --# given services on specific interfaces.
  672. --#
  673. --# This table provides the following information:
  674. --#
  675. --# outageID : Unique integer identifier for the outage
  676. --# svcLostEventID : ID of the event that caused the outage. Will be
  677. --# a non-null value when a new outage is inserted
  678. --# but might be null in case of an opennms upgrade
  679. --# svcRegainedEventID: ID of the event that cleared the outage
  680. --# nodeID : Unique integer identifier for node
  681. --# ipAddr : IP Address of node's interface
  682. --# serviceID : Unique integer identifier of service/poller package
  683. --# ifLostService : Time of lost service event
  684. --# ifRegainedService : Time of regained service event
  685. --# suppressTime : Time to suppress the outage
  686. --# suppressedBy : The suppressor
  687. --#
  688. --########################################################################
  689. create table outages (
  690. outageID integer not null,
  691. svcLostEventID integer,
  692. svcRegainedEventID integer,
  693. nodeID integer not null,
  694. ipAddr text not null,
  695. serviceID integer not null,
  696. ifLostService timestamp with time zone not null,
  697. ifRegainedService timestamp with time zone,
  698. suppressTime timestamp with time zone,
  699. suppressedBy varchar(256),
  700. ifServiceId INTEGER not null,
  701. constraint pk_outageID primary key (outageID),
  702. constraint fk_eventID1 foreign key (svcLostEventID) references events (eventID) ON DELETE CASCADE,
  703. constraint fk_eventID2 foreign key (svcRegainedEventID) references events (eventID) ON DELETE CASCADE,
  704. constraint fk_nodeID4 foreign key (nodeID) references node (nodeID) ON DELETE CASCADE,
  705. constraint fk_serviceID2 foreign key (serviceID) references service (serviceID) ON DELETE CASCADE,
  706. CONSTRAINT ifServices_fkey1 FOREIGN KEY (nodeId, ipAddr, serviceId) REFERENCES ifServices (nodeId, ipAddr, serviceId) ON DELETE CASCADE ON UPDATE CASCADE,
  707. CONSTRAINT ifServices_fkey2 FOREIGN KEY (ifServiceId) REFERENCES ifServices (id) ON DELETE CASCADE
  708. );
  709. create index outages_nodeid_ipaddr_svc_idx on outages(nodeID, ipAddr, serviceId);
  710. create index outages_svclostid_idx on outages(svcLostEventID);
  711. create index outages_svcregainedid_idx on outages(svcRegainedEventID);
  712. create index outages_nodeid_idx on outages(nodeID);
  713. create index outages_serviceid_idx on outages(serviceID);
  714. create index outages_ipaddr_idx on outages(ipaddr);
  715. create index outages_regainedservice_idx on outages(ifRegainedService);
  716. create index outages_ifServivceId_idx on outages(ifServiceId);
  717. --########################################################################
  718. --#
  719. --# vulnerabilities table -- This table maintains a record of vulnerabilites
  720. --# that have been detected on target IP addresses.
  721. --#
  722. --# This table provides the following information:
  723. --#
  724. --# vulnerabilityID : Unique integer identifier for the outage
  725. --# nodeID : Unique integer identifier for node
  726. --# ipAddr : IP Address of node's interface
  727. --# serviceID : Unique integer identifier of service/poller package
  728. --#
  729. --# creationTime : Initial creation time of the vulnerability
  730. --# lastAttemptTime : Last time that an attempt was made to scan for
  731. --# this vulnerability
  732. --# lastScanTime : Most recent successful scan time
  733. --# resolvedTime : Time after which the vulnerability was no longer
  734. --# detected
  735. --#
  736. --# severity : Severity of the vulnerability (identical to event
  737. --# severities
  738. --# pluginID : ID number of the plugin that produced the vulnerability
  739. --# pluginSubID : Specific vulnerability type generated by the plugin
  740. --# logmsg : Terse description of vulnerability (usually
  741. --# the plugin name plus short description)
  742. --# descr : Verbose description of vulnerability
  743. --# port : Port that the vulnerability affects
  744. --# protocol : Network protocol of the attack (TCP, UDP, ICMP)
  745. --#
  746. --########################################################################
  747. create table vulnerabilities (
  748. vulnerabilityID integer not null,
  749. nodeID integer,
  750. ipAddr text,
  751. serviceID integer,
  752. creationTime timestamp with time zone not null,
  753. lastAttemptTime timestamp with time zone not null,
  754. lastScanTime timestamp with time zone not null,
  755. resolvedTime timestamp with time zone,
  756. severity integer not null,
  757. pluginID integer not null,
  758. pluginSubID integer not null,
  759. logmsg text,
  760. descr text,
  761. port integer,
  762. protocol varchar(32),
  763. cveEntry varchar(255),
  764. constraint pk_vulnerabilityID primary key (vulnerabilityID)
  765. );
  766. create index vulnerabilities_nodeid_idx on vulnerabilities(nodeID);
  767. create index vulnerabilities_ipaddr_idx on vulnerabilities(ipAddr);
  768. create index vulnerabilities_severity_idx on vulnerabilities(severity);
  769. create index vulnerabilities_port_idx on vulnerabilities(port);
  770. create index vulnerabilities_protocol_idx on vulnerabilities(protocol);
  771. --########################################################################
  772. --#
  773. --# vulnPlugins table -- This table contains a list of information about
  774. --# Nessus plugins that are in use by the nessusd
  775. --# daemons that are being used by vulnscand.
  776. --#
  777. --# This table provides the following information:
  778. --#
  779. --# pluginID : Plugin ID number (from Nessus)
  780. --# pluginSubID : Specific vulnerability type within the plugin
  781. --# name : Short name of the plugin
  782. --# category : Category of the plugin's behavior (scanner,
  783. --# attack, etc)
  784. --# copyright : Copyright notice for the plugin
  785. --# descr : Verbose description of vulnerability
  786. --# summary : Short description of plugin behavior
  787. --# family : User-comprehensible type of attack (CGI abuses,
  788. --# Backdoors, etc)
  789. --# version : Version of the plugin code
  790. --# cveEntry : CVE entry associated with the vulnerability
  791. --# that this plugin tests
  792. --# md5 : 128-bit hex MD5 checksum of the plugin that
  793. --# can be used to detect changes in the plugin code
  794. --#
  795. --########################################################################
  796. create table vulnPlugins (
  797. pluginID integer not null,
  798. pluginSubID integer not null,
  799. name varchar(128),
  800. category varchar(32),
  801. copyright varchar(128),
  802. descr text,
  803. summary varchar(256),
  804. family varchar(32),
  805. version varchar(32),
  806. cveEntry varchar(255),
  807. md5 varchar(32)
  808. );
  809. --# This constraint not understood installer
  810. --# CONSTRAINT pk_vulnplugins PRIMARY KEY (pluginID,pluginSubID));
  811. --#
  812. create unique index vulnplugins_plugin_idx on vulnPlugins(pluginID, pluginSubID);
  813. --########################################################################
  814. --# notification table - Contains information on acknowleged and outstanding
  815. --# pages listed by user/groups
  816. --#
  817. --# This table contains the following fields:
  818. --#
  819. --# textMsg : The message being sent in the page.
  820. --# numericMsg : The message being sent to a numeric pager
  821. --# notifyID : The primary key of this row, populated with the value from
  822. --# the notifyNxtId sequence.
  823. --# pageTime : A timestamp of when the page was originally sent.
  824. --# respondTime : A timestamp of when the page was acknowleged. A null in this
  825. --# field means that the page has not been answered yet.
  826. --# answeredBy : The user id of the user that answered the page, set the same
  827. --# for all rows with the same groupId field.
  828. --# nodeId : The id of the node that has the problem
  829. --# interfaceId : The id of the interface on the node that has the problem
  830. --# serviceID : The id of the service on the interface that has the problem
  831. --# eventID : The primary key of the event that spawned the notification
  832. --# eventUEI : The uei of the event that spawned the notification, placed here
  833. --# for speed of lookup as notifications are processed.
  834. --#
  835. --########################################################################
  836. create table notifications (
  837. textMsg text not null,
  838. subject text,
  839. numericMsg varchar(256),
  840. notifyID integer not null,
  841. pageTime timestamp with time zone,
  842. respondTime timestamp with time zone,
  843. answeredBy varchar(256),
  844. nodeID integer,
  845. interfaceID varchar(16),
  846. serviceID integer,
  847. queueID varchar(256),
  848. eventID integer,
  849. eventUEI varchar(256) not null,
  850. notifConfigName varchar(63),
  851. constraint pk_notifyID primary key (notifyID),
  852. constraint fk_nodeID7 foreign key (nodeID) references node (nodeID) ON DELETE CASCADE,
  853. constraint fk_eventID3 foreign key (eventID) references events (eventID) ON DELETE CASCADE
  854. );
  855. create index notifications_nodeid_idx on notifications(nodeid);
  856. create index notifications_ipaddr_idx on notifications(interfaceID);
  857. create index notifications_serviceid_idx on notifications(serviceID);
  858. create index notifications_eventid_idx on notifications(eventID);
  859. create index notifications_respondtime_idx on notifications(respondTime);
  860. create index notifications_answeredby_idx on notifications(answeredBy);
  861. create index notifications_eventuei_idx on notifications (eventuei);
  862. --########################################################################
  863. --#
  864. --# This table contains the following fields:
  865. --# id : ID column for the table
  866. --# userID : The user id of the person being paged, from the users.xml
  867. --# file.
  868. --# notifyID : The index of the row from the notification table.
  869. --# notifyTime : The timestamp of when the notification was sent
  870. --# media : A string describing the type of contact being made, ie text
  871. --# page, numeric page, email, etc...
  872. --# contactInfo : A field for storing the information used to contact the user,
  873. --# e.g. an email address, the phone number and pin of the pager...
  874. --# autonotify : A character to determine how auto acknowledge is handled for
  875. --# this entry
  876. --#
  877. --########################################################################
  878. create table usersNotified (
  879. id integer not null,
  880. userID varchar(256) not null,
  881. notifyID integer,
  882. notifyTime timestamp with time zone,
  883. media varchar(32),
  884. contactinfo varchar(64),
  885. autonotify char(1),
  886. constraint pk_userNotificationID primary key (id),
  887. constraint fk_notifID2 foreign key (notifyID) references notifications (notifyID) ON DELETE CASCADE
  888. );
  889. create index userid_notifyid_idx on usersNotified(userID, notifyID);
  890. --#################################
  891. --# This table contains memos used by alarms to represent StickyMemos and Journal / ReductionKeyMemos
  892. create table memos (
  893. id integer NOT NULL,
  894. created timestamp with time zone,
  895. updated timestamp with time zone,
  896. author character varying(256),
  897. body text,
  898. reductionkey character varying(256),
  899. type character varying(64),
  900. CONSTRAINT memos_pkey PRIMARY KEY (id)
  901. );
  902. --########################################################################
  903. --#
  904. --# This table contains the following fields:
  905. --# alarmID : The id created from the alarmsNxtId sequence.
  906. --# eventUei : A reference to the eventUei that created this alarm.
  907. --# nodeID : A reference to the node represented by this alarm.
  908. --# ipAddr : IP Address of node's interface
  909. --# serviceID : A reference to the service represented by the alarm.
  910. --# reductionKey: Used with nodeID and serviceID to match an event and
  911. --# increment the counter column. Set by configuring the
  912. --# optional alarm-data elment in the eventConf.xml file.
  913. --# alarmType : Customizable column designed for use in automations and
  914. --# can be set in the eventConf.xml file by configuring the
  915. --# optional alarm-data element.
  916. --# counter : Incremented by the AlarmWriter instead of inserting
  917. --# a new row when matched node, service, and reductionKey
  918. --# severity : Severity of the Alarm... Initially set by the event
  919. --# can be changed with SQL update.
  920. --# lastEventID : A reference to the event table with the ID of the last
  921. --# matching event (typically node, service, reductionkey)
  922. --# firstEventTime: timestamp of the first event matching this alarm
  923. --# lastEventTime: timestamp of the last event matching this alarm
  924. --# description : description from the event
  925. --# logMsg : the logmsg from the event
  926. --# ifIndex : the ifindex from the event
  927. --# operInstruct: the operator instructions from the event
  928. --# tticketID : helpdesk integration field
  929. --# tticketState: helpdesk integration field
  930. --# mouseOverTest: flyOverText for the webUI
  931. --# suppressedUntil: used to suppress display an alarm until
  932. --# : timestamp time is reached
  933. --# suppressedUser : user that suppressed alarm
  934. --# suppressedTime : time the alarm was suppressed
  935. --# alarmAckUser : user that acknowledged the alarm
  936. --# alarmAckTime : time user Ack'd the alarm
  937. --# stickymemo : reference to the memo table
  938. --########################################################################
  939. create table alarms (
  940. alarmID INTEGER, CONSTRAINT pk_alarmID PRIMARY KEY (alarmID),
  941. eventUei VARCHAR(256) NOT NULL,
  942. dpName VARCHAR(12) NOT NULL,
  943. nodeID INTEGER, CONSTRAINT fk_alarms_nodeid FOREIGN KEY (nodeID) REFERENCES node (nodeID) ON DELETE CASCADE,
  944. ipaddr VARCHAR(39),
  945. serviceID INTEGER,
  946. reductionKey VARCHAR(256),
  947. alarmType INTEGER,
  948. counter INTEGER NOT NULL,
  949. severity INTEGER NOT NULL,
  950. lastEventID INTEGER, CONSTRAINT fk_eventIDak2 FOREIGN KEY (lastEventID) REFERENCES events (eventID) ON DELETE CASCADE,
  951. firstEventTime timestamp with time zone,
  952. lastEventTime timestamp with time zone,
  953. firstAutomationTime timestamp with time zone,
  954. lastAutomationTime timestamp with time zone,
  955. description text,
  956. logMsg text,
  957. operInstruct VARCHAR(1024),
  958. tticketID VARCHAR(128),
  959. tticketState INTEGER,
  960. mouseOverText VARCHAR(64),
  961. suppressedUntil timestamp with time zone,
  962. suppressedUser VARCHAR(256),
  963. suppressedTime timestamp with time zone,
  964. alarmAckUser VARCHAR(256),
  965. alarmAckTime timestamp with time zone,
  966. managedObjectInstance VARCHAR(512),
  967. managedObjectType VARCHAR(512),
  968. applicationDN VARCHAR(512),
  969. ossPrimaryKey VARCHAR(512),
  970. x733AlarmType VARCHAR(31),
  971. x733ProbableCause INTEGER default 0 not null,
  972. qosAlarmState VARCHAR(31),
  973. ifIndex INTEGER,
  974. clearKey VARCHAR(256),
  975. eventParms text,
  976. stickymemo INTEGER, CONSTRAINT fk_stickyMemo FOREIGN KEY (stickymemo) REFERENCES memos (id) ON DELETE CASCADE
  977. );
  978. CREATE INDEX alarm_uei_idx ON alarms(eventUei);
  979. CREATE INDEX alarm_nodeid_idx ON alarms(nodeID);
  980. CREATE UNIQUE INDEX alarm_reductionkey_idx ON alarms(reductionKey);
  981. CREATE INDEX alarm_clearkey_idx ON alarms(clearKey);
  982. CREATE INDEX alarm_reduction2_idx ON alarms(alarmID, eventUei, dpName, nodeID, serviceID, reductionKey);
  983. CREATE INDEX alarm_app_dn ON alarms(applicationDN);
  984. CREATE INDEX alarm_oss_primary_key ON alarms(ossPrimaryKey);
  985. CREATE INDEX alarm_eventid_idx ON alarms(lastEventID);
  986. CREATE INDEX alarm_lasteventtime_idx on alarms(lasteventtime);
  987. CREATE INDEX alarm_firstautomationtime_idx on alarms(firstautomationtime);
  988. CREATE INDEX alarm_lastautomationtime_idx on alarms(lastautomationtime);
  989. --########################################################################
  990. --#
  991. --# Use this table to add additional custom data about an alarm... somewhat
  992. --# usefull with automations and will be viewable/editable in the alarm
  993. --# details WebUI page.
  994. --#
  995. --# This table contains the following fields:
  996. --# alarmID : The id created from the alarmsNxtId sequence.
  997. --# attribute : The custom attribute name
  998. --# attributeValue : The custom attribute value
  999. --########################################################################
  1000. CREATE TABLE alarm_attributes (
  1001. alarmID INTEGER, CONSTRAINT fk_alarmID1 FOREIGN KEY (alarmID) REFERENCES alarms (alarmID) ON DELETE CASCADE,
  1002. attributeName VARCHAR(63),
  1003. attributeValue VARCHAR(255)
  1004. );
  1005. CREATE INDEX alarm_attributes_idx ON alarm_attributes(alarmID);
  1006. CREATE UNIQUE INDEX alarm_attributes_aan_idx ON alarm_attributes(alarmID, attributeName);
  1007. --# This constraint not understood by installer
  1008. --# CONSTRAINT pk_usersNotified PRIMARY KEY (userID,notifyID) );
  1009. --#
  1010. --########################################################################
  1011. --# asset table - Contains inventory and other user-entered information
  1012. --# for nodes
  1013. --#
  1014. --# This table contains the following fields:
  1015. --#
  1016. --# nodeID : The node id for the node this asset information belongs.
  1017. --# category : A broad idea of what this asset does (examples are
  1018. --# desktop, printer, server, infrastructure, etc.).
  1019. --# manufacturer : Name of the manufacturer of this asset.
  1020. --# vendor : Vendor from whom this asset was purchased.
  1021. --# modelNumber : The model number of this asset.
  1022. --# serialNumber : The serial number of this asset.
  1023. --# description : A free-form description.
  1024. --# circuitId : The electrical/network circuit this asset connects to.
  1025. --# assetNumber : A business-specified asset number.
  1026. --# operatingSystem : The operating system, if any.
  1027. --# rack : For servers, the rack it is installed in.
  1028. --# slot : For servers, the slot in the rack it is installed in.
  1029. --# port : For servers, the port in the slot it is installed in.
  1030. --# region : A broad geographical or organizational area.
  1031. --# division : A broad geographical or organizational area.
  1032. --# department : The department this asset belongs to.
  1033. --# address1 : Address of geographical location of asset, line 1.
  1034. --# address2 : Address of geographical location of asset, line 2.
  1035. --# city : The city where this asset resides.
  1036. --# state : The state where this asset resides.
  1037. --# zip : The zip code where this asset resides.
  1038. --# building : The building where this asset resides.
  1039. --# floor : The floor of the building where this asset resides.
  1040. --# room : The room where this asset resides.
  1041. --# vendorPhone : A contact number for the vendor.
  1042. --# vendorFax : A fax number for the vendor.
  1043. --# vendorAssetNumber: The vendor asset number.
  1044. --# username : A Username to access the node
  1045. --# password : The password to access the node
  1046. --# enable : The privilege password to access the node
  1047. --# autoenable : If username has privileged access
  1048. --# - 'A' autoenable true
  1049. --# connection : Connection protocol used to access the node (telnet, ssh, rsh, ...)
  1050. --# userCreated : The username who created this record.
  1051. --# userLastModified : The last user who modified this record.
  1052. --# lastModifiedDate : The last time this record was modified.
  1053. --# dateInstalled : The date the asset was installed.
  1054. --# lease : The lease number of this asset.
  1055. --# leaseExpires : The date the lease expires for this asset.
  1056. --# supportPhone : A support phone number for this asset.
  1057. --# maintContract : The maintenance contract number for this asset.
  1058. --#
  1059. --########################################################################
  1060. create table assets (
  1061. id INTEGER DEFAULT nextval('opennmsNxtId') NOT NULL,
  1062. nodeID integer,
  1063. category varchar(64) not null,
  1064. manufacturer varchar(64),
  1065. vendor varchar(64),
  1066. modelNumber varchar(64),
  1067. serialNumber varchar(64),
  1068. description varchar(128),
  1069. circuitId varchar(64),
  1070. assetNumber varchar(64),
  1071. operatingSystem varchar(64),
  1072. rack varchar(64),
  1073. slot varchar(64),
  1074. port varchar(64),
  1075. region varchar(64),
  1076. division varchar(64),
  1077. department varchar(64),
  1078. address1 varchar(256),
  1079. address2 varchar(256),
  1080. city varchar(64),
  1081. state varchar(64),
  1082. zip varchar(64),
  1083. country varchar(64),
  1084. building varchar(64),
  1085. floor varchar(64),
  1086. room varchar(64),
  1087. vendorPhone varchar(64),
  1088. vendorFax varchar(64),
  1089. vendorAssetNumber varchar(64),
  1090. username varchar(32),
  1091. password varchar(32),
  1092. enable varchar(32),
  1093. autoenable char(1),
  1094. connection varchar(32),
  1095. userLastModified char(20) not null,
  1096. lastModifiedDate timestamp with time zone not null,
  1097. dateInstalled varchar(64),
  1098. lease varchar(64),
  1099. leaseExpires varchar(64),
  1100. supportPhone varchar(64),
  1101. maintContract varchar(64),
  1102. maintContractExpires varchar(64),
  1103. displayCategory varchar(64),
  1104. notifyCategory varchar(64),
  1105. pollerCategory varchar(64),
  1106. thresholdCategory varchar(64),
  1107. comment text,
  1108. managedObjectInstance varchar(512),
  1109. managedObjectType varchar(512),
  1110. cpu varchar(32),
  1111. ram varchar(10),
  1112. storagectrl varchar(32),
  1113. hdd1 varchar(32),
  1114. hdd2 varchar(32),
  1115. hdd3 varchar(32),
  1116. hdd4 varchar(32),
  1117. hdd5 varchar(32),
  1118. hdd6 varchar(32),
  1119. numpowersupplies varchar(1),
  1120. inputpower varchar(6),
  1121. additionalhardware varchar(64),
  1122. admin varchar(32),
  1123. snmpcommunity varchar(32),
  1124. rackunitheight varchar(2),
  1125. longitude float,
  1126. latitude float,
  1127. vmwaremanagedobjectid varchar(70),
  1128. vmwaremanagedentitytype varchar(70),
  1129. vmwaremanagementserver varchar(70),
  1130. vmwaretopologyinfo text,
  1131. vmwarestate varchar(255),
  1132. constraint pk_assetID primary key (id),
  1133. constraint fk_nodeID5 foreign key (nodeID) references node ON DELETE CASCADE
  1134. );
  1135. create index assets_nodeid_idx on assets(nodeid);
  1136. CREATE INDEX assets_an_idx ON assets(assetNumber);
  1137. --########################################################################
  1138. --# categories table - Contains list of categories
  1139. --# for nodes, interfaces, and services
  1140. --#
  1141. --# This table contains the following fields:
  1142. --#
  1143. --# id : The category id
  1144. --# name : Textual name of a category
  1145. --# description : Descriptive text about a category.
  1146. --########################################################################
  1147. create table categories (
  1148. categoryId integer,
  1149. categoryName text not null,
  1150. categoryDescription varchar(256),
  1151. constraint category_pkey primary key (categoryId)
  1152. );
  1153. CREATE UNIQUE INDEX category_idx ON categories(categoryName);
  1154. --##################################################################
  1155. --# The following command adds an initial set of categories if there
  1156. --# are no categories in the category table
  1157. --##################################################################
  1158. --# criteria: SELECT count(*) = 0 from categories
  1159. insert into categories values (nextVal('catNxtId'), 'Routers', null);
  1160. --# criteria: SELECT count(*) = 0 from categories
  1161. insert into categories values (nextVal('catNxtId'), 'Switches', null);
  1162. --# criteria: SELECT count(*) = 0 from categories
  1163. insert into categories values (nextVal('catNxtId'), 'Servers', null);
  1164. --# criteria: SELECT count(*) = 0 from categories
  1165. insert into categories values (nextVal('catNxtId'), 'Production', null);
  1166. --# criteria: SELECT count(*) = 0 from categories
  1167. insert into categories values (nextVal('catNxtId'), 'Test', null);
  1168. --# criteria: SELECT count(*) = 0 from categories
  1169. insert into categories values (nextVal('catNxtId'), 'Development', null);
  1170. --########################################################################
  1171. --# category_node table - Many-to-Many mapping table of categories to nodes
  1172. --#
  1173. --# This table contains the following fields:
  1174. --#
  1175. --# categoryid : The category id from category table
  1176. --# nodeID : The node id from the node table.
  1177. --########################################################################
  1178. create table category_node (
  1179. categoryId integer,
  1180. nodeId integer,
  1181. constraint categoryid_fkey1 foreign key (categoryId) references categories (categoryId) ON DELETE CASCADE,
  1182. constraint nodeid_fkey1 foreign key (nodeId) references node ON DELETE CASCADE
  1183. );
  1184. CREATE INDEX catid_idx on category_node(categoryId);
  1185. CREATE INDEX catnode_idx on category_node(nodeId);
  1186. CREATE UNIQUE INDEX catenode_unique_idx on category_node(categoryId, nodeId);
  1187. --########################################################################
  1188. --# pathOutage Table - Contains the critical path IP address and service
  1189. --# associated with each node for suppressing nodeDown
  1190. --# notifications
  1191. --#
  1192. --# This table contains the following information:
  1193. --#
  1194. --# nodeID : Unique identifier of the node
  1195. --# criticalPathIp : IP Address associated with the critical element in
  1196. --# the path between the OpenNMS server and the node
  1197. --# criticalPathServiceName : the service to test on the critical path IP
  1198. --# address (Assume ICMP in Phase I implementation)
  1199. --#
  1200. --# NOTE: The nodeID must be unique
  1201. --#
  1202. --########################################################################
  1203. create table pathOutage (
  1204. nodeID integer,
  1205. criticalPathIp text not null,
  1206. criticalPathServiceName varchar(255),
  1207. constraint fk_nodeID8 foreign key (nodeID) references node ON DELETE CASCADE
  1208. );
  1209. create unique index pathoutage_nodeid on pathOutage(nodeID);
  1210. create index pathoutage_criticalpathip on pathOutage(criticalPathIp);
  1211. create index pathoutage_criticalpathservicename_idx on pathOutage(criticalPathServiceName);
  1212. --########################################################################
  1213. --# demandPolls Table - contains a list of requested polls
  1214. --#
  1215. --# This table contains the following information:
  1216. --#
  1217. --# id : Unique identifier of the demand poll
  1218. --# requestTime : the time the user requested the poll
  1219. --# user : the user that requested the poll
  1220. --# description : ?
  1221. --#
  1222. --########################################################################
  1223. create table demandPolls (
  1224. id integer,
  1225. requestTime timestamp with time zone,
  1226. username varchar(32),
  1227. description varchar(128),
  1228. constraint demandpoll_pkey primary key (id)
  1229. );
  1230. create index demandpoll_request_time on demandPolls(requestTime);
  1231. --########################################################################
  1232. --# pollResults Table - contains a list of requested polls
  1233. --#
  1234. --# This table contains the following information:
  1235. --#
  1236. --# id : unique identifier of the demand poll
  1237. --# pollId : unique identifier of this specific service poll
  1238. --# nodeId : node id of the polled service
  1239. --# ipAddr : ip address of the polled service
  1240. --# ifIndex : ifIndex of the polled service's interface
  1241. --# serviceId : serviceid of the polled service
  1242. --# statusCode : status code of the pollstatus returned by the monitor
  1243. --# statusName : status name of the pollstaus returnd by the monitor
  1244. --# reason : the reason of the pollstatus returned by the monitor
  1245. --#
  1246. --########################################################################
  1247. create table pollResults (
  1248. id integer,
  1249. pollId integer,
  1250. nodeId integer,
  1251. ipAddr text,
  1252. ifIndex integer,
  1253. serviceId integer,
  1254. statusCode integer,
  1255. statusName varchar(32),
  1256. reason varchar(128),
  1257. constraint pollresult_pkey primary key (id),
  1258. constraint fk_demandPollId foreign key (pollID) references demandPolls (id) ON DELETE CASCADE
  1259. );
  1260. create index pollresults_poll_id on pollResults(pollId);
  1261. create index pollresults_service on pollResults(nodeId, ipAddr, ifIndex, serviceId);
  1262. --#####################################################
  1263. --# locaation_monitors Table - contains a list of monitors in remote
  1264. --# locations
  1265. --#
  1266. --# This table contains the following information:
  1267. --#
  1268. --# id : surrogate key generated by sequence
  1269. --# name : name of the location monitor
  1270. --# definitionName : used to reference XML configuration
  1271. --#
  1272. --#
  1273. --#####################################################
  1274. CREATE TABLE location_monitors (
  1275. id INTEGER,
  1276. status VARCHAR(31) NOT NULL,
  1277. lastCheckInTime timestamp with time zone,
  1278. definitionName VARCHAR(31) NOT NULL,
  1279. CONSTRAINT location_monitors_pkey PRIMARY KEY (id)
  1280. );
  1281. CREATE TABLE location_monitor_details (
  1282. locationMonitorId INTEGER NOT NULL,
  1283. property VARCHAR(255) NOT NULL,
  1284. propertyValue VARCHAR(255),
  1285. CONSTRAINT location_monitor_fkey1 FOREIGN KEY (locationMonitorId) REFERENCES location_monitors (id) ON DELETE CASCADE
  1286. );
  1287. create index location_monitor_details_id on location_monitor_details(locationMonitorId);
  1288. create unique index location_monitor_details_id_property on location_monitor_details(locationMonitorId, property);
  1289. --#############################################################################
  1290. --# location_specific_status_changes Table - contains a list status
  1291. --# changed reported for a service by a monitor in a remote
  1292. --# location.
  1293. --#
  1294. --# This table contains the following information:
  1295. --#
  1296. --# id : surrogate key generated by a sequence
  1297. --# locationMonitorId : foreign key referencing a specific
  1298. --# monitor in a remote location
  1299. --# serviceId : foreign key referencing a specific monitored services
  1300. --# statusTime : time of reported status from remote location monitor
  1301. --# reason : description of status change
  1302. --# responseTime : data for latency reporting
  1303. --#
  1304. --#############################################################################
  1305. CREATE TABLE location_specific_status_changes (
  1306. id INTEGER,
  1307. locationMonitorId INTEGER NOT NULL,
  1308. ifServiceId INTEGER NOT NULL,
  1309. statusCode INTEGER NOT NULL,
  1310. statusTime timestamp with time zone NOT NULL,
  1311. statusReason VARCHAR(255),
  1312. responseTime DOUBLE PRECISION,
  1313. CONSTRAINT location_specific_status_changes_pkey PRIMARY KEY (id),
  1314. CONSTRAINT location_monitor_fkey2 FOREIGN KEY (locationMonitorId) REFERENCES location_monitors (id) ON DELETE CASCADE,
  1315. CONSTRAINT ifservices_fkey4 FOREIGN KEY (ifServiceId) REFERENCES ifservices (id) ON DELETE CASCADE
  1316. );
  1317. create index location_specific_status_changes_ifserviceid on location_specific_status_changes(ifserviceid);
  1318. create index location_specific_status_changes_locationmonitorid on location_specific_status_changes(locationmonitorid);
  1319. create index location_specific_status_changes_locationmonitorid_ifserviceid on location_specific_status_changes(locationmonitorid, ifserviceid);
  1320. create index location_specific_status_changes_locationmonitorid_loc_if_time on location_specific_status_changes(locationmonitorid, ifserviceid, statustime);
  1321. create index location_specific_status_changes_statustime on location_specific_status_changes(statustime);
  1322. --########################################################################
  1323. --# applications table - Contains list of applications for services
  1324. --#
  1325. --# This table contains the following fields:
  1326. --#
  1327. --# id : The application id
  1328. --# name : Textual name of a application
  1329. --########################################################################
  1330. create table applications (
  1331. id integer,
  1332. name varchar(32) not null,
  1333. constraint applications_pkey primary key (id)
  1334. );
  1335. CREATE UNIQUE INDEX applications_name_idx ON applications(name);
  1336. --########################################################################
  1337. --# application_service_map table - Many-to-Many mapping table of
  1338. --# applications to ifServices
  1339. --#
  1340. --# This table contains the following fields:
  1341. --#
  1342. --# appId : The application id from applications table
  1343. --# ifServiceId : The id from the ifServices table.
  1344. --########################################################################
  1345. create table application_service_map (
  1346. appId integer,
  1347. ifServiceId integer,
  1348. constraint applicationid_fkey1 foreign key (appId) references applications (id) ON DELETE CASCADE,
  1349. constraint ifservices_fkey3 foreign key (ifServiceId) references ifServices (id) ON DELETE CASCADE
  1350. );
  1351. CREATE INDEX appid_idx on application_service_map(appid);
  1352. CREATE INDEX ifserviceid_idx on application_service_map(ifserviceid);
  1353. CREATE UNIQUE INDEX appid_ifserviceid_idex on application_service_map(appid,ifserviceid);
  1354. --##################################################################
  1355. --# The following command adds the initial loopback poller entry to
  1356. --# the 'distPoller' table.
  1357. --##################################################################
  1358. --# criteria: SELECT count(*) = 0 from distPoller where dpName = 'localhost'
  1359. insert into distPoller (dpName, dpIP, dpComment, dpDiscLimit, dpLastNodePull, dpLastEventPull, dpLastPackagePush, dpAdminState, dpRunState) values ('localhost', '127.0.0.1', 'This is the default poller.', 0.10, null, null, null, 1, 1);
  1360. --########################################################################
  1361. --#
  1362. --# next are Italian Adventures 2 specific tables
  1363. --# author rssntn67@yahoo.it
  1364. --#
  1365. --# 10/08/04
  1366. --# creato il file e le tabelle
  1367. --# rev. rssntn67@yahoo.it
  1368. --#
  1369. --# 18/08/04
  1370. --# eliminato createtime dalle tabelle
  1371. --# sufficiente il createtime della tabella node
  1372. --#
  1373. --# 11/07/05
  1374. --# modificata la tabella stpnode aggiunto campo vlanname
  1375. --# definita primary key
  1376. --# per la tabella atinterface,
  1377. --# Modified: 2007-01-09
  1378. --# Note: Added vlan table, Modified Stpnode Table
  1379. --#
  1380. --#
  1381. --########################################################################
  1382. --########################################################################
  1383. --#
  1384. --# atInterface table -- This table maintains a record of ip address to mac
  1385. --# address among interfaces. It reflect information from mib-2
  1386. --# arp table
  1387. --# at interface is now deprecated .iso.org.dod.internet.mgmt.mib-2.at.atTable.atEntry
  1388. --# OID: .1.3.6.1.2.1.3.1.1
  1389. --# so support is for .iso.org.dod.internet.mgmt.mib-2.ip.ipNetToMediaTable.ipNetToMediaEntry
  1390. --# OID: .1.3.6.1.2.1.4.22.1
  1391. --#
  1392. --# This table provides the following information:
  1393. --#
  1394. --# nodeid : Unique integer identifier of the node
  1395. --# ipAddr : Ip address identifier of the node
  1396. --# atPhysAddr : Mac address identifier for the node
  1397. --# status : Flag indicating the status of the entry.
  1398. --# 'A' - Active
  1399. --# 'N' - Not Active
  1400. --# 'D' - Deleted
  1401. --# 'K' - Unknown
  1402. --# sourceNodeid : The nodeid from which information have been retrivied.
  1403. --# ifindex : The SNMP ifindex on which this info was recorded.
  1404. --# lastPollTime : The last time when this information was active
  1405. --#
  1406. --########################################################################
  1407. create table atinterface (
  1408. id integer default nextval('opennmsNxtId') not null,
  1409. nodeid integer not null,
  1410. ipAddr text not null,
  1411. atPhysAddr varchar(32) not null,
  1412. status char(1) not null,
  1413. sourceNodeid integer not null,
  1414. ifindex integer not null,
  1415. lastPollTime timestamp not null,
  1416. constraint pk_atinterface primary key (nodeid,ipAddr,atPhysAddr),
  1417. constraint fk_ia_nodeID1 foreign key (nodeid) references node on delete cascade
  1418. );
  1419. create index atinterface_nodeid_idx on atinterface(nodeid);
  1420. create index atinterface_node_ipaddr_idx on atinterface(nodeid,ipaddr);
  1421. create index atinterface_atphysaddr_idx on atinterface(atphysaddr);
  1422. --########################################################################
  1423. --#
  1424. --# vlan table -- This table maintains a record of generic vlan table
  1425. --#
  1426. --# This table provides the following information:
  1427. --#
  1428. --# nodeid : Unique integer identifier of the node
  1429. --# vlanid : The vlan identifier to be referred to in a unique fashion.
  1430. --# vlanname : the name the vlan
  1431. --# vlantype : Indicates what type of vlan is this:
  1432. --# '1' ethernet
  1433. --# '2' FDDI
  1434. --# '3' TokenRing
  1435. --# '4' FDDINet
  1436. --# '5' TRNet
  1437. --# '6' Deprecated
  1438. --# vlanstatus : An indication of what is the Vlan Status:
  1439. --# '1' operational
  1440. --# '2' suspendid
  1441. --# '3' mtuTooBigForDevice
  1442. --# '4' mtuTooBigForTrunk
  1443. --# status : Flag indicating the status of the entry.
  1444. --# 'A' - Active
  1445. --# 'N' - Not Active
  1446. --# 'D' - Deleted
  1447. --# 'K' - Unknown
  1448. --# lastPollTime : The last time when this information was retrived
  1449. --#
  1450. --########################################################################
  1451. create table vlan (
  1452. id integer default nextval('opennmsNxtId') not null,
  1453. nodeid integer not null,
  1454. vlanid integer not null,
  1455. vlanname varchar(64) not null,
  1456. vlantype integer,
  1457. vlanstatus integer,
  1458. status char(1) not null,
  1459. lastPollTime timestamp not null,
  1460. constraint pk_vlan primary key (nodeid,vlanid),
  1461. constraint fk_ia_nodeID8 foreign key (nodeid) references node on delete cascade
  1462. );
  1463. create unique index vlan_id_key on vlan(id);
  1464. create index vlan_vlanname_idx on vlan(vlanname);
  1465. --########################################################################
  1466. --#
  1467. --# stpNode table -- This table maintains a record of general bridge interface.
  1468. --# It reflect information from the mib-2 bridge mib
  1469. --# support .iso.org.dod.internet.mgmt.mib-2.dot1dBridge
  1470. --# OID: .1.3.6.1.2.1.17
  1471. --#
  1472. --# This table provides the following information:
  1473. --#
  1474. --# nodeid : Unique integer identifier of the node
  1475. --# baseBridgeAddress : The MAC address used by this bridge when it must
  1476. --# be referred to in a unique fashion.
  1477. --# baseNumPorts : The number of ports controlled by the bridge entity.
  1478. --# baseType : Indicates what type of bridging this bridge can
  1479. --# perform.
  1480. --# '1' unknown
  1481. --# '2' transparent-only
  1482. --# '3' sourceroute-only
  1483. --# '4' srt
  1484. --# stpProtocolSpecification : An indication of what version of the Spanning
  1485. --# Tree Protocol is being run.
  1486. --# '1' unknown
  1487. --# '2' decLb100
  1488. --# '3' ieee8011d
  1489. --# stpPriority : The value of the write-able portion of the Bridge
  1490. --# ID, i.e., the first two octets of the (8 octet
  1491. --# long) Bridge ID. The other (last) 6 octets of the
  1492. --# Bridge ID are given by the value of dot1dBaseBridgeAddress.
  1493. --# stpDesignatedRoot : The bridge identifier of the root of the spanning
  1494. --# tree as determined by the Spanning Tree Protocol
  1495. --# as executed by this node.
  1496. --# stpRootCost : The cost of the path to the root as seen from this bridge.
  1497. --# stpRootPort : The port number of the port which offers the
  1498. --# lowest cost path from this bridge to the root bridge.
  1499. --# status : Flag indicating the status of the entry.
  1500. --# 'A' - Active
  1501. --# 'N' - Not Active
  1502. --# 'D' - Deleted
  1503. --# 'K' - Unknown
  1504. --# lastPollTime : The last time when this information was retrived
  1505. --# baseVlan : Unique integer identifier VLAN for which this info is valid
  1506. --# baseVlanName : VLAN name
  1507. --#
  1508. --########################################################################
  1509. create table stpnode (
  1510. id integer default nextval('opennmsNxtId') not null,
  1511. nodeid integer not null,
  1512. baseBridgeAddress varchar(12) not null,
  1513. baseNumPorts integer,
  1514. basetype integer,
  1515. stpProtocolSpecification integer,
  1516. stpPriority integer,
  1517. stpdesignatedroot varchar(16),
  1518. stprootcost integer,
  1519. stprootport integer,
  1520. status char(1) not null,
  1521. lastPollTime timestamp not null,
  1522. basevlan integer not null,
  1523. basevlanname varchar(32),
  1524. constraint pk_stpnode primary key (nodeid,basevlan),
  1525. constraint fk_ia_nodeID2 foreign key (nodeid) references node on delete cascade
  1526. );
  1527. create unique index stpnode_id_key on stpnode(id);
  1528. create index stpnode_nodeid_idx on stpnode(nodeid);
  1529. create index stpnode_baseBridgeAddress_idx on stpnode(baseBridgeAddress);
  1530. create index stpnode_stpdesignatedroot_idx on stpnode(stpdesignatedroot);
  1531. --########################################################################
  1532. --#
  1533. --# stpInterface table -- This table maintains a record of STP interface.
  1534. --# It reflect information from mib-2
  1535. --# bridge mib and subinterface STP table
  1536. --# support .iso.org.dod.internet.mgmt.mib-2.dot1dBridge
  1537. --# OID: .1.3.6.1.2.1.17
  1538. --#
  1539. --# This table provides the following information:
  1540. --#
  1541. --# nodeid : Unique integer identifier of the node
  1542. --# ifIndex : interface ifindex corresponding to bridge port number
  1543. --# bridgePort : bridge port number identifier
  1544. --# stpPortState : integer that reflect thestp staus of the bridge port
  1545. --# '1' disabled
  1546. --# '2' blocking
  1547. --# '3' listening
  1548. --# '4' learning
  1549. --# '5' forwarding
  1550. --# '6' broken
  1551. --# stpPortPathCost : The contribution of this port to the path cost of
  1552. --# paths towards the spanning tree root which include
  1553. --# this port.
  1554. --# stpPortDesignatedRoot : the unique Bridge Identifier of the Bridge
  1555. --# recorded as the Root in the Configuration BPDUs
  1556. --# transmitted by the Designated Bridge for the
  1557. --# segment to which the port is attached.
  1558. --# stpPortDesignatedCost : The path cost of the Designated Port of the
  1559. --# segment connected to this port. This value is
  1560. --# compared to the Root Path Cost field in received
  1561. --# bridge PDUs.
  1562. --# stpPortDesignatedBridge : The Bridge Identifier of the bridge which this
  1563. --# port considers to be the Designated Bridge for
  1564. --# this port's segment.
  1565. --# stpPortDesignatedPort : The Port Identifier of the port on the Designated
  1566. --# Bridge for this port's segment.
  1567. --# status : Flag indicating the status of the entry.
  1568. --# 'A' - Active
  1569. --# 'N' - Not Active
  1570. --# 'D' - Deleted
  1571. --# 'K' - Unknown
  1572. --# lastPollTime : The last time when this information was retrived
  1573. --# stpVlan : Unique integer identifier VLAN for which this info is valid
  1574. --#
  1575. --########################################################################
  1576. create table stpinterface (
  1577. id integer default nextval('opennmsNxtId') not null,
  1578. nodeid integer not null,
  1579. bridgeport integer not null,
  1580. ifindex integer not null,
  1581. stpportstate integer,
  1582. stpportpathcost integer,
  1583. stpportdesignatedroot varchar(16),
  1584. stpportdesignatedcost integer,
  1585. stpportdesignatedbridge varchar(16),
  1586. stpportdesignatedport varchar(4),
  1587. status char(1) not null,
  1588. lastPollTime timestamp not null,
  1589. stpvlan integer not null,
  1590. constraint pk_stpinterface primary key (nodeid,bridgeport,stpvlan),
  1591. constraint fk_ia_nodeID3 foreign key (nodeid) references node on delete cascade
  1592. );
  1593. create unique index stpinterface_id_key on stpinterface(id);
  1594. create index stpinterface_node_ifindex_idx on stpinterface(nodeid,ifindex);
  1595. create index stpinterface_node_idx on stpinterface(nodeid);
  1596. create index stpinterface_stpvlan_idx on stpinterface(stpvlan);
  1597. create index stpinterface_stpdesbridge_idx on stpinterface(stpportdesignatedbridge);
  1598. --########################################################################
  1599. --#
  1600. --# ipRouteInterface table -- This table maintains a record of ip route info on routers.
  1601. --# It reflect information from mib-2
  1602. --# ipRouteTable mib
  1603. --# support .iso.org.dod.internet.mgmt.mib-2.ip.ipRouteTable.ipRouteEntry
  1604. --# OID: .1.3.6.1.2.1.4.21.1
  1605. --#
  1606. --# This table provides the following information:
  1607. --#
  1608. --# nodeid : Unique integer identifier of the node
  1609. --# routeDest : The destination IP address of this route. An
  1610. --# entry with a value of 0.0.0.0 is considered a default route.
  1611. --# routeMask : Indicate the mask to be logical-ANDed with the
  1612. --# destination address before being compared to the
  1613. --# value in the ipRouteDest field.
  1614. --# routeNextHop : The IP address of the next hop of this route.
  1615. --# (In the case of a route bound to an interface
  1616. --# which is realized via a broadcast media, the value
  1617. --# of this field is the agent's IP address on that
  1618. --# interface.)
  1619. --# routeifIndex : The index value which uniquely identifies the
  1620. --# local interface through which the next hop of this
  1621. --# route should be reached.
  1622. --# routeMetric1 : The primary routing metric for this route. The
  1623. --# semantics of this metric are determined by the
  1624. --# routing-protocol specified in the route's
  1625. --# ipRouteProto value. If this metric is not used,
  1626. --# its value should be set to -1.
  1627. --# routeMetric2 : An alternate routing metric for this route.
  1628. --# routeMetric3 : An alternate routing metric for this route.
  1629. --# routeMetric4 : An alternate routing metric for this route.
  1630. --# routeMetric5 : An alternate routing metric for this route.
  1631. --# routeType : The type of route.
  1632. --# '1' other
  1633. --# '2' invalid
  1634. --# '3' direct
  1635. --# '4' indirect
  1636. --# routeProto : The routing mechanism via which this route was learned.
  1637. --# '1' other
  1638. --# '2' local
  1639. --# '3' netmgmt
  1640. --# '4' icmp
  1641. --# '5' egp
  1642. --# '6' ggp
  1643. --# '7' hello
  1644. --# '8' rip
  1645. --# '9' is-is
  1646. --# '10' es-is
  1647. --# '11' ciscolgrp
  1648. --# '12' bbnSpfIgp
  1649. --# '13' ospf
  1650. --# '14' bgp
  1651. --# status : Flag indicating the status of the entry.
  1652. --# 'A' - Active
  1653. --# 'N' - Not Active
  1654. --# 'D' - Deleted
  1655. --# 'K' - Unknown
  1656. --# lastPollTime : The last time when this information was retrived
  1657. --#
  1658. --########################################################################
  1659. create table iprouteinterface (
  1660. id integer default nextval('opennmsNxtId') not null,
  1661. nodeid integer not null,
  1662. routeDest varchar(16) not null,
  1663. routeMask varchar(16) not null,
  1664. routeNextHop varchar(16) not null,
  1665. routeifindex integer not null,
  1666. routemetric1 integer,
  1667. routemetric2 integer,
  1668. routemetric3 integer,
  1669. routemetric4 integer,
  1670. routemetric5 integer,
  1671. routetype integer,
  1672. routeproto integer,
  1673. status char(1) not null,
  1674. lastPollTime timestamp not null,
  1675. constraint pk_iprouteinterface primary key (nodeid,routedest),
  1676. constraint fk_ia_nodeID4 foreign key (nodeid) references node on delete cascade
  1677. );
  1678. create unique index iprouteinterface_id_key on iprouteinterface(id);
  1679. create index iprouteinterface_nodeid_idx on iprouteinterface(nodeid);
  1680. create index iprouteinterface_node_ifdex_idx on iprouteinterface(nodeid,routeifindex);
  1681. create index iprouteinterface_rnh_idx on iprouteinterface(routenexthop);
  1682. --########################################################################
  1683. --#
  1684. --# dataLinkInterface table -- This table maintains a record of data link info
  1685. --# among the interfaces.
  1686. --#
  1687. --# This table provides the following information:
  1688. --#
  1689. --# nodeid : Unique integer identifier for the linked node
  1690. --# IfIndex : SNMP index of interface connected to the link on the node,
  1691. --# is -1 if it doesn't support SNMP.
  1692. --# nodeparentid : Unique integer identifier for linking node
  1693. --# parentIfIndex : SNMP index of interface linked on the parent node.
  1694. --# status : Flag indicating the status of the entry.
  1695. --# 'A' - Active
  1696. --# 'N' - Not Active
  1697. --# 'D' - Deleted
  1698. --# 'U' - Unknown
  1699. --# 'G' - Good
  1700. --# 'B' - Bad
  1701. --# 'X' - Admin Down
  1702. --# protocol : the protocol used to discover the link (bridge,iproute,isis,ospf,cdp,lldp)
  1703. --# linkTypeId : An Integer (corresponding at iftype for cables links) indicating the type
  1704. --# lastPollTime : The last time when this information was retrived
  1705. --# source : The source of the data link. Defaults to 'linkd', but can be different
  1706. --# when created from the ReST interface.
  1707. --#
  1708. --########################################################################
  1709. create table datalinkinterface (
  1710. id integer default nextval('opennmsNxtId') not null,
  1711. nodeid integer not null,
  1712. ifindex integer not null,
  1713. nodeparentid integer not null,
  1714. parentIfIndex integer not null,
  1715. status char(1) not null,
  1716. protocol varchar(31),
  1717. linkTypeId integer,
  1718. lastPollTime timestamp not null,
  1719. source varchar(64) not null default 'linkd',
  1720. constraint pk_datalinkinterface primary key (id),
  1721. constraint fk_ia_nodeID5 foreign key (nodeid) references node on delete cascade,
  1722. constraint fk_ia_nodeID6 foreign key (nodeparentid) references node (nodeid) ON DELETE CASCADE
  1723. );
  1724. create index dlint_id_idx on datalinkinterface(id);
  1725. create index dlint_node_idx on datalinkinterface(nodeid);
  1726. create index dlint_nodeparent_idx on datalinkinterface(nodeparentid);
  1727. create index dlint_nodeparent_paifindex_idx on datalinkinterface(nodeparentid,parentifindex);
  1728. --########################################################################
  1729. --#
  1730. --# linkState table -- This table maintains the state of the link.
  1731. --#
  1732. --# This table provides the following information:
  1733. --#
  1734. --# nodeid : Unique integer identifier for the linked node
  1735. --# IfIndex : SNMP index of interface connected to the link on the node,
  1736. --# is -1 if it doesn't support SNMP.
  1737. --# nodeparentid : Unique integer identifier for linking node
  1738. --# parentIfIndex : SNMP index of interface linked on the parent node.
  1739. --# status : Flag indicating the status of the entry.
  1740. --# 'A' - Active
  1741. --# 'N' - Not Active
  1742. --# 'D' - Deleted
  1743. --# 'U' - Unknown
  1744. --# 'G' - Good
  1745. --# 'B' - Bad
  1746. --# 'X' - Admin Down
  1747. --# linkTypeId : An Integer (corresponding at iftype for cables links) indicating the type
  1748. --# lastPollTime : The last time when this information was retrived
  1749. --#
  1750. --########################################################################
  1751. create table linkstate (
  1752. id integer default nextval('opennmsNxtId') not null,
  1753. datalinkinterfaceid integer not null,
  1754. linkstate varchar(30) default 'LINK_UP' not null,
  1755. constraint pk_linkstate primary key (id),
  1756. constraint fk_linkstate_datalinkinterface_id foreign key (datalinkinterfaceid) references datalinkinterface (id) on delete cascade
  1757. );
  1758. create unique index linkstate_datalinkinterfaceid_index on linkstate (datalinkinterfaceid);
  1759. --########################################################################
  1760. --#
  1761. --# inventory table -- This table maintains inventories
  1762. --# of switch nodes.
  1763. --#
  1764. --# This table provides the following information:
  1765. --#
  1766. --# nodeid : Unique integer identifier for the linked node.
  1767. --# name : Name that describes the category of the inventory.
  1768. --# createtime : The timestamp of the creation of the inventory.
  1769. --# lastpolltime : The timestamp of last download of the inventory.
  1770. --# pathtofile : The path where the inventory file is stored.
  1771. --# status : Flag indicating the status of the entry.
  1772. --# 'A' - Active
  1773. --# 'N' - Not Active
  1774. --# 'D' - Deleted: when the status of the node associated
  1775. --# is Deleted
  1776. --#
  1777. --########################################################################
  1778. create table inventory (
  1779. nodeid integer not null,
  1780. name varchar(30) not null,
  1781. createtime timestamp not null,
  1782. lastpolltime timestamp not null,
  1783. pathtofile varchar(256) not null,
  1784. status char(1) not null,
  1785. constraint fk_ia_nodeID7 foreign key (nodeID) references node on delete cascade
  1786. );
  1787. create index inventory_nodeid_name_idx on inventory(nodeid,name);
  1788. create index inventory_nodeid_idx on inventory(nodeid);
  1789. create index inventory_lastpolltime_idx on inventory(lastpolltime);
  1790. create index inventory_status_idx on inventory(status);
  1791. --########################################################################
  1792. --#
  1793. --# map table -- This table maintains a record of map definede in opennms
  1794. --#
  1795. --# This table provides the following information:
  1796. --#
  1797. --# mapId : Unique integer identifier of the map
  1798. --# mapName : Identifier of the map
  1799. --# mapBackGround : bakground image assocated with map
  1800. --# mapOwner : user who has the ownership of the map (also the user that created the map)
  1801. --# mapGroup : group who has the access to the map
  1802. --# mapCreateTime : The time the map was created
  1803. --# mapAccess : a 2/4 character sequence rw,ro, rwro to access the map owner/group/all permission
  1804. --# userLastModifies : the user who last modified the map
  1805. --# lastModifiedTime : The last time the map was modified
  1806. --# mapScale : A float scale factor for the map
  1807. --# mapXOffeset : An Integer representing the offset in Pixel
  1808. --# mapYOffset : An Integer representing the offset in Pixel
  1809. --# mapType : Flag indicating the type of the map.
  1810. --# 'A' - Map generated automatically
  1811. --# 'U' - Map generated by user
  1812. --# 'S' - Map Static means that is an Automatic map Saved by a user
  1813. --# 'D' - Map deleted // FOR FUTURE USE
  1814. --# mapWidth : Width of the map
  1815. --# mapHeight : Height of the map
  1816. --########################################################################
  1817. create table map (
  1818. mapId integer default nextval('opennmsNxtId') not null,
  1819. mapName varchar(63) not null,
  1820. mapBackGround varchar(256),
  1821. mapOwner varchar(64) not null,
  1822. mapGroup varchar(64),
  1823. mapCreateTime timestamp not null,
  1824. mapAccess char(6) not null,
  1825. userLastModifies varchar(64) not null,
  1826. lastModifiedTime timestamp not null,
  1827. mapScale float8,
  1828. mapXOffset integer,
  1829. mapYOffset integer,
  1830. mapType char(1),
  1831. mapWidth integer not null,
  1832. mapHeight integer not null,
  1833. constraint pk_mapID primary key (mapId)
  1834. );
  1835. --########################################################################
  1836. --#
  1837. --# element table -- This table maintains a record of elements beloging to maps
  1838. --#
  1839. --# This table provides the following information:
  1840. --#
  1841. --# mapId : Identifier of the parent map
  1842. --# elementId : Identifier of the element map
  1843. --# elemenType : Flag indicating the type of the element.
  1844. --# 'M' - Element is a Map
  1845. --# 'N' - Element is a Node
  1846. --# elementLabel : element label
  1847. --# elementIcon : image assocated with element
  1848. --# elementX : An Integer representing the position in arbitrary units
  1849. --# elementY : An Integer representing the offset in abitrary units
  1850. --#
  1851. --########################################################################
  1852. create table element (
  1853. id integer default nextval('opennmsNxtId') not null,
  1854. mapId integer not null,
  1855. elementId integer not null,
  1856. elementType char(1) not null,
  1857. elementLabel varchar(256) not null,
  1858. elementIcon varchar(256),
  1859. elementX integer,
  1860. elementY integer,
  1861. constraint pk_element primary key (mapId,elementId,elementType),
  1862. constraint fk_mapID foreign key (mapId) references map on delete cascade
  1863. );
  1864. create index element_mapid_elementid on element(mapId,elementId);
  1865. --# These don't work with installer
  1866. --#alter table element add constraint elementid check (elementid <> 0);
  1867. --########################################################################
  1868. --#
  1869. --# reportLocator table -- This table contains a record of availability
  1870. --# reports and their location on disk
  1871. --#
  1872. --# This table provides the following information:
  1873. --#
  1874. --# id : Unique integer identifier for the report
  1875. --# categoryName : Name of the report category
  1876. --# runDate : Date report sheduled to run
  1877. --# format : format of the report (calenda etc).
  1878. --# type : output type of the file (SVG/PDF/HTML)
  1879. --# location : where on disk we put the report
  1880. --# Available : Have we run the report yet or not?
  1881. --#
  1882. --########################################################################
  1883. create table reportLocator (
  1884. reportId integer not null,
  1885. reportCategory varchar(256) not null,
  1886. reportDate timestamp with time zone not null,
  1887. reportFormat varchar(256) not null,
  1888. reportType varchar(256) not null,
  1889. reportLocation varchar(256) not null,
  1890. reportAvailable bool not null
  1891. );
  1892. --# Sequence for the reportId column in the reportLocator table
  1893. --# sequence, column, table
  1894. --# install: reportNxtId reportId reportLocator
  1895. create sequence reportNxtId minvalue 1;
  1896. --########################################################################
  1897. --#
  1898. --# reportcatalog table -- report catalog data
  1899. --# reports and their location on disk
  1900. --#
  1901. --# This table provides the following information:
  1902. --#
  1903. --# id : Unique integer identifier for the report
  1904. --# reportId : Name of the report category
  1905. --# title : display title
  1906. --# date : when the report was run
  1907. --# location : where on disk we put the report
  1908. --#
  1909. --########################################################################
  1910. create table reportCatalog (
  1911. id integer not null,
  1912. reportId varchar(256) not null,
  1913. title varchar(256) not null,
  1914. date timestamp with time zone not null,
  1915. location varchar(256) not null
  1916. );
  1917. --# Sequence for the reportId column in the reportLocator table
  1918. --# sequence, column, table
  1919. --# install: reportCatalogNxtId id reportCatalog
  1920. create sequence reportCatalogNxtId minvalue 1;
  1921. --########################################################################
  1922. --#
  1923. --# statisticsReport table -- This table contains a record of statistics
  1924. --# reports
  1925. --#
  1926. --# This table provides the following information:
  1927. --#
  1928. --# id : Unique integer identifier for the report
  1929. --# startDate : The beginning date for the report (data starting
  1930. --# at this time stamp is included)
  1931. --# endDate : The end date for the report (data up to,
  1932. --# but not including this time stamp is included)
  1933. --# name : Report name this references a report definition
  1934. --# in statsd-configuration.xml
  1935. --# description : User-friendly description for this report
  1936. --# jobStartedDate : The date when this report run started
  1937. --# jobCompletedDate : The date when this report run completed
  1938. --# purgeDate : The date at which this report can be purged
  1939. --#
  1940. --########################################################################
  1941. create table statisticsReport (
  1942. id integer default nextval('opennmsNxtId') not null,
  1943. startDate timestamp with time zone not null,
  1944. endDate timestamp with time zone not null,
  1945. name varchar(63) not null,
  1946. description varchar(255) not null,
  1947. jobStartedDate timestamp with time zone not null,
  1948. jobCompletedDate timestamp with time zone not null,
  1949. purgeDate timestamp with time zone not null,
  1950. constraint pk_statisticsReport_id primary key (id)
  1951. );
  1952. create index statisticsReport_startDate on statisticsReport(startDate);
  1953. create index statisticsReport_name on statisticsReport(name);
  1954. create index statisticsReport_purgeDate on statisticsReport(purgeDate);
  1955. --########################################################################
  1956. --#
  1957. --# resourceReference table -- This table is a lookup table for string
  1958. --# resourceIds. This will help keep the relatively
  1959. --# long (tens of characters) string resource IDs
  1960. --# out of the statistics table.
  1961. --#
  1962. --# This table provides the following information:
  1963. --#
  1964. --# id : Unique integer identifier for the resource
  1965. --# resourceId : String resource ID for this resource
  1966. --#
  1967. --########################################################################
  1968. create table resourceReference (
  1969. id integer default nextval('opennmsNxtId') not null,
  1970. resourceId varchar(255) not null,
  1971. constraint pk_resourceReference_id primary key (id)
  1972. );
  1973. create unique index resourceReference_resourceId on resourceReference (resourceId);
  1974. --########################################################################
  1975. --#
  1976. --# statisticsReportData table -- This table contains individual data points
  1977. --# (aggregated or not) for statistics reports.
  1978. --#
  1979. --# This table provides the following information:
  1980. --#
  1981. --# id : Unique integer identifier for the data
  1982. --# reportId : Integer ID for the report that created this data
  1983. --# resourceId : Integer ID for this resource related to this data
  1984. --# value : Float containing the value for this data point
  1985. --#
  1986. --########################################################################
  1987. create table statisticsReportData (
  1988. id integer default nextval('opennmsNxtId') not null,
  1989. reportId integer not null,
  1990. resourceId integer not null,
  1991. value float8 not null,
  1992. constraint pk_statsData_id primary key (id),
  1993. constraint fk_statsData_reportId foreign key (reportId) references statisticsReport (id) on delete cascade,
  1994. constraint fk_statsData_resourceId foreign key (resourceId) references resourceReference (id) on delete cascade
  1995. );
  1996. create unique index statsData_unique on statisticsReportData(reportId, resourceId);
  1997. --# Begin Acknowledgment persistence table structure
  1998. --########################################################################
  1999. --#
  2000. --# acks table -- This table contains each acknowledgment
  2001. --#
  2002. --# id : Unique ID
  2003. --# ackTime : Time of the Acknowledgment
  2004. --# ackUser : User ID of the Acknowledgment
  2005. --# ackType : Enum of Acknowlegable Types in the system (i.e
  2006. --# : notifications/alarms
  2007. --# ackAction : Enum of Acknowlegable Actions in the system (i.e.
  2008. --# : ack,unack,clear,escalate
  2009. --# refId : Acknowledgable's ID
  2010. --########################################################################
  2011. CREATE TABLE acks (
  2012. id integer default nextval('opennmsnxtid') not null,
  2013. ackTime timestamp with time zone not null default now(),
  2014. ackUser varchar(64) not null default 'admin',
  2015. ackType integer not null default 1,
  2016. ackAction integer not null default 1,
  2017. log varchar(128),
  2018. refId integer,
  2019. constraint pk_acks_id primary key (id)
  2020. );
  2021. create index ack_time_idx on acks(ackTime);
  2022. create index ack_user_idx on acks(ackUser);
  2023. --########################################################################
  2024. --#
  2025. --# categories to groups mapping table -- This table used for maintaining a many-to-many
  2026. --# relationship between categories and groups
  2027. --#
  2028. --# categoryId : References foreign key in the groups table
  2029. --# groupId : References foreign key in the users table
  2030. --########################################################################
  2031. create table category_group (
  2032. categoryId integer not null,
  2033. groupId varchar(16) not null,
  2034. constraint categoryid_fkey2 foreign key (categoryId) references categories ON DELETE CASCADE
  2035. );
  2036. CREATE INDEX catid_idx3 on category_group(categoryId);
  2037. CREATE INDEX catgroup_idx on category_group(groupId);
  2038. CREATE UNIQUE INDEX catgroup_unique_idx on category_group(categoryId, groupId);
  2039. --# Begin enlinkd table
  2040. drop table lldpElement cascade;
  2041. drop table lldpLink cascade;
  2042. drop table cdpElement cascade;
  2043. drop table cdpLink cascade;
  2044. drop table ospfElement cascade;
  2045. drop table ospfLink cascade;
  2046. drop table isisElement cascade;
  2047. drop table isisLink cascade;
  2048. drop table ipNetToMedia cascade;
  2049. drop table bridgeElement cascade;
  2050. drop table bridgeMacLink cascade;
  2051. drop table bridgeBridgeLink cascade;
  2052. drop table bridgeStpLink cascade;
  2053. create table lldpElement (
  2054. id integer default nextval('opennmsnxtid') not null,
  2055. nodeid integer not null,
  2056. lldpChassisId varchar(255) not null,
  2057. lldpChassisIdSubType integer not null,
  2058. lldpSysname varchar(255) not null,
  2059. lldpNodeCreateTime timestamp not null,
  2060. lldpNodeLastPollTime timestamp not null,
  2061. constraint pk_lldpelement_id primary key (id),
  2062. constraint fk_nodeIDlldpelem foreign key (nodeid) references node ON DELETE CASCADE
  2063. );
  2064. create table lldpLink (
  2065. id integer default nextval('opennmsnxtid') not null,
  2066. nodeid integer not null,
  2067. lldpLocalPortNum integer not null,
  2068. lldpPortId varchar(255) not null,
  2069. lldpPortIdSubType integer not null,
  2070. lldpPortDescr varchar(255) not null,
  2071. lldpPortIfindex integer,
  2072. lldpRemChassisId varchar(255) not null,
  2073. lldpRemChassisIdSubType integer not null,
  2074. lldpRemSysname varchar(255) not null,
  2075. lldpRemPortId varchar(255) not null,
  2076. lldpRemPortIdSubType integer not null,
  2077. lldpRemPortDescr varchar(255) not null,
  2078. lldpLinkCreateTime timestamp not null,
  2079. lldpLinkLastPollTime timestamp not null,
  2080. constraint pk_lldplink_id primary key (id),
  2081. constraint fk_nodeIDlldplink foreign key (nodeid) references node ON DELETE CASCADE
  2082. );
  2083. create table cdpElement (
  2084. id integer default nextval('opennmsnxtid') not null,
  2085. nodeid integer not null,
  2086. cdpGlobalRun integer not null,
  2087. cdpGlobalDeviceId varchar(255) not null,
  2088. cdpNodeCreateTime timestamp not null,
  2089. cdpNodeLastPollTime timestamp not null,
  2090. constraint pk_cdpelement_id primary key (id),
  2091. constraint fk_nodeIDcdpelem foreign key (nodeid) references node ON DELETE CASCADE
  2092. );
  2093. create table cdpLink (
  2094. id integer default nextval('opennmsnxtid') not null,
  2095. nodeid integer not null,
  2096. cdpCacheIfIndex integer not null,
  2097. cdpInterfaceName varchar(96) not null,
  2098. cdpCacheAddressType integer not null,
  2099. cdpCacheAddress varchar(64) not null,
  2100. cdpCacheVersion varchar(255) not null,
  2101. cdpCacheDeviceId varchar(64) not null,
  2102. cdpCacheDevicePort varchar(96) not null,
  2103. cdpCacheDevicePlatform varchar(96) not null,
  2104. cdpLinkCreateTime timestamp not null,
  2105. cdpLinkLastPollTime timestamp not null,
  2106. constraint pk_cdplink_id primary key (id),
  2107. constraint fk_nodeIDcdplink foreign key (nodeid) references node ON DELETE CASCADE
  2108. );
  2109. create table ospfElement (
  2110. id integer default nextval('opennmsnxtid') not null,
  2111. nodeid integer not null,
  2112. ospfRouterId varchar(16) not null,
  2113. ospfAdminStat integer not null,
  2114. ospfVersionNumber integer not null,
  2115. ospfBdrRtrStatus integer not null,
  2116. ospfASBdrRtrStatus integer not null,
  2117. ospfRouterIdNetmask varchar(16) not null,
  2118. ospfRouterIdIfindex integer not null,
  2119. ospfNodeCreateTime timestamp not null,
  2120. ospfNodeLastPollTime timestamp not null,
  2121. constraint pk_ospfelement_id primary key (id),
  2122. constraint fk_nodeIDospfelem foreign key (nodeid) references node ON DELETE CASCADE
  2123. );
  2124. create table ospfLink (
  2125. id integer default nextval('opennmsnxtid') not null,
  2126. nodeid integer not null,
  2127. ospfIpAddr varchar(16),
  2128. ospfIpMask varchar(16),
  2129. ospfAddressLessIndex integer,
  2130. ospfIfIndex integer,
  2131. ospfRemRouterId varchar(16) not null,
  2132. ospfRemIpAddr varchar(16) not null,
  2133. ospfRemAddressLessIndex integer not null,
  2134. ospfLinkCreateTime timestamp not null,
  2135. ospfLinkLastPollTime timestamp not null,
  2136. constraint pk_ospflink_id primary key (id),
  2137. constraint fk_nodeIDospflink foreign key (nodeid) references node ON DELETE CASCADE
  2138. );
  2139. create table isisElement (
  2140. id integer default nextval('opennmsnxtid') not null,
  2141. nodeid integer not null,
  2142. isisSysID varchar(32) not null,
  2143. isisSysAdminState integer not null,
  2144. isisNodeCreateTime timestamp not null,
  2145. isisNodeLastPollTime timestamp not null,
  2146. constraint pk_isiselement_id primary key (id),
  2147. constraint fk_nodeIDisiselem foreign key (nodeid) references node ON DELETE CASCADE
  2148. );
  2149. create table isisLink (
  2150. id integer default nextval('opennmsnxtid') not null,
  2151. nodeid integer not null,
  2152. isisCircIndex integer not null,
  2153. isisISAdjIndex integer not null,
  2154. isisCircIfIndex integer,
  2155. isisCircAdminState integer,
  2156. isisISAdjState integer not null,
  2157. isisISAdjNeighSNPAAddress varchar(80) not null,
  2158. isisISAdjNeighSysType integer not null,
  2159. isisISAdjNeighSysID varchar(32) not null,
  2160. isisISAdjNbrExtendedCircID integer,
  2161. isisLinkCreateTime timestamp not null,
  2162. isisLinkLastPollTime timestamp not null,
  2163. constraint pk_isislink_id primary key (id),
  2164. constraint fk_nodeIDisislink foreign key (nodeid) references node ON DELETE CASCADE
  2165. );
  2166. create table ipNetToMedia (
  2167. id integer default nextval('opennmsNxtId') not null,
  2168. netAddress text not null,
  2169. physAddress varchar(32) not null,
  2170. sourceNodeId integer not null,
  2171. sourceIfIndex integer not null,
  2172. createTime timestamp not null,
  2173. lastPollTime timestamp not null,
  2174. constraint pk_ipnettomedia_id primary key (id),
  2175. constraint fk_sourcenodeid_ipnettomedia foreign key (sourcenodeid) references node (nodeid)
  2176. );
  2177. create table bridgeElement (
  2178. id integer default nextval('opennmsNxtId') not null,
  2179. nodeid integer not null,
  2180. baseBridgeAddress varchar(12) not null,
  2181. baseNumPorts integer not null,
  2182. basetype integer not null,
  2183. vlan integer,
  2184. vlanname varchar(64),
  2185. stpProtocolSpecification integer,
  2186. stpPriority integer,
  2187. stpdesignatedroot varchar(16),
  2188. stprootcost integer,
  2189. stprootport integer,
  2190. bridgeNodeCreateTime timestamp not null,
  2191. bridgeNodeLastPollTime timestamp not null,
  2192. constraint pk_bridgeelement_id primary key (id),
  2193. constraint fk_nodeIDbridgeelement foreign key (nodeid) references node on delete cascade
  2194. );
  2195. create table bridgeMacLink (
  2196. id integer default nextval('opennmsNxtId') not null,
  2197. nodeid integer not null,
  2198. bridgePort integer not null,
  2199. bridgePortIfIndex integer,
  2200. bridgePortIfName varchar(32),
  2201. vlan integer,
  2202. macAdreess varchar(12) not null,
  2203. bridgeMacLinkCreateTime timestamp not null,
  2204. bridgeMacLinkLastPollTime timestamp not null,
  2205. constraint pk_bridgemaclink_id primary key (id),
  2206. constraint fk_nodeIDbridgemaclink foreign key (nodeid) references node on delete cascade
  2207. );
  2208. create table bridgeBridgeLink (
  2209. id integer default nextval('opennmsNxtId') not null,
  2210. nodeid integer not null,
  2211. bridgePort integer,
  2212. bridgePortIfIndex integer,
  2213. bridgePortIfName varchar(32),
  2214. vlan integer,
  2215. designatedNodeid integer not null,
  2216. designatedPort integer,
  2217. designatedPortIfIndex integer,
  2218. designatedPortIfName varchar(32),
  2219. designatedVlan integer,
  2220. bridgeBridgeLinkCreateTime timestamp not null,
  2221. bridgeBridgeLinkLastPollTime timestamp not null,
  2222. constraint pk_bridgebridgelink_id primary key (id),
  2223. constraint fk_nodeIDbridgebridgelink foreign key (nodeid) references node on delete cascade,
  2224. constraint fk_desnodeIDbridgemaclink foreign key (designatednodeid) references node (nodeid)
  2225. );
  2226. create table bridgeStpLink (
  2227. id integer default nextval('opennmsNxtId') not null,
  2228. nodeid integer not null,
  2229. stpPort integer not null,
  2230. stpPortPriority integer not null,
  2231. stpPortState integer not null,
  2232. stpPortEnable integer not null,
  2233. stpPortPathCost integer not null,
  2234. stpPortIfIndex integer,
  2235. stpPortIfName varchar(32),
  2236. vlan integer,
  2237. designatedCost integer not null,
  2238. designatedRoot varchar(16) not null,
  2239. designatedBridge varchar(16) not null,
  2240. designatedPort varchar(4) not null,
  2241. bridgeStpLinkCreateTime timestamp not null,
  2242. bridgeStpLinkLastPollTime timestamp not null,
  2243. constraint pk_bridgestplink_id primary key (id),
  2244. constraint fk_nodeIDbridgestplink foreign key (nodeid) references node on delete cascade
  2245. );
  2246. --# End enlinkd table
  2247. --# Begin Quartz persistence tables
  2248. CREATE TABLE qrtz_job_details
  2249. (
  2250. JOB_NAME VARCHAR(80) NOT NULL,
  2251. JOB_GROUP VARCHAR(80) NOT NULL,
  2252. DESCRIPTION VARCHAR(120) NULL,
  2253. JOB_CLASS_NAME VARCHAR(128) NOT NULL,
  2254. IS_DURABLE BOOL NOT NULL,
  2255. IS_VOLATILE BOOL NOT NULL,
  2256. IS_STATEFUL BOOL NOT NULL,
  2257. REQUESTS_RECOVERY BOOL NOT NULL,
  2258. JOB_DATA BYTEA NOT NULL,
  2259. constraint qrtz_job_details_pkey PRIMARY KEY (JOB_NAME,JOB_GROUP)
  2260. );
  2261. CREATE TABLE qrtz_job_listeners
  2262. (
  2263. JOB_NAME VARCHAR(80) NOT NULL,
  2264. JOB_GROUP VARCHAR(80) NOT NULL,
  2265. JOB_LISTENER VARCHAR(80) NOT NULL,
  2266. constraint pk_qrtz_job_listeners PRIMARY KEY (JOB_NAME,JOB_GROUP,JOB_LISTENER),
  2267. constraint fk_qrtz_job_listeners FOREIGN KEY (JOB_NAME,JOB_GROUP)
  2268. REFERENCES QRTZ_JOB_DETAILS (JOB_NAME,JOB_GROUP)
  2269. );
  2270. CREATE TABLE qrtz_triggers
  2271. (
  2272. TRIGGER_NAME VARCHAR(80) NOT NULL,
  2273. TRIGGER_GROUP VARCHAR(80) NOT NULL,
  2274. JOB_NAME VARCHAR(80) NOT NULL,
  2275. JOB_GROUP VARCHAR(80) NOT NULL,
  2276. IS_VOLATILE BOOL NOT NULL,
  2277. DESCRIPTION VARCHAR(120),
  2278. NEXT_FIRE_TIME BIGINT,
  2279. PREV_FIRE_TIME BIGINT,
  2280. TRIGGER_STATE VARCHAR(16) NOT NULL,
  2281. TRIGGER_TYPE VARCHAR(8) NOT NULL,
  2282. START_TIME BIGINT NOT NULL,
  2283. END_TIME BIGINT,
  2284. CALENDAR_NAME VARCHAR(80),
  2285. MISFIRE_INSTR SMALLINT,
  2286. JOB_DATA BYTEA,
  2287. PRIORITY INTEGER,
  2288. constraint pk_qrtz_triggers PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
  2289. constraint fk_qrtz_triggers FOREIGN KEY (JOB_NAME,JOB_GROUP)
  2290. REFERENCES QRTZ_JOB_DETAILS (JOB_NAME,JOB_GROUP)
  2291. );
  2292. CREATE TABLE qrtz_simple_triggers
  2293. (
  2294. TRIGGER_NAME VARCHAR(80) NOT NULL,
  2295. TRIGGER_GROUP VARCHAR(80) NOT NULL,
  2296. REPEAT_COUNT BIGINT NOT NULL,
  2297. REPEAT_INTERVAL BIGINT NOT NULL,
  2298. TIMES_TRIGGERED BIGINT NOT NULL,
  2299. constraint pk_qrtz_simple_triggers PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
  2300. constraint fk_qrtz_simple_triggers FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
  2301. REFERENCES QRTZ_TRIGGERS (TRIGGER_NAME,TRIGGER_GROUP)
  2302. );
  2303. CREATE TABLE qrtz_cron_triggers
  2304. (
  2305. TRIGGER_NAME VARCHAR(80) NOT NULL,
  2306. TRIGGER_GROUP VARCHAR(80) NOT NULL,
  2307. CRON_EXPRESSION VARCHAR(80) NOT NULL,
  2308. TIME_ZONE_ID VARCHAR(80),
  2309. constraint pk_qrtz_cron_triggers PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
  2310. constraint fk_qrtz_cron_triggers FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
  2311. REFERENCES QRTZ_TRIGGERS (TRIGGER_NAME,TRIGGER_GROUP)
  2312. );
  2313. CREATE TABLE qrtz_blob_triggers
  2314. (
  2315. TRIGGER_NAME VARCHAR(80) NOT NULL,
  2316. TRIGGER_GROUP VARCHAR(80) NOT NULL,
  2317. BLOB_DATA BYTEA,
  2318. constraint pk_qrtz_blob_triggers PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
  2319. constraint fk_qrtz_blob_triggers FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
  2320. REFERENCES QRTZ_TRIGGERS (TRIGGER_NAME,TRIGGER_GROUP)
  2321. );
  2322. CREATE TABLE qrtz_trigger_listeners
  2323. (
  2324. TRIGGER_NAME VARCHAR(80) NOT NULL,
  2325. TRIGGER_GROUP VARCHAR(80) NOT NULL,
  2326. TRIGGER_LISTENER VARCHAR(80) NOT NULL,
  2327. constraint pk_qrtz_trigger_listeners PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_LISTENER),
  2328. constraint fk_qrtz_trigger_listeners FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
  2329. REFERENCES QRTZ_TRIGGERS (TRIGGER_NAME,TRIGGER_GROUP)
  2330. );
  2331. CREATE TABLE qrtz_calendars
  2332. (
  2333. CALENDAR_NAME VARCHAR(80) NOT NULL,
  2334. CALENDAR BYTEA NOT NULL,
  2335. constraint pk_qrtz_calendars PRIMARY KEY (CALENDAR_NAME)
  2336. );
  2337. CREATE TABLE qrtz_paused_trigger_grps
  2338. (
  2339. TRIGGER_GROUP VARCHAR(80) NOT NULL,
  2340. constraint pk_qrtz_paused_trigger_grps PRIMARY KEY (TRIGGER_GROUP)
  2341. );
  2342. CREATE TABLE qrtz_fired_triggers
  2343. (
  2344. ENTRY_ID VARCHAR(95) NOT NULL,
  2345. TRIGGER_NAME VARCHAR(80) NOT NULL,
  2346. TRIGGER_GROUP VARCHAR(80) NOT NULL,
  2347. IS_VOLATILE BOOL NOT NULL,
  2348. INSTANCE_NAME VARCHAR(80) NOT NULL,
  2349. FIRED_TIME BIGINT NOT NULL,
  2350. STATE VARCHAR(16) NOT NULL,
  2351. JOB_NAME VARCHAR(80),
  2352. JOB_GROUP VARCHAR(80),
  2353. IS_STATEFUL BOOL,
  2354. REQUESTS_RECOVERY BOOL,
  2355. PRIORITY INTEGER,
  2356. constraint pk_qrtz_fired_triggers PRIMARY KEY (ENTRY_ID)
  2357. );
  2358. CREATE TABLE qrtz_scheduler_state
  2359. (
  2360. INSTANCE_NAME VARCHAR(80) NOT NULL,
  2361. LAST_CHECKIN_TIME BIGINT NOT NULL,
  2362. CHECKIN_INTERVAL BIGINT NOT NULL,
  2363. RECOVERER VARCHAR(80),
  2364. constraint pk_qrtz_scheduler_state PRIMARY KEY (INSTANCE_NAME)
  2365. );
  2366. CREATE TABLE qrtz_locks
  2367. (
  2368. LOCK_NAME VARCHAR(40) NOT NULL,
  2369. constraint pk_qrtz_locks PRIMARY KEY (LOCK_NAME)
  2370. );
  2371. --##################################################################
  2372. --# The following command should populate the qrtz_locks table
  2373. --# are no categories in the category table
  2374. --##################################################################
  2375. --# criteria: SELECT count(*) = 0 from qrtz_locks
  2376. insert into qrtz_locks values('TRIGGER_ACCESS');
  2377. --# criteria: SELECT count(*) = 0 from qrtz_locks
  2378. insert into qrtz_locks values('JOB_ACCESS');
  2379. --# criteria: SELECT count(*) = 0 from qrtz_locks
  2380. insert into qrtz_locks values('CALENDAR_ACCESS');
  2381. --# criteria: SELECT count(*) = 0 from qrtz_locks
  2382. insert into qrtz_locks values('STATE_ACCESS');
  2383. --# criteria: SELECT count(*) = 0 from qrtz_locks
  2384. insert into qrtz_locks values('MISFIRE_ACCESS');
  2385. --# End Quartz persistence tables
  2386. create table accesspoints (
  2387. physaddr varchar(32) NOT NULL UNIQUE,
  2388. nodeid integer NOT NULL,
  2389. pollingpackage varchar(256) NOT NULL,
  2390. status integer,
  2391. controlleripaddr varchar(40),
  2392. CONSTRAINT pk_physaddr primary key (physaddr)
  2393. );
  2394. create index accesspoint_package_idx on accesspoints(pollingpackage);
  2395. --##################################################################
  2396. --# The following command should populate the filterfavorites table
  2397. --##################################################################
  2398. CREATE TABLE filterfavorites (
  2399. filterid INTEGER NOT NULL,
  2400. username VARCHAR(50) NOT NULL,
  2401. filtername VARCHAR(50) NOT NULL,
  2402. page VARCHAR(25) NOT NULL,
  2403. filter VARCHAR(255) NOT NULL,
  2404. CONSTRAINT pk_filterid PRIMARY KEY (filterid)
  2405. );
  2406. CREATE INDEX filternamesidx ON filterfavorites (username, filtername, page);