Skip to content

Commit

Permalink
DB IDO: Add check_source_object_id reference to endpoint objects.
Browse files Browse the repository at this point in the history
Refs #5810
Refs #5636
  • Loading branch information
Michael Friedrich committed Mar 20, 2014
1 parent b4f0148 commit a26df23
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions components/db_ido_mysql/schema/mysql.sql
Expand Up @@ -1398,6 +1398,10 @@ ALTER TABLE icinga_servicechecks ADD COLUMN endpoint_object_id bigint default NU
ALTER TABLE icinga_statehistory ADD COLUMN endpoint_object_id bigint default NULL;
ALTER TABLE icinga_systemcommands ADD COLUMN endpoint_object_id bigint default NULL;

ALTER TABLE icinga_servicestatus ADD COLUMN check_source_object_id bigint default NULL;
ALTER TABLE icinga_hoststatus ADD COLUMN check_source_object_id bigint default NULL;
ALTER TABLE icinga_statehistory ADD COLUMN check_source_object_id bigint default NULL;


-- -----------------------------------------
-- add index (delete)
Expand Down
4 changes: 4 additions & 0 deletions components/db_ido_mysql/schema/upgrade/0.0.9.sql
@@ -0,0 +1,4 @@

ALTER TABLE icinga_servicestatus ADD COLUMN check_source_object_id bigint default NULL;
ALTER TABLE icinga_hoststatus ADD COLUMN check_source_object_id bigint default NULL;
ALTER TABLE icinga_statehistory ADD COLUMN check_source_object_id bigint default NULL;
3 changes: 3 additions & 0 deletions components/db_ido_pgsql/schema/pgsql.sql
Expand Up @@ -1426,6 +1426,9 @@ ALTER TABLE icinga_servicechecks ADD COLUMN endpoint_object_id bigint default NU
ALTER TABLE icinga_statehistory ADD COLUMN endpoint_object_id bigint default NULL;
ALTER TABLE icinga_systemcommands ADD COLUMN endpoint_object_id bigint default NULL;

ALTER TABLE icinga_servicestatus ADD COLUMN check_source_object_id bigint default NULL;
ALTER TABLE icinga_hoststatus ADD COLUMN check_source_object_id bigint default NULL;
ALTER TABLE icinga_statehistory ADD COLUMN check_source_object_id bigint default NULL;

-- -----------------------------------------
-- add index (delete)
Expand Down
5 changes: 5 additions & 0 deletions components/db_ido_pgsql/schema/upgrade/0.0.9.sql
@@ -0,0 +1,5 @@

ALTER TABLE icinga_servicestatus ADD COLUMN check_source_object_id bigint default NULL;
ALTER TABLE icinga_hoststatus ADD COLUMN check_source_object_id bigint default NULL;
ALTER TABLE icinga_statehistory ADD COLUMN check_source_object_id bigint default NULL;

18 changes: 16 additions & 2 deletions lib/db_ido/servicedbobject.cpp
Expand Up @@ -145,7 +145,14 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields(void) const
fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
fields->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
fields->Set("perfdata", CompatUtility::GetCheckResultPerfdata(cr));
fields->Set("check_source", cr->GetCheckSource());

String check_source = cr->GetCheckSource();
fields->Set("check_source", check_source);

Endpoint::Ptr check_endpoint = Endpoint::GetByName(check_source);

if(check_endpoint)
fields->Set("check_source_object_id", check_endpoint);
}

fields->Set("current_state", CompatUtility::GetServiceCurrentState(service));
Expand Down Expand Up @@ -887,7 +894,14 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const C
if (cr) {
fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
fields1->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
fields1->Set("check_source", cr->GetCheckSource());

String check_source = cr->GetCheckSource();
fields1->Set("check_source", check_source);

Endpoint::Ptr check_endpoint = Endpoint::GetByName(check_source);

if(check_endpoint)
fields1->Set("check_source_object_id", check_endpoint);
}

fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
Expand Down

0 comments on commit a26df23

Please sign in to comment.