From f5e568d3fb65f91fc633621feff21aeb10037986 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sat, 10 May 2014 21:03:47 +0200 Subject: [PATCH] DB IDO: Add 'is_reachable' column to {host,service}status tables. Refs #6094 --- components/db_ido_mysql/schema/mysql.sql | 2 ++ components/db_ido_mysql/schema/upgrade/0.0.11.sql | 8 ++++++++ components/db_ido_pgsql/schema/pgsql.sql | 2 ++ components/db_ido_pgsql/schema/upgrade/0.0.11.sql | 8 ++++++++ lib/db_ido/hostdbobject.cpp | 1 + lib/db_ido/servicedbobject.cpp | 1 + lib/icinga/compatutility.cpp | 5 +++++ lib/icinga/compatutility.h | 1 + 8 files changed, 28 insertions(+) create mode 100644 components/db_ido_mysql/schema/upgrade/0.0.11.sql create mode 100644 components/db_ido_pgsql/schema/upgrade/0.0.11.sql diff --git a/components/db_ido_mysql/schema/mysql.sql b/components/db_ido_mysql/schema/mysql.sql index a462e2a55..119d5fda6 100644 --- a/components/db_ido_mysql/schema/mysql.sql +++ b/components/db_ido_mysql/schema/mysql.sql @@ -747,6 +747,7 @@ CREATE TABLE IF NOT EXISTS icinga_hoststatus ( normal_check_interval double default '0', retry_check_interval double default '0', check_timeperiod_object_id bigint unsigned default 0, + is_reachable smallint default 0, PRIMARY KEY (hoststatus_id), UNIQUE KEY object_id (host_object_id) ) ENGINE=InnoDB COMMENT='Current host status information'; @@ -1230,6 +1231,7 @@ CREATE TABLE IF NOT EXISTS icinga_servicestatus ( normal_check_interval double default '0', retry_check_interval double default '0', check_timeperiod_object_id bigint unsigned default 0, + is_reachable smallint default 0, PRIMARY KEY (servicestatus_id), UNIQUE KEY object_id (service_object_id) ) ENGINE=InnoDB COMMENT='Current service status information'; diff --git a/components/db_ido_mysql/schema/upgrade/0.0.11.sql b/components/db_ido_mysql/schema/upgrade/0.0.11.sql new file mode 100644 index 000000000..5c30f67e6 --- /dev/null +++ b/components/db_ido_mysql/schema/upgrade/0.0.11.sql @@ -0,0 +1,8 @@ + + +-- ----------------------------------------- +-- #6094 +-- ----------------------------------------- + +ALTER TABLE icinga_hoststatus ADD COLUMN is_reachable smallint(6) DEFAULT NULL; +ALTER TABLE icinga_servicestatus ADD COLUMN is_reachable smallint(6) DEFAULT NULL; diff --git a/components/db_ido_pgsql/schema/pgsql.sql b/components/db_ido_pgsql/schema/pgsql.sql index f568ca8cc..bc106e8e9 100644 --- a/components/db_ido_pgsql/schema/pgsql.sql +++ b/components/db_ido_pgsql/schema/pgsql.sql @@ -773,6 +773,7 @@ CREATE TABLE icinga_hoststatus ( normal_check_interval double precision default 0, retry_check_interval double precision default 0, check_timeperiod_object_id bigint default 0, + is_reachable INTEGER default 0, CONSTRAINT PK_hoststatus_id PRIMARY KEY (hoststatus_id) , CONSTRAINT UQ_hoststatus UNIQUE (host_object_id) ) ; @@ -1256,6 +1257,7 @@ CREATE TABLE icinga_servicestatus ( normal_check_interval double precision default 0, retry_check_interval double precision default 0, check_timeperiod_object_id bigint default 0, + is_reachable INTEGER default 0, CONSTRAINT PK_servicestatus_id PRIMARY KEY (servicestatus_id) , CONSTRAINT UQ_servicestatus UNIQUE (service_object_id) ) ; diff --git a/components/db_ido_pgsql/schema/upgrade/0.0.11.sql b/components/db_ido_pgsql/schema/upgrade/0.0.11.sql new file mode 100644 index 000000000..f2c4894ee --- /dev/null +++ b/components/db_ido_pgsql/schema/upgrade/0.0.11.sql @@ -0,0 +1,8 @@ + + +-- ----------------------------------------- +-- #6094 +-- ----------------------------------------- + +ALTER TABLE icinga_hoststatus ADD COLUMN is_reachable INTEGER default 0; +ALTER TABLE icinga_servicestatus ADD COLUMN is_reachable INTEGER default 0; diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index 9b88bc6b5..6fd0cfb67 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -167,6 +167,7 @@ Dictionary::Ptr HostDbObject::GetStatusFields(void) const fields->Set("normal_check_interval", CompatUtility::GetCheckableCheckInterval(host)); fields->Set("retry_check_interval", CompatUtility::GetCheckableRetryInterval(host)); fields->Set("check_timeperiod_object_id", host->GetCheckPeriod()); + fields->Set("is_reachable", CompatUtility::GetCheckableIsReachable(host)); return fields; } diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index 7b3434807..68946b2a9 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -161,6 +161,7 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields(void) const fields->Set("retry_check_interval", CompatUtility::GetCheckableRetryInterval(service)); fields->Set("check_timeperiod_object_id", service->GetCheckPeriod()); fields->Set("modified_service_attributes", service->GetModifiedAttributes()); + fields->Set("is_reachable", CompatUtility::GetCheckableIsReachable(service)); return fields; } diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index eac272aa2..218a4fcbc 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -216,6 +216,11 @@ int CompatUtility::GetCheckableIsFlapping(const Checkable::Ptr& checkable) return (checkable->IsFlapping() ? 1 : 0); } +int CompatUtility::GetCheckableIsReachable(const Checkable::Ptr& checkable) +{ + return (checkable->IsReachable() ? 1 : 0); +} + String CompatUtility::GetCheckablePercentStateChange(const Checkable::Ptr& checkable) { return Convert::ToString(checkable->GetFlappingCurrent()); diff --git a/lib/icinga/compatutility.h b/lib/icinga/compatutility.h index f7b6e7d13..f51e845cf 100644 --- a/lib/icinga/compatutility.h +++ b/lib/icinga/compatutility.h @@ -59,6 +59,7 @@ public: static int GetCheckableEventHandlerEnabled(const Checkable::Ptr& checkable); static int GetCheckableFlapDetectionEnabled(const Checkable::Ptr& checkable); static int GetCheckableIsFlapping(const Checkable::Ptr& checkable); + static int GetCheckableIsReachable(const Checkable::Ptr& checkable); static String GetCheckablePercentStateChange(const Checkable::Ptr& checkable); static int GetCheckableProcessPerformanceData(const Checkable::Ptr& checkable);