StatusDataWriter: Fix missing host dependencies.

Fixes #6102
This commit is contained in:
Michael Friedrich 2014-05-01 20:54:09 +02:00
parent 630a1a28e2
commit adc684289a

View File

@ -38,6 +38,7 @@
#include "base/statsfunction.h" #include "base/statsfunction.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <fstream> #include <fstream>
@ -702,9 +703,6 @@ void StatusDataWriter::UpdateObjectsCache(void)
Service::Ptr parent_service; Service::Ptr parent_service;
tie(parent_host, parent_service) = GetHostService(parent); tie(parent_host, parent_service) = GetHostService(parent);
if (!parent_service)
continue;
Checkable::Ptr child = dep->GetChild(); Checkable::Ptr child = dep->GetChild();
if (!child) if (!child)
@ -714,18 +712,41 @@ void StatusDataWriter::UpdateObjectsCache(void)
Service::Ptr child_service; Service::Ptr child_service;
tie(child_host, child_service) = GetHostService(child); tie(child_host, child_service) = GetHostService(child);
if (!child_service) int state_filter = dep->GetStateFilter();
continue; std::vector<String> failure_criteria;
if (state_filter & StateFilterOK || state_filter & StateFilterUp)
failure_criteria.push_back("o");
if (state_filter & StateFilterWarning)
failure_criteria.push_back("w");
if (state_filter & StateFilterCritical)
failure_criteria.push_back("c");
if (state_filter & StateFilterUnknown)
failure_criteria.push_back("u");
if (state_filter & StateFilterDown)
failure_criteria.push_back("d");
objectfp << "define servicedependency {" "\n" String criteria = boost::algorithm::join(failure_criteria, ",");
"\t" "dependent_host_name" "\t" << child_service->GetHost()->GetName() << "\n"
"\t" "dependent_service_description" "\t" << child_service->GetShortName() << "\n" if (!child_service && !parent_service) {
"\t" "host_name" "\t" << parent_service->GetHost()->GetName() << "\n" objectfp << "define hostdependency {" "\n"
"\t" "service_description" "\t" << parent_service->GetShortName() << "\n" "\t" "dependent_host_name" "\t" << child_host->GetName() << "\n"
"\t" "execution_failure_criteria" "\t" "n" "\n" "\t" "host_name" "\t" << parent_host->GetName() << "\n"
"\t" "notification_failure_criteria" "\t" "w,u,c" "\n" "\t" "execution_failure_criteria" "\t" << criteria << "\n"
"\t" "}" "\n" "\t" "notification_failure_criteria" "\t" << criteria << "\n"
"\n"; "\t" "}" "\n"
"\n";
} else {
objectfp << "define servicedependency {" "\n"
"\t" "dependent_host_name" "\t" << child_service->GetHost()->GetName() << "\n"
"\t" "dependent_service_description" "\t" << child_service->GetShortName() << "\n"
"\t" "host_name" "\t" << parent_service->GetHost()->GetName() << "\n"
"\t" "service_description" "\t" << parent_service->GetShortName() << "\n"
"\t" "execution_failure_criteria" "\t" << criteria << "\n"
"\t" "notification_failure_criteria" "\t" << criteria << "\n"
"\t" "}" "\n"
"\n";
}
} }
objectfp.close(); objectfp.close();