"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/icinga/service.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

service.cpp  (icinga2-2.11.5):service.cpp  (icinga2-2.12.0)
skipping to change at line 16 skipping to change at line 16
#include "icinga/scheduleddowntime.hpp" #include "icinga/scheduleddowntime.hpp"
#include "icinga/pluginutility.hpp" #include "icinga/pluginutility.hpp"
#include "base/objectlock.hpp" #include "base/objectlock.hpp"
#include "base/convert.hpp" #include "base/convert.hpp"
#include "base/utility.hpp" #include "base/utility.hpp"
using namespace icinga; using namespace icinga;
REGISTER_TYPE(Service); REGISTER_TYPE(Service);
boost::signals2::signal<void (const Service::Ptr&, const CheckResult::Ptr&, cons
t MessageOrigin::Ptr&)> Service::OnHostProblemChanged;
String ServiceNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const String ServiceNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const
{ {
Service::Ptr service = dynamic_pointer_cast<Service>(context); Service::Ptr service = dynamic_pointer_cast<Service>(context);
if (!service) if (!service)
return ""; return "";
return service->GetHostName() + "!" + shortName; return service->GetHostName() + "!" + shortName;
} }
skipping to change at line 106 skipping to change at line 108
} else { } else {
return Service::GetByName(serviceName); return Service::GetByName(serviceName);
} }
} }
Host::Ptr Service::GetHost() const Host::Ptr Service::GetHost() const
{ {
return m_Host; return m_Host;
} }
/* keep in sync with Host::GetSeverity() */ /* keep in sync with Host::GetSeverity()
* One could think it may be smart to use an enum and some bitmask math here.
* But the only thing the consuming icingaweb2 cares about is being able to
* sort by severity. It is therefore easier to keep them seperated here. */
int Service::GetSeverity() const int Service::GetSeverity() const
{ {
int severity = 0; int severity;
ObjectLock olock(this); ObjectLock olock(this);
ServiceState state = GetStateRaw(); ServiceState state = GetStateRaw();
if (!HasBeenChecked()) if (!HasBeenChecked()) {
severity |= SeverityFlagPending; severity = 16;
else if (state == ServiceWarning) } else if (state == ServiceOK) {
severity |= SeverityFlagWarning; severity = 0;
else if (state == ServiceUnknown) } else {
severity |= SeverityFlagUnknown; switch (state) {
else if (state == ServiceCritical) case ServiceWarning:
severity |= SeverityFlagCritical; severity = 32;
break;
/* TODO: Add host reachability and handled */ case ServiceUnknown:
if (IsInDowntime()) severity = 64;
severity |= SeverityFlagDowntime; break;
else if (IsAcknowledged()) case ServiceCritical:
severity |= SeverityFlagAcknowledgement; severity = 128;
else if (m_Host && m_Host->GetProblem()) break;
severity |= SeverityFlagHostDown; default:
else severity = 256;
severity |= SeverityFlagUnhandled; }
Host::Ptr host = GetHost();
ObjectLock hlock (host);
if (host->GetState() != HostUp || !host->IsReachable()) {
severity += 1024;
} else {
if (IsAcknowledged())
severity += 512;
else if (IsInDowntime())
severity += 256;
else
severity += 2048;
}
hlock.Unlock();
}
olock.Unlock(); olock.Unlock();
return severity; return severity;
} }
bool Service::GetHandled() const bool Service::GetHandled() const
{ {
return Checkable::GetHandled() || (m_Host && m_Host->GetProblem()); return Checkable::GetHandled() || (m_Host && m_Host->GetProblem());
} }
 End of changes. 4 change blocks. 
20 lines changed or deleted 41 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)