diff --git a/components/compat/statusdatawriter.cpp b/components/compat/statusdatawriter.cpp index d45dc1317..ea9fe5515 100644 --- a/components/compat/statusdatawriter.cpp +++ b/components/compat/statusdatawriter.cpp @@ -564,9 +564,23 @@ void StatusDataWriter::UpdateObjectsCache(void) std::ostringstream tempobjectfp; tempobjectfp << std::fixed; + String display_name = hg->GetDisplayName(); + String notes = hg->GetNotes(); + String notes_url = hg->GetNotesUrl(); + String action_url = hg->GetActionUrl(); + tempobjectfp << "define hostgroup {" "\n" "\t" "hostgroup_name" "\t" << hg->GetName() << "\n"; + if (!display_name.IsEmpty()) + tempobjectfp << "\t" "alias" "\t" << display_name << "\n"; + if (!notes.IsEmpty()) + tempobjectfp << "\t" "notes" "\t" << notes << "\n"; + if (!notes_url.IsEmpty()) + tempobjectfp << "\t" "notes_url" "\t" << notes_url << "\n"; + if (!action_url.IsEmpty()) + tempobjectfp << "\t" "action_url" "\t" << action_url << "\n"; + DumpCustomAttributes(tempobjectfp, hg); tempobjectfp << "\t" "members" "\t"; @@ -581,9 +595,23 @@ void StatusDataWriter::UpdateObjectsCache(void) std::ostringstream tempobjectfp; tempobjectfp << std::fixed; + String display_name = sg->GetDisplayName(); + String notes = sg->GetNotes(); + String notes_url = sg->GetNotesUrl(); + String action_url = sg->GetActionUrl(); + tempobjectfp << "define servicegroup {" "\n" "\t" "servicegroup_name" "\t" << sg->GetName() << "\n"; + if (!display_name.IsEmpty()) + tempobjectfp << "\t" "alias" "\t" << display_name << "\n"; + if (!notes.IsEmpty()) + tempobjectfp << "\t" "notes" "\t" << notes << "\n"; + if (!notes_url.IsEmpty()) + tempobjectfp << "\t" "notes_url" "\t" << notes_url << "\n"; + if (!action_url.IsEmpty()) + tempobjectfp << "\t" "action_url" "\t" << action_url << "\n"; + DumpCustomAttributes(tempobjectfp, sg); tempobjectfp << "\t" "members" "\t"; diff --git a/components/db_ido_mysql/schema/mysql.sql b/components/db_ido_mysql/schema/mysql.sql index 06d2dd807..a462e2a55 100644 --- a/components/db_ido_mysql/schema/mysql.sql +++ b/components/db_ido_mysql/schema/mysql.sql @@ -600,6 +600,9 @@ CREATE TABLE IF NOT EXISTS icinga_hostgroups ( config_type smallint default 0, hostgroup_object_id bigint unsigned default 0, alias TEXT character set latin1 default '', + notes TEXT character set latin1 default NULL, + notes_url TEXT character set latin1 default NULL, + action_url TEXT character set latin1 default NULL, PRIMARY KEY (hostgroup_id), UNIQUE KEY instance_id (instance_id,hostgroup_object_id) ) ENGINE=InnoDB COMMENT='Hostgroup definitions'; @@ -1086,6 +1089,9 @@ CREATE TABLE IF NOT EXISTS icinga_servicegroups ( config_type smallint default 0, servicegroup_object_id bigint unsigned default 0, alias TEXT character set latin1 default '', + notes TEXT character set latin1 default NULL, + notes_url TEXT character set latin1 default NULL, + action_url TEXT character set latin1 default NULL, PRIMARY KEY (servicegroup_id), UNIQUE KEY instance_id (instance_id,config_type,servicegroup_object_id) ) ENGINE=InnoDB COMMENT='Servicegroup definitions'; diff --git a/components/db_ido_mysql/schema/upgrade/0.0.10.sql b/components/db_ido_mysql/schema/upgrade/0.0.10.sql new file mode 100644 index 000000000..1fdff956b --- /dev/null +++ b/components/db_ido_mysql/schema/upgrade/0.0.10.sql @@ -0,0 +1,8 @@ + + +ALTER TABLE icinga_hostgroups ADD COLUMN notes TEXT character set latin1 default NULL; +ALTER TABLE icinga_hostgroups ADD COLUMN notes_url TEXT character set latin1 default NULL; +ALTER TABLE icinga_hostgroups ADD COLUMN action_url TEXT character set latin1 default NULL; +ALTER TABLE icinga_servicegroups ADD COLUMN notes TEXT character set latin1 default NULL; +ALTER TABLE icinga_servicegroups ADD COLUMN notes_url TEXT character set latin1 default NULL; +ALTER TABLE icinga_servicegroups ADD COLUMN action_url TEXT character set latin1 default NULL; diff --git a/components/db_ido_pgsql/schema/pgsql.sql b/components/db_ido_pgsql/schema/pgsql.sql index eb6ab4234..f568ca8cc 100644 --- a/components/db_ido_pgsql/schema/pgsql.sql +++ b/components/db_ido_pgsql/schema/pgsql.sql @@ -627,6 +627,9 @@ CREATE TABLE icinga_hostgroups ( config_type INTEGER default 0, hostgroup_object_id bigint default 0, alias TEXT default '', + notes TEXT default NULL, + notes_url TEXT default NULL, + action_url TEXT default NULL, CONSTRAINT PK_hostgroup_id PRIMARY KEY (hostgroup_id) , CONSTRAINT UQ_hostgroups UNIQUE (instance_id,hostgroup_object_id) ) ; @@ -1113,6 +1116,9 @@ CREATE TABLE icinga_servicegroups ( config_type INTEGER default 0, servicegroup_object_id bigint default 0, alias TEXT default '', + notes TEXT default NULL, + notes_url TEXT default NULL, + action_url TEXT default NULL, CONSTRAINT PK_servicegroup_id PRIMARY KEY (servicegroup_id) , CONSTRAINT UQ_servicegroups UNIQUE (instance_id,config_type,servicegroup_object_id) ) ; diff --git a/components/db_ido_pgsql/schema/upgrade/0.0.10.sql b/components/db_ido_pgsql/schema/upgrade/0.0.10.sql new file mode 100644 index 000000000..c80125904 --- /dev/null +++ b/components/db_ido_pgsql/schema/upgrade/0.0.10.sql @@ -0,0 +1,8 @@ + + +ALTER TABLE icinga_hostgroups ADD COLUMN notes TEXT default NULL; +ALTER TABLE icinga_hostgroups ADD COLUMN notes_url TEXT default NULL; +ALTER TABLE icinga_hostgroups ADD COLUMN action_url TEXT default NULL; +ALTER TABLE icinga_servicegroups ADD COLUMN notes TEXT default NULL; +ALTER TABLE icinga_servicegroups ADD COLUMN notes_url TEXT default NULL; +ALTER TABLE icinga_servicegroups ADD COLUMN action_url TEXT default NULL; diff --git a/components/livestatus/hostgroupstable.cpp b/components/livestatus/hostgroupstable.cpp index c9c73a708..2e0c4134f 100644 --- a/components/livestatus/hostgroupstable.cpp +++ b/components/livestatus/hostgroupstable.cpp @@ -85,32 +85,17 @@ Value HostGroupsTable::AliasAccessor(const Value& row) Value HostGroupsTable::NotesAccessor(const Value& row) { - Dictionary::Ptr vars = static_cast(row)->GetVars(); - - if (!vars) - return Empty; - - return vars->Get("notes"); + return static_cast(row)->GetNotes(); } Value HostGroupsTable::NotesUrlAccessor(const Value& row) { - Dictionary::Ptr vars = static_cast(row)->GetVars(); - - if (!vars) - return Empty; - - return vars->Get("notes_url"); + return static_cast(row)->GetNotesUrl(); } Value HostGroupsTable::ActionUrlAccessor(const Value& row) { - Dictionary::Ptr vars = static_cast(row)->GetVars(); - - if (!vars) - return Empty; - - return vars->Get("action_url"); + return static_cast(row)->GetActionUrl(); } Value HostGroupsTable::MembersAccessor(const Value& row) diff --git a/components/livestatus/servicegroupstable.cpp b/components/livestatus/servicegroupstable.cpp index 7e48eb0d7..7f4a20afd 100644 --- a/components/livestatus/servicegroupstable.cpp +++ b/components/livestatus/servicegroupstable.cpp @@ -76,32 +76,17 @@ Value ServiceGroupsTable::AliasAccessor(const Value& row) Value ServiceGroupsTable::NotesAccessor(const Value& row) { - Dictionary::Ptr vars = static_cast(row)->GetVars(); - - if (!vars) - return Empty; - - return vars->Get("notes"); + return static_cast(row)->GetNotes(); } Value ServiceGroupsTable::NotesUrlAccessor(const Value& row) { - Dictionary::Ptr vars = static_cast(row)->GetVars(); - - if (!vars) - return Empty; - - return vars->Get("notes_url"); + return static_cast(row)->GetNotesUrl(); } Value ServiceGroupsTable::ActionUrlAccessor(const Value& row) { - Dictionary::Ptr vars = static_cast(row)->GetVars(); - - if (!vars) - return Empty; - - return vars->Get("action_url"); + return static_cast(row)->GetActionUrl(); } Value ServiceGroupsTable::MembersAccessor(const Value& row) diff --git a/lib/db_ido/hostgroupdbobject.cpp b/lib/db_ido/hostgroupdbobject.cpp index 1f2945b57..e569ff5d7 100644 --- a/lib/db_ido/hostgroupdbobject.cpp +++ b/lib/db_ido/hostgroupdbobject.cpp @@ -39,6 +39,9 @@ Dictionary::Ptr HostGroupDbObject::GetConfigFields(void) const HostGroup::Ptr group = static_pointer_cast(GetObject()); fields->Set("alias", group->GetDisplayName()); + fields->Set("notes", group->GetNotes()); + fields->Set("notes_url", group->GetNotesUrl()); + fields->Set("action_url", group->GetActionUrl()); return fields; } diff --git a/lib/db_ido/servicegroupdbobject.cpp b/lib/db_ido/servicegroupdbobject.cpp index 5faf2bd68..a119bcb34 100644 --- a/lib/db_ido/servicegroupdbobject.cpp +++ b/lib/db_ido/servicegroupdbobject.cpp @@ -38,6 +38,9 @@ Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const ServiceGroup::Ptr group = static_pointer_cast(GetObject()); fields->Set("alias", group->GetDisplayName()); + fields->Set("notes", group->GetNotes()); + fields->Set("notes_url", group->GetNotesUrl()); + fields->Set("action_url", group->GetActionUrl()); return fields; } diff --git a/lib/icinga/hostgroup.ti b/lib/icinga/hostgroup.ti index 43f54c8f6..a254856a7 100644 --- a/lib/icinga/hostgroup.ti +++ b/lib/icinga/hostgroup.ti @@ -15,6 +15,9 @@ class HostGroup : DynamicObject }; [config] Array::Ptr groups; + [config] String notes; + [config] String notes_url; + [config] String action_url; }; } diff --git a/lib/icinga/icinga-type.conf b/lib/icinga/icinga-type.conf index 048d6535a..e648dabd1 100644 --- a/lib/icinga/icinga-type.conf +++ b/lib/icinga/icinga-type.conf @@ -76,6 +76,10 @@ %attribute %array "groups" { %attribute %name(HostGroup) "*" }, + + %attribute %string "notes", + %attribute %string "notes_url", + %attribute %string "action_url", } %type Service %inherits Checkable { @@ -95,6 +99,10 @@ %attribute %array "groups" { %attribute %name(ServiceGroup) "*" }, + + %attribute %string "notes", + %attribute %string "notes_url", + %attribute %string "action_url", } %type Notification { diff --git a/lib/icinga/servicegroup.ti b/lib/icinga/servicegroup.ti index 5d79331ee..383e993bc 100644 --- a/lib/icinga/servicegroup.ti +++ b/lib/icinga/servicegroup.ti @@ -15,6 +15,9 @@ class ServiceGroup : DynamicObject }; [config] Array::Ptr groups; + [config] String notes; + [config] String notes_url; + [config] String action_url; }; }