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`
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:
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)
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")
DbObjectTypeContactGroup = 11,
DbObjectTypeCommand = 12,
DbObjectTypeEndpoint = 13,
+ DbObjectTypeZone = 14,
};
/**
fields->Set("identity", endpoint->GetName());
fields->Set("node", IcingaApplication::GetInstance()->GetNodeName());
+ fields->Set("zone_object_id", endpoint->GetZone());
return fields;
}
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;
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);
--- /dev/null
+/******************************************************************************
+ * 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;
+}
--- /dev/null
+/******************************************************************************
+ * 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 */
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,
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,
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;
-- 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
-- -----------------------------------------
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,
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,
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;
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
-- -----------------------------------------