mirror of https://github.com/Icinga/icinga2.git
parent
c8d129bf9f
commit
a788de679c
|
@ -168,6 +168,7 @@ New table: `endpointstatus`
|
|||
endpoints | endpoint_object_id | bigint | NULL | FK: objects table
|
||||
endpoints | identity | TEXT | NULL | endpoint name
|
||||
endpoints | node | TEXT | NULL | local node name
|
||||
endpoints | zone_object_id | bigint | NULL | zone object where this endpoint is a member of
|
||||
|
||||
New table: `endpointstatus`
|
||||
|
||||
|
@ -177,6 +178,16 @@ New table: `endpointstatus`
|
|||
endpointstatus | identity | TEXT | NULL | endpoint name
|
||||
endpointstatus | node | TEXT | NULL | local node name
|
||||
endpointstatus | is_connected | smallint | 0 | update on endpoint connect/disconnect
|
||||
endpointstatus | zone_object_id | bigint | NULL | zone object where this endpoint is a member of
|
||||
|
||||
New tables: `zones` and `zonestatus`:
|
||||
|
||||
Table | Column | Type | Default | Description
|
||||
--------------------|--------------------|----------|---------|-------------
|
||||
zones | zone_object_id | bigint | NULL | FK: objects table
|
||||
zones | parent_zone_object_id | bigint | NULL | FK: zones table
|
||||
zones | is_global | smallint | 0 | zone is global
|
||||
|
||||
|
||||
New columns:
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ set(db_ido_SOURCES
|
|||
dbreference.cpp dbtype.cpp dbvalue.cpp endpointdbobject.cpp hostdbobject.cpp
|
||||
hostgroupdbobject.cpp idochecktask.cpp servicedbobject.cpp
|
||||
servicegroupdbobject.cpp timeperioddbobject.cpp userdbobject.cpp
|
||||
usergroupdbobject.cpp
|
||||
usergroupdbobject.cpp zonedbobject.cpp
|
||||
)
|
||||
|
||||
if(ICINGA2_UNITY_BUILD)
|
||||
|
|
|
@ -122,8 +122,8 @@ void DbObject::SendStatusUpdate(void)
|
|||
query.Fields = fields;
|
||||
query.Fields->Set(GetType()->GetIDColumn(), GetObject());
|
||||
|
||||
/* do not override our own endpoint dbobject id */
|
||||
if (GetType()->GetTable() != "endpoint") {
|
||||
/* do not override endpoint_object_id for endpoints & zones */
|
||||
if (query.Table != "endpointstatus" && query.Table != "zonestatus") {
|
||||
String node = IcingaApplication::GetInstance()->GetNodeName();
|
||||
|
||||
Log(LogDebug, "DbObject")
|
||||
|
|
|
@ -51,6 +51,7 @@ enum DbObjectType
|
|||
DbObjectTypeContactGroup = 11,
|
||||
DbObjectTypeCommand = 12,
|
||||
DbObjectTypeEndpoint = 13,
|
||||
DbObjectTypeZone = 14,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,6 +53,7 @@ Dictionary::Ptr EndpointDbObject::GetConfigFields(void) const
|
|||
|
||||
fields->Set("identity", endpoint->GetName());
|
||||
fields->Set("node", IcingaApplication::GetInstance()->GetNodeName());
|
||||
fields->Set("zone_object_id", endpoint->GetZone());
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ Dictionary::Ptr EndpointDbObject::GetStatusFields(void) const
|
|||
|
||||
fields->Set("identity", endpoint->GetName());
|
||||
fields->Set("node", IcingaApplication::GetInstance()->GetNodeName());
|
||||
fields->Set("zone_object_id", endpoint->GetZone());
|
||||
fields->Set("is_connected", EndpointIsConnected(endpoint));
|
||||
|
||||
return fields;
|
||||
|
@ -120,6 +122,7 @@ void EndpointDbObject::OnConfigUpdate(void)
|
|||
Dictionary::Ptr fields1 = new Dictionary();
|
||||
fields1->Set("identity", endpoint->GetName());
|
||||
fields1->Set("node", IcingaApplication::GetInstance()->GetNodeName());
|
||||
fields1->Set("zone_object_id", endpoint->GetZone());
|
||||
fields1->Set("is_connected", EndpointIsConnected(endpoint));
|
||||
fields1->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
|
||||
fields1->Set("endpoint_object_id", endpoint);
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "db_ido/zonedbobject.hpp"
|
||||
#include "db_ido/dbtype.hpp"
|
||||
#include "db_ido/dbvalue.hpp"
|
||||
#include "base/logger.hpp"
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
||||
REGISTER_DBTYPE(Zone, "zone", DbObjectTypeZone, "zone_object_id", ZoneDbObject);
|
||||
|
||||
ZoneDbObject::ZoneDbObject(const DbType::Ptr& type, const String& name1, const String& name2)
|
||||
: DbObject(type, name1, name2)
|
||||
{ }
|
||||
|
||||
Dictionary::Ptr ZoneDbObject::GetConfigFields(void) const
|
||||
{
|
||||
Dictionary::Ptr fields = new Dictionary();
|
||||
Zone::Ptr zone = static_pointer_cast<Zone>(GetObject());
|
||||
|
||||
fields->Set("is_global", zone->IsGlobal() ? 1 : 0);
|
||||
fields->Set("parent_zone_object_id", zone->GetParent());
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
Dictionary::Ptr ZoneDbObject::GetStatusFields(void) const
|
||||
{
|
||||
Zone::Ptr zone = static_pointer_cast<Zone>(GetObject());
|
||||
|
||||
Log(LogDebug, "ZoneDbObject")
|
||||
<< "update status for zone '" << zone->GetName() << "'";
|
||||
|
||||
Dictionary::Ptr fields = new Dictionary();
|
||||
fields->Set("parent_zone_object_id", zone->GetParent());
|
||||
|
||||
return fields;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ZONEDBOBJECT_H
|
||||
#define ZONEDBOBJECT_H
|
||||
|
||||
#include "db_ido/dbobject.hpp"
|
||||
#include "base/dynamicobject.hpp"
|
||||
#include "remote/zone.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* An Endpoint database object.
|
||||
*
|
||||
* @ingroup ido
|
||||
*/
|
||||
class ZoneDbObject : public DbObject
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(ZoneDbObject);
|
||||
|
||||
ZoneDbObject(const intrusive_ptr<DbType>& type, const String& name1, const String& name2);
|
||||
|
||||
virtual Dictionary::Ptr GetConfigFields(void) const;
|
||||
virtual Dictionary::Ptr GetStatusFields(void) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ZONEDBOBJECT_H */
|
|
@ -1362,6 +1362,7 @@ CREATE TABLE IF NOT EXISTS icinga_endpoints (
|
|||
endpoint_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
instance_id bigint unsigned default 0,
|
||||
endpoint_object_id bigint(20) unsigned DEFAULT '0',
|
||||
zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
config_type smallint(6) DEFAULT '0',
|
||||
identity varchar(255) DEFAULT NULL,
|
||||
node varchar(255) DEFAULT NULL,
|
||||
|
@ -1378,6 +1379,7 @@ CREATE TABLE IF NOT EXISTS icinga_endpointstatus (
|
|||
endpointstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
instance_id bigint unsigned default 0,
|
||||
endpoint_object_id bigint(20) unsigned DEFAULT '0',
|
||||
zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
identity varchar(255) DEFAULT NULL,
|
||||
node varchar(255) DEFAULT NULL,
|
||||
|
@ -1385,6 +1387,37 @@ CREATE TABLE IF NOT EXISTS icinga_endpointstatus (
|
|||
PRIMARY KEY (endpointstatus_id)
|
||||
) ENGINE=InnoDB COMMENT='Endpoint status';
|
||||
|
||||
--
|
||||
-- Table structure for table icinga_zones
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS icinga_zones (
|
||||
zone_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
instance_id bigint unsigned default 0,
|
||||
zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
config_type smallint(6) DEFAULT '0',
|
||||
parent_zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
is_global smallint(6),
|
||||
PRIMARY KEY (zone_id)
|
||||
) ENGINE=InnoDB COMMENT='Zone configuration';
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table icinga_zonestatus
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS icinga_zonestatus (
|
||||
zonestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
instance_id bigint unsigned default 0,
|
||||
zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
parent_zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
PRIMARY KEY (zonestatus_id)
|
||||
) ENGINE=InnoDB COMMENT='Zone status';
|
||||
|
||||
|
||||
|
||||
|
||||
ALTER TABLE icinga_servicestatus ADD COLUMN endpoint_object_id bigint default NULL;
|
||||
ALTER TABLE icinga_hoststatus ADD COLUMN endpoint_object_id bigint default NULL;
|
||||
|
|
|
@ -7,6 +7,30 @@
|
|||
-- Please check http://docs.icinga.org for upgrading information!
|
||||
-- -----------------------------------------
|
||||
|
||||
|
||||
ALTER TABLE icinga_endpoints ADD COLUMN zone_object_id bigint(20) unsigned DEFAULT '0';
|
||||
ALTER TABLE icinga_endpointstatus ADD COLUMN zone_object_id bigint(20) unsigned DEFAULT '0';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS icinga_zones (
|
||||
zone_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
instance_id bigint unsigned default 0,
|
||||
zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
config_type smallint(6) DEFAULT '0',
|
||||
parent_zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
is_global smallint(6),
|
||||
PRIMARY KEY (zone_id)
|
||||
) ENGINE=InnoDB COMMENT='Zone configuration';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS icinga_zonestatus (
|
||||
zonestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
instance_id bigint unsigned default 0,
|
||||
zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
parent_zone_object_id bigint(20) unsigned DEFAULT '0',
|
||||
PRIMARY KEY (zonestatus_id)
|
||||
) ENGINE=InnoDB COMMENT='Zone status';
|
||||
|
||||
|
||||
-- -----------------------------------------
|
||||
-- update dbversion
|
||||
-- -----------------------------------------
|
||||
|
|
|
@ -1388,6 +1388,7 @@ CREATE TABLE icinga_endpoints (
|
|||
endpoint_id bigserial,
|
||||
instance_id bigint default 0,
|
||||
endpoint_object_id bigint default 0,
|
||||
zone_object_id bigint default 0,
|
||||
config_type integer default 0,
|
||||
identity text DEFAULT NULL,
|
||||
node text DEFAULT NULL,
|
||||
|
@ -1405,6 +1406,7 @@ CREATE TABLE icinga_endpointstatus (
|
|||
endpointstatus_id bigserial,
|
||||
instance_id bigint default 0,
|
||||
endpoint_object_id bigint default 0,
|
||||
zone_object_id bigint default 0,
|
||||
status_update_time timestamp with time zone default '1970-01-01 00:00:00+00',
|
||||
identity text DEFAULT NULL,
|
||||
node text DEFAULT NULL,
|
||||
|
@ -1413,6 +1415,37 @@ CREATE TABLE icinga_endpointstatus (
|
|||
CONSTRAINT UQ_endpointstatus UNIQUE (endpoint_object_id)
|
||||
) ;
|
||||
|
||||
--
|
||||
-- Table structure for table icinga_zones
|
||||
--
|
||||
|
||||
CREATE TABLE icinga_zones (
|
||||
zone_id bigserial,
|
||||
instance_id bigint default 0,
|
||||
zone_object_id bigint default 0,
|
||||
parent_zone_object_id bigint default 0,
|
||||
config_type integer default 0,
|
||||
is_global integer default 0,
|
||||
CONSTRAINT PK_zone_id PRIMARY KEY (zone_id) ,
|
||||
CONSTRAINT UQ_zones UNIQUE (instance_id,config_type,zone_object_id)
|
||||
) ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table icinga_zonestatus
|
||||
--
|
||||
|
||||
CREATE TABLE icinga_zonestatus (
|
||||
zonestatus_id bigserial,
|
||||
instance_id bigint default 0,
|
||||
zone_object_id bigint default 0,
|
||||
parent_zone_object_id bigint default 0,
|
||||
status_update_time timestamp with time zone default '1970-01-01 00:00:00+00',
|
||||
CONSTRAINT PK_zonestatus_id PRIMARY KEY (zonestatus_id) ,
|
||||
CONSTRAINT UQ_zonestatus UNIQUE (zone_object_id)
|
||||
) ;
|
||||
|
||||
|
||||
ALTER TABLE icinga_servicestatus ADD COLUMN endpoint_object_id bigint default NULL;
|
||||
ALTER TABLE icinga_hoststatus ADD COLUMN endpoint_object_id bigint default NULL;
|
||||
|
|
|
@ -123,6 +123,34 @@ ALTER TABLE icinga_endpointstatus ALTER COLUMN status_update_time SET DEFAULT '1
|
|||
ALTER TABLE icinga_statehistory ALTER COLUMN check_source TYPE TEXT;
|
||||
ALTER TABLE icinga_statehistory ALTER COLUMN check_source SET default '';
|
||||
|
||||
-- -----------------------------------------
|
||||
-- #9286 zones table
|
||||
-- -----------------------------------------
|
||||
|
||||
ALTER TABLE icinga_endpoints ADD COLUMN zone_object_id bigint default 0;
|
||||
ALTER TABLE icinga_endpointstatus ADD COLUMN zone_object_id bigint default 0;
|
||||
|
||||
CREATE TABLE icinga_zones (
|
||||
zone_id bigserial,
|
||||
instance_id bigint default 0,
|
||||
zone_object_id bigint default 0,
|
||||
parent_zone_object_id bigint default 0,
|
||||
config_type integer default 0,
|
||||
is_global integer default 0,
|
||||
CONSTRAINT PK_zone_id PRIMARY KEY (zone_id) ,
|
||||
CONSTRAINT UQ_zones UNIQUE (instance_id,config_type,zone_object_id)
|
||||
) ;
|
||||
|
||||
CREATE TABLE icinga_zonestatus (
|
||||
zonestatus_id bigserial,
|
||||
instance_id bigint default 0,
|
||||
zone_object_id bigint default 0,
|
||||
parent_zone_object_id bigint default 0,
|
||||
status_update_time timestamp with time zone default '1970-01-01 00:00:00+00',
|
||||
CONSTRAINT PK_zonestatus_id PRIMARY KEY (zonestatus_id) ,
|
||||
CONSTRAINT UQ_zonestatus UNIQUE (zone_object_id)
|
||||
) ;
|
||||
|
||||
-- -----------------------------------------
|
||||
-- update dbversion
|
||||
-- -----------------------------------------
|
||||
|
|
Loading…
Reference in New Issue