mirror of https://github.com/Icinga/icinga2.git
Distinguish between 'dependencies' (reachability) and 'hostchecks' (host status).
This commit is contained in:
parent
55ca6fd276
commit
746d24c9a2
|
@ -71,12 +71,22 @@ void CompatComponent::DumpHostStatus(ofstream& fp, Host host)
|
||||||
for (it = dependencies->Begin(); it != dependencies->End(); it++) {
|
for (it = dependencies->Begin(); it != dependencies->End(); it++) {
|
||||||
Service service = Service::GetByName(it->second);
|
Service service = Service::GetByName(it->second);
|
||||||
|
|
||||||
if (!service.IsReachable()) {
|
if (!service.IsReachable() ||
|
||||||
|
(service.GetState() != StateOK && service.GetState() != StateWarning)) {
|
||||||
std::cerr << service.GetName() << " is unreachable." << std::endl;
|
std::cerr << service.GetName() << " is unreachable." << std::endl;
|
||||||
state = 2; /* unreachable */
|
state = 2; /* unreachable */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary::Ptr hostchecks;
|
||||||
|
if (state == 0 && host.GetConfigObject()->GetProperty("hostchecks", &hostchecks)) {
|
||||||
|
hostchecks = Service::ResolveDependencies(host, hostchecks);
|
||||||
|
|
||||||
|
Dictionary::Iterator it;
|
||||||
|
for (it = hostchecks->Begin(); it != hostchecks->End(); it++) {
|
||||||
|
Service service = Service::GetByName(it->second);
|
||||||
if (service.GetState() != StateOK && service.GetState() != StateWarning) {
|
if (service.GetState() != StateOK && service.GetState() != StateWarning) {
|
||||||
state = 1; /* down */
|
state = 1; /* down */
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -75,6 +75,11 @@ void ConvenienceComponent::CopyServiceAttributes(const ConfigObject::Ptr& host,
|
||||||
Dictionary::Ptr checkers;
|
Dictionary::Ptr checkers;
|
||||||
if (service->GetProperty("checkers", &checkers))
|
if (service->GetProperty("checkers", &checkers))
|
||||||
builder->AddExpression("checkers", OperatorSet, checkers);
|
builder->AddExpression("checkers", OperatorSet, checkers);
|
||||||
|
|
||||||
|
Dictionary::Ptr dependencies;
|
||||||
|
if (service->GetProperty("dependencies", &dependencies))
|
||||||
|
builder->AddExpression("dependencies", OperatorPlus,
|
||||||
|
Service::ResolveDependencies(host, dependencies));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item)
|
void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item)
|
||||||
|
@ -130,11 +135,6 @@ void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item)
|
||||||
builder->AddParent(parent);
|
builder->AddParent(parent);
|
||||||
|
|
||||||
CopyServiceAttributes(host, service, builder);
|
CopyServiceAttributes(host, service, builder);
|
||||||
|
|
||||||
Dictionary::Ptr dependencies;
|
|
||||||
if (service->GetProperty("dependencies", &dependencies))
|
|
||||||
builder->AddExpression("dependencies", OperatorPlus,
|
|
||||||
Service::ResolveDependencies(host, dependencies));
|
|
||||||
} else {
|
} else {
|
||||||
throw invalid_argument("Service description must be either a string or a dictionary.");
|
throw invalid_argument("Service description must be either a string or a dictionary.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue