Bugfixes.

This commit is contained in:
Gunnar Beutner 2012-07-03 15:01:09 +02:00
parent 734ec2f5fb
commit f9139a6f97
4 changed files with 25 additions and 9 deletions

View File

@ -186,22 +186,35 @@ void Service::InvalidateDependencyCache(void)
m_DependencyCacheValid = false; m_DependencyCacheValid = false;
} }
ServiceStatusMessage Service::CalculateCombinedStatus(ServiceStatusMessage *input, const vector<Service>& parents) ServiceStatusMessage Service::CalculateCombinedStatus(Service *current, ServiceStatusMessage *input, const vector<Service>& parents)
{ {
vector<Service> failedServices; vector<Service> failedServices;
time_t nextCheck = -1; time_t nextCheck = -1;
time_t lastChange = -1;
vector<Service>::const_iterator it; vector<Service>::const_iterator it;
for (it = parents.begin(); it != parents.end(); it++) { for (it = parents.begin(); it != parents.end(); it++) {
Service parent = *it; Service parent = *it;
if (parent.GetState() != StateOK && parent.GetState() != StateWarning) if (current && current->GetName() == parent.GetName())
failedServices.push_back(parent); continue;
if (lastChange == -1 || parent.GetLastStateChange() > lastChange) if (!parent.HasLastCheckResult())
lastChange = parent.GetLastStateChange(); continue;
string svcname;
ServiceState state = StateUnknown;
ServiceStateType type = StateTypeHard;
if (input && input->GetService(&svcname) && svcname == parent.GetName()) {
input->GetState(&state);
input->GetStateType(&type);
} else {
state = parent.GetState();
type = parent.GetStateType();
}
if (state != StateOK && state != StateWarning && type == StateTypeHard)
failedServices.push_back(parent);
if (nextCheck == -1 || parent.GetNextCheck() < nextCheck) if (nextCheck == -1 || parent.GetNextCheck() < nextCheck)
nextCheck = parent.GetNextCheck(); nextCheck = parent.GetNextCheck();

View File

@ -50,7 +50,7 @@ public:
static void UpdateDependencyCache(void); static void UpdateDependencyCache(void);
static void InvalidateDependencyCache(void); static void InvalidateDependencyCache(void);
static ServiceStatusMessage CalculateCombinedStatus(ServiceStatusMessage *input, const vector<Service>& parents); static ServiceStatusMessage CalculateCombinedStatus(Service *current, ServiceStatusMessage *input, const vector<Service>& parents);
void SetNextCheck(time_t nextCheck); void SetNextCheck(time_t nextCheck);
time_t GetNextCheck(void); time_t GetNextCheck(void);

View File

@ -113,6 +113,9 @@ void CompatComponent::DumpServiceStatus(ofstream& fp, Service service)
int state = service.GetState(); int state = service.GetState();
if (state == StateUnreachable)
state = StateCritical;
if (state >= StateUnknown) if (state >= StateUnknown)
state = StateUnknown; state = StateUnknown;

View File

@ -315,7 +315,7 @@ void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender,
vector<Service> affectedServices = child.GetParents(); vector<Service> affectedServices = child.GetParents();
affectedServices.push_back(child); affectedServices.push_back(child);
ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(NULL, affectedServices); ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&child, NULL, affectedServices);
statusmsg.SetService(child.GetName()); statusmsg.SetService(child.GetName());
ServiceState state = StateUnreachable; ServiceState state = StateUnreachable;
@ -335,7 +335,7 @@ void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender,
rm.SetMethod("delegation::ServiceStatus"); rm.SetMethod("delegation::ServiceStatus");
vector<Service> parents = service.GetParents(); vector<Service> parents = service.GetParents();
ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&params, parents); ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&service, &params, parents);
statusmsg.SetService(service.GetName()); statusmsg.SetService(service.GetName());
rm.SetParams(statusmsg); rm.SetParams(statusmsg);