Make host 'check' attribute available in legacy interfaces.

Fixes #5764
This commit is contained in:
Michael Friedrich 2014-03-21 17:57:24 +01:00
parent c9590d5183
commit 23c47dd430
10 changed files with 49 additions and 10 deletions

View File

@ -207,8 +207,11 @@ void StatusDataWriter::DumpHostStatus(std::ostream& fp, const Host::Ptr& host)
Service::Ptr hc = host->GetCheckService();
ObjectLock olock(hc);
if (hc)
if (hc) {
/* only dump status data information for Classic UI */
fp << "\t" "check_service=" << hc->GetShortName() << "\n";
DumpServiceStatusAttrs(fp, hc, CompatTypeHost);
}
/* ugly but cgis parse only that */
fp << "\t" "last_time_up=" << host->GetLastStateUp() << "\n"

View File

@ -1398,6 +1398,7 @@ 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_hosts ADD COLUMN check_service_object_id bigint default NULL;
-- -----------------------------------------
-- add index (delete)

View File

@ -0,0 +1,2 @@
ALTER TABLE icinga_hosts ADD COLUMN check_service_object_id bigint default NULL;

View File

@ -1426,6 +1426,7 @@ 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_hosts ADD COLUMN check_service_object_id bigint default NULL;
-- -----------------------------------------
-- add index (delete)

View File

@ -0,0 +1,2 @@
ALTER TABLE icinga_hosts ADD COLUMN check_service_object_id bigint default NULL;

View File

@ -157,6 +157,7 @@ void HostsTable::AddColumns(Table *table, const String& prefix,
table->AddColumn(prefix + "services", Column(&HostsTable::ServicesAccessor, objectAccessor));
table->AddColumn(prefix + "services_with_state", Column(&HostsTable::ServicesWithStateAccessor, objectAccessor));
table->AddColumn(prefix + "services_with_info", Column(&HostsTable::ServicesWithInfoAccessor, objectAccessor));
table->AddColumn(prefix + "check_service", Column(&HostsTable::CheckServiceAccessor, objectAccessor));
}
String HostsTable::GetName(void) const
@ -1854,3 +1855,20 @@ Value HostsTable::ServicesWithInfoAccessor(const Value& row)
return services;
}
Value HostsTable::CheckServiceAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
if (!host)
return Empty;
Service::Ptr hc = host->GetCheckService();
Array::Ptr services = make_shared<Array>();
if (!hc)
return Empty;
return hc->GetShortName();
}

View File

@ -141,9 +141,9 @@ protected:
static Value GroupsAccessor(const Value& row);
static Value ContactGroupsAccessor(const Value& row);
static Value ServicesAccessor(const Value& row);
static Value ServicesWithStateAccessor(const Value& row);
static Value ServicesWithInfoAccessor(const Value& row);
static Value CheckServiceAccessor(const Value& row);
};
}

View File

@ -1,6 +1,15 @@
## <a id="schemas"></a> Schemas
### <a id="schema-status-dat"></a> Status Data
Changes require newest Icinga Classic UI releases.
Object | Key
------------|--------------
hoststatus | check_service
### <a id="schema-db-ido"></a> DB IDO
There is a detailed documentation for the Icinga IDOUtils 1.x
@ -27,13 +36,14 @@ New tables: `endpoints`, `endpointstatus`
New columns:
Table | Column | Type | Default | Description
--------------------|--------------------|----------|---------|-------------
all status/history | endpoint_object_id | bigint | NULL | FK: objects table
servicestatus | check_source | TEXT | NULL | node name where check was executed
hoststatus | check_source | TEXT | NULL | node name where check was executed
statehistory | check_source | TEXT | NULL | node name where check was executed
logentries | object_id | bigint | NULL | FK: objects table (service associated with column)
Table | Column | Type | Default | Description
--------------------|-------------------------|----------|---------|-------------
all status/history | endpoint_object_id | bigint | NULL | FK: objects table
servicestatus | check_source | TEXT | NULL | node name where check was executed
hoststatus | check_source | TEXT | NULL | node name where check was executed
statehistory | check_source | TEXT | NULL | node name where check was executed
logentries | object_id | bigint | NULL | FK: objects table (service associated with column)
hosts | check_service_object_id | bigint | NULL | FK: objects table (service associated with column)
@ -175,5 +185,6 @@ New columns:
Table | Column
----------|--------------
services | check_source
hosts | check_service
downtimes | triggers
downtimes | trigger_time

View File

@ -51,6 +51,7 @@ Dictionary::Ptr HostDbObject::GetConfigFields(void) const
fields->Set("address6", CompatUtility::GetHostAddress6(host));
if (service) {
fields->Set("check_service_object_id", service);
fields->Set("check_command_object_id", service->GetCheckCommand());
fields->Set("check_command_args", Empty);
fields->Set("eventhandler_command_object_id", service->GetEventCommand());

View File

@ -1,4 +1,4 @@
GET hosts
Columns: name parents childs
Columns: name parents childs check_service
ResponseHeader: fixed16