mirror of https://github.com/Icinga/icinga2.git
Bugfixes.
This commit is contained in:
parent
734ec2f5fb
commit
f9139a6f97
|
@ -186,22 +186,35 @@ void Service::InvalidateDependencyCache(void)
|
|||
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;
|
||||
|
||||
time_t nextCheck = -1;
|
||||
time_t lastChange = -1;
|
||||
|
||||
vector<Service>::const_iterator it;
|
||||
for (it = parents.begin(); it != parents.end(); it++) {
|
||||
Service parent = *it;
|
||||
|
||||
if (parent.GetState() != StateOK && parent.GetState() != StateWarning)
|
||||
failedServices.push_back(parent);
|
||||
if (current && current->GetName() == parent.GetName())
|
||||
continue;
|
||||
|
||||
if (lastChange == -1 || parent.GetLastStateChange() > lastChange)
|
||||
lastChange = parent.GetLastStateChange();
|
||||
if (!parent.HasLastCheckResult())
|
||||
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)
|
||||
nextCheck = parent.GetNextCheck();
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
static void UpdateDependencyCache(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);
|
||||
time_t GetNextCheck(void);
|
||||
|
|
|
@ -113,6 +113,9 @@ void CompatComponent::DumpServiceStatus(ofstream& fp, Service service)
|
|||
|
||||
int state = service.GetState();
|
||||
|
||||
if (state == StateUnreachable)
|
||||
state = StateCritical;
|
||||
|
||||
if (state >= StateUnknown)
|
||||
state = StateUnknown;
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender,
|
|||
vector<Service> affectedServices = child.GetParents();
|
||||
affectedServices.push_back(child);
|
||||
|
||||
ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(NULL, affectedServices);
|
||||
ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&child, NULL, affectedServices);
|
||||
statusmsg.SetService(child.GetName());
|
||||
|
||||
ServiceState state = StateUnreachable;
|
||||
|
@ -335,7 +335,7 @@ void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender,
|
|||
rm.SetMethod("delegation::ServiceStatus");
|
||||
|
||||
vector<Service> parents = service.GetParents();
|
||||
ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(¶ms, parents);
|
||||
ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&service, ¶ms, parents);
|
||||
statusmsg.SetService(service.GetName());
|
||||
|
||||
rm.SetParams(statusmsg);
|
||||
|
|
Loading…
Reference in New Issue