From: Gunnar Beutner Date: Wed, 6 Feb 2013 21:41:40 +0000 (+0100) Subject: objects.cache: Implement service dependencies X-Git-Tag: v0.0.2~531 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a64fa1b9944a9a8522502563181e31bb153c1fe9;p=icinga2 objects.cache: Implement service dependencies Fixes #3639 --- diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp index 65354c56a..4b294c70f 100644 --- a/components/compat/compatcomponent.cpp +++ b/components/compat/compatcomponent.cpp @@ -36,7 +36,7 @@ String CompatComponent::GetStatusPath(void) const { Value statusPath = GetConfig()->Get("status_path"); if (statusPath.IsEmpty()) - return Application::GetLocalStateDir() + "/cache/status.dat"; + return Application::GetLocalStateDir() + "/cache/icinga2/status.dat"; else return statusPath; } @@ -50,7 +50,7 @@ String CompatComponent::GetObjectsPath(void) const { Value objectsPath = GetConfig()->Get("objects_path"); if (objectsPath.IsEmpty()) - return Application::GetLocalStateDir() + "/cache/objects.cache"; + return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache"; else return objectsPath; } @@ -384,6 +384,27 @@ void CompatComponent::DumpServiceObject(ofstream& fp, const Service::Ptr& servic << "\t" << "passive_checks_enabled" << "\t" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n" << "\t" << "}" << "\n" << "\n"; + + Dictionary::Ptr dependencies = boost::make_shared(); + service->GetDependenciesRecursive(dependencies); + + Value dependency; + BOOST_FOREACH(tie(tuples::ignore, dependency), dependencies) { + Service::Ptr depService = Service::GetByName(dependency); + + /* ignore ourselves */ + if (depService->GetName() == service->GetName()) + continue; + + fp << "define servicedependency {" << "\n" + << "\t" << "dependent_host_name" << "\t" << service->GetHost()->GetName() << "\n" + << "\t" << "dependent_service_description" << "\t" << service->GetName() << "\n" + << "\t" << "host_name" << "\t" << depService->GetHost()->GetName() << "\n" + << "\t" << "service_description" << "\t" << depService->GetName() << "\n" + << "\t" << "execution_failure_criteria" << "\t" << "n" << "\n" + << "\t" << "}" << "\n" + << "\n"; + } } /**