config: Don't clone host/service attributes.

This commit is contained in:
Gunnar Beutner 2013-09-25 08:51:55 +02:00
parent bf1a800e39
commit a401d871eb
4 changed files with 54 additions and 168 deletions

View File

@ -227,24 +227,6 @@ void Host::UpdateSlaveServices(void)
} }
} }
/* Clone attributes from the host object. */
std::set<String, string_iless> keys;
keys.insert("check_interval");
keys.insert("retry_interval");
keys.insert("servicegroups");
keys.insert("notification_interval");
keys.insert("notification_type_filter");
keys.insert("notification_state_filter");
keys.insert("check_period");
keys.insert("servicedependencies");
keys.insert("hostdependencies");
keys.insert("authorities");
keys.insert("domains");
ExpressionList::Ptr host_exprl = boost::make_shared<ExpressionList>();
item->GetLinkedExpressionList()->ExtractFiltered(keys, host_exprl);
builder->AddExpressionList(host_exprl);
/* Clone attributes from the service expression list. */ /* Clone attributes from the service expression list. */
ExpressionList::Ptr svc_exprl = boost::make_shared<ExpressionList>(); ExpressionList::Ptr svc_exprl = boost::make_shared<ExpressionList>();
item->GetLinkedExpressionList()->ExtractPath(path, svc_exprl); item->GetLinkedExpressionList()->ExtractPath(path, svc_exprl);

View File

@ -45,59 +45,16 @@ type Host {
} }
}, },
%attribute dictionary "notifications" {
%attribute dictionary "*" {
%attribute array "templates" {
%attribute name(Notification) "*"
},
%attribute any "*"
}
},
/* service attributes */
%attribute number "max_check_attempts",
%attribute name(TimePeriod) "check_period",
%attribute number "check_interval",
%attribute number "retry_interval",
%attribute number "enable_notifications",
%attribute number "notification_interval",
%attribute name(TimePeriod) "notification_period",
%attribute number "enable_flapping",
%attribute number "flapping_threshold",
%attribute number "notification_type_filter",
%attribute number "notification_state_filter",
%attribute dictionary "macros" { %attribute dictionary "macros" {
%attribute string "*" %attribute string "*"
}, },
%attribute dictionary "custom" {
%attribute string "*"
},
%attribute array "servicegroups" {
%attribute name(ServiceGroup) "*"
},
%attribute array "checkers" {
%attribute string "*"
}
} }
type HostGroup { type HostGroup {
%attribute string "display_name", %attribute string "display_name"
%attribute string "notes_url",
%attribute string "action_url"
} }
type IcingaApplication { type IcingaApplication {
%attribute string "pid_path",
%attribute dictionary "macros" {
%attribute string "*"
}
} }
type Service { type Service {
@ -107,11 +64,8 @@ type Service {
%attribute string "short_name", %attribute string "short_name",
%attribute string "display_name", %attribute string "display_name",
%attribute dictionary "macros" {
%attribute string "*"
},
%attribute dictionary "custom" { %attribute dictionary "macros" {
%attribute string "*" %attribute string "*"
}, },
@ -147,9 +101,6 @@ type Service {
%attribute array "servicegroups" { %attribute array "servicegroups" {
%attribute name(ServiceGroup) "*" %attribute name(ServiceGroup) "*"
}, },
%attribute array "checkers" {
%attribute string "*"
},
%attribute dictionary "notifications" { %attribute dictionary "notifications" {
%attribute dictionary "*" { %attribute dictionary "*" {
@ -163,14 +114,12 @@ type Service {
} }
type ServiceGroup { type ServiceGroup {
%attribute string "display_name", %attribute string "display_name"
%attribute string "notes_url",
%attribute string "action_url"
} }
type Notification { type Notification {
%require "host_name", %require "host_name",
%attribute string "host_name", %attribute name(Host) "host_name",
%attribute string "service", %attribute string "service",
%attribute dictionary "macros" { %attribute dictionary "macros" {
@ -215,13 +164,10 @@ type User {
%attribute number "notification_type_filter", %attribute number "notification_type_filter",
%attribute number "notification_state_filter", %attribute number "notification_state_filter",
%attribute name(TimePeriod) "notification_period" %attribute name(TimePeriod) "notification_period"
} }
type UserGroup { type UserGroup {
%attribute string "display_name", %attribute string "display_name"
%attribute string "action_url",
%attribute string "notes_url"
} }
type TimePeriod { type TimePeriod {

View File

@ -98,46 +98,17 @@ void Service::RemoveNotification(const Notification::Ptr& notification)
void Service::UpdateSlaveNotifications(void) void Service::UpdateSlaveNotifications(void)
{ {
ConfigItem::Ptr serviceItem, hostItem; ConfigItem::Ptr item = ConfigItem::GetObject("Service", GetName());
serviceItem = ConfigItem::GetObject("Service", GetName());
/* Don't create slave notifications unless we own this object */ /* Don't create slave notifications unless we own this object */
if (!serviceItem) if (!item)
return; return;
Host::Ptr host = GetHost();
if (!host)
return;
hostItem = ConfigItem::GetObject("Host", host->GetName());
/* Don't create slave notifications unless we own the host */
if (!hostItem)
return;
std::vector<Dictionary::Ptr> descLists;
descLists.push_back(GetNotificationDescriptions());
descLists.push_back(host->GetNotificationDescriptions());
for (int i = 0; i < 2; i++) {
Dictionary::Ptr descs;
ConfigItem::Ptr item;
if (i == 0) {
/* Host notification descs */
descs = host->GetNotificationDescriptions();
item = hostItem;
} else {
/* Service notification descs */ /* Service notification descs */
descs = GetNotificationDescriptions(); Dictionary::Ptr descs = GetNotificationDescriptions();
item = serviceItem;
}
if (!descs) if (!descs)
continue; return;
ObjectLock olock(descs); ObjectLock olock(descs);
@ -161,7 +132,7 @@ void Service::UpdateSlaveNotifications(void)
ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>(di); ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>(di);
builder->SetType("Notification"); builder->SetType("Notification");
builder->SetName(name); builder->SetName(name);
builder->AddExpression("host_name", OperatorSet, host->GetName()); builder->AddExpression("host_name", OperatorSet, GetHost()->GetName());
builder->AddExpression("service", OperatorSet, GetShortName()); builder->AddExpression("service", OperatorSet, GetShortName());
if (!nfcdesc.IsObjectType<Dictionary>()) if (!nfcdesc.IsObjectType<Dictionary>())
@ -179,20 +150,6 @@ void Service::UpdateSlaveNotifications(void)
} }
} }
/* Clone attributes from the host/service object. */
std::set<String, string_iless> keys;
keys.insert("users");
keys.insert("groups");
keys.insert("notification_interval");
keys.insert("notification_period");
keys.insert("notification_type_filter");
keys.insert("notification_state_filter");
keys.insert("export_macros");
ExpressionList::Ptr svc_exprl = boost::make_shared<ExpressionList>();
item->GetLinkedExpressionList()->ExtractFiltered(keys, svc_exprl);
builder->AddExpressionList(svc_exprl);
/* Clone attributes from the notification expression list. */ /* Clone attributes from the notification expression list. */
ExpressionList::Ptr nfc_exprl = boost::make_shared<ExpressionList>(); ExpressionList::Ptr nfc_exprl = boost::make_shared<ExpressionList>();
item->GetLinkedExpressionList()->ExtractPath(path, nfc_exprl); item->GetLinkedExpressionList()->ExtractPath(path, nfc_exprl);
@ -209,7 +166,6 @@ void Service::UpdateSlaveNotifications(void)
dobj->OnConfigLoaded(); dobj->OnConfigLoaded();
} }
} }
}
bool Service::GetEnableNotifications(void) const bool Service::GetEnableNotifications(void) const
{ {

View File

@ -46,6 +46,8 @@ void Service::Start(void)
{ {
DynamicObject::Start(); DynamicObject::Start();
VERIFY(GetHost());
SetSchedulingOffset(rand()); SetSchedulingOffset(rand());
UpdateNextCheck(); UpdateNextCheck();